Mercurial > emacs
comparison src/term.c @ 83632:cc587bfd19ca
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 781-792)
- Update from CVS
- Merge from gnus--rel--5.10
- Merge from emacs--rel--22
* emacs--rel--22 (patch 33-41)
* gnus--rel--5.10 (patch 226-228)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-21
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 11 Jun 2007 01:00:07 +0000 |
parents | 28201311b297 d620b28641cd |
children | 9c01792a3ce8 |
comparison
equal
deleted
inserted
replaced
83631:7d63b897231b | 83632:cc587bfd19ca |
---|---|
205 static int mouse_face_beg_row, mouse_face_beg_col; | 205 static int mouse_face_beg_row, mouse_face_beg_col; |
206 static int mouse_face_end_row, mouse_face_end_col; | 206 static int mouse_face_end_row, mouse_face_end_col; |
207 static int mouse_face_past_end; | 207 static int mouse_face_past_end; |
208 static Lisp_Object Qmouse_face_window; | 208 static Lisp_Object Qmouse_face_window; |
209 static int mouse_face_face_id; | 209 static int mouse_face_face_id; |
210 | |
211 /* FRAME and X, Y position of mouse when last checked for | |
212 highlighting. X and Y can be negative or out of range for the frame. */ | |
213 struct frame *mouse_face_mouse_frame; | |
214 int mouse_face_mouse_x, mouse_face_mouse_y; | |
215 | 210 |
216 static int pos_x, pos_y; | 211 static int pos_x, pos_y; |
217 static int last_mouse_x, last_mouse_y; | 212 static int last_mouse_x, last_mouse_y; |
218 #endif /* HAVE_GPM */ | 213 #endif /* HAVE_GPM */ |
219 | 214 |
2342 /*********************************************************************** | 2337 /*********************************************************************** |
2343 Mouse | 2338 Mouse |
2344 ***********************************************************************/ | 2339 ***********************************************************************/ |
2345 | 2340 |
2346 #ifdef HAVE_GPM | 2341 #ifdef HAVE_GPM |
2347 void term_mouse_moveto (int x, int y) | 2342 void |
2343 term_mouse_moveto (int x, int y) | |
2348 { | 2344 { |
2349 const char *name; | 2345 const char *name; |
2350 int fd; | 2346 int fd; |
2347 /* TODO: how to set mouse position? | |
2351 name = (const char *) ttyname (0); | 2348 name = (const char *) ttyname (0); |
2352 fd = open (name, O_WRONLY); | 2349 fd = open (name, O_WRONLY); |
2353 /* TODO: how to set mouse position? | 2350 SOME_FUNCTION (x, y, fd); |
2354 SOME_FUNCTION (x, y, fd); */ | |
2355 close (fd); | 2351 close (fd); |
2356 last_mouse_x = x; | 2352 last_mouse_x = x; |
2357 last_mouse_y = y; | 2353 last_mouse_y = y; */ |
2358 } | 2354 } |
2359 | 2355 |
2360 static void | 2356 static void |
2361 term_show_mouse_face (enum draw_glyphs_face draw) | 2357 term_show_mouse_face (enum draw_glyphs_face draw) |
2362 { | 2358 { |
2531 struct buffer *b; | 2527 struct buffer *b; |
2532 | 2528 |
2533 if (NILP (Vmouse_highlight) | 2529 if (NILP (Vmouse_highlight) |
2534 || !f->glyphs_initialized_p) | 2530 || !f->glyphs_initialized_p) |
2535 return; | 2531 return; |
2536 | |
2537 mouse_face_mouse_x = x; | |
2538 mouse_face_mouse_y = y; | |
2539 mouse_face_mouse_frame = f; | |
2540 | 2532 |
2541 /* Which window is that in? */ | 2533 /* Which window is that in? */ |
2542 window = window_from_coordinates (f, x, y, &part, &x, &y, 0); | 2534 window = window_from_coordinates (f, x, y, &part, &x, &y, 0); |
2543 | 2535 |
2544 /* Not on a window -> return. */ | 2536 /* Not on a window -> return. */ |
2777 { | 2769 { |
2778 /* Has the mouse moved off the glyph it was on at the last sighting? */ | 2770 /* Has the mouse moved off the glyph it was on at the last sighting? */ |
2779 if (event->x != last_mouse_x || event->y != last_mouse_y) | 2771 if (event->x != last_mouse_x || event->y != last_mouse_y) |
2780 { | 2772 { |
2781 frame->mouse_moved = 1; | 2773 frame->mouse_moved = 1; |
2782 term_mouse_highlight (frame, event->x - 1, event->y - 1); | 2774 term_mouse_highlight (frame, event->x, event->y); |
2783 /* Remember which glyph we're now on. */ | 2775 /* Remember which glyph we're now on. */ |
2784 last_mouse_x = event->x; | 2776 last_mouse_x = event->x; |
2785 last_mouse_y = event->y; | 2777 last_mouse_y = event->y; |
2786 return 1; | 2778 return 1; |
2787 } | 2779 } |
2797 Set *bar_window to Qnil, and *x and *y to the column and | 2789 Set *bar_window to Qnil, and *x and *y to the column and |
2798 row of the character cell the mouse is over. | 2790 row of the character cell the mouse is over. |
2799 | 2791 |
2800 Set *time to the time the mouse was at the returned position. | 2792 Set *time to the time the mouse was at the returned position. |
2801 | 2793 |
2802 This should clear mouse_moved until the next motion | 2794 This clears mouse_moved until the next motion |
2803 event arrives. */ | 2795 event arrives. */ |
2804 static void | 2796 static void |
2805 term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | 2797 term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, |
2806 enum scroll_bar_part *part, Lisp_Object *x, | 2798 enum scroll_bar_part *part, Lisp_Object *x, |
2807 Lisp_Object *y, unsigned long *time) | 2799 Lisp_Object *y, unsigned long *time) |
2808 { | 2800 { |
2809 struct timeval now; | 2801 struct timeval now; |
2810 Lisp_Object frame, window; | |
2811 struct window *w; | |
2812 | 2802 |
2813 *fp = SELECTED_FRAME (); | 2803 *fp = SELECTED_FRAME (); |
2814 (*fp)->mouse_moved = 0; | 2804 (*fp)->mouse_moved = 0; |
2815 | 2805 |
2816 *bar_window = Qnil; | 2806 *bar_window = Qnil; |
2817 *part = 0; | 2807 *part = 0; |
2818 | 2808 |
2819 XSETINT (*x, last_mouse_x); | 2809 XSETINT (*x, last_mouse_x); |
2820 XSETINT (*y, last_mouse_y); | 2810 XSETINT (*y, last_mouse_y); |
2821 XSETFRAME (frame, *fp); | |
2822 window = Fwindow_at (*x, *y, frame); | |
2823 | |
2824 XSETINT (*x, last_mouse_x - WINDOW_LEFT_EDGE_COL (XWINDOW (window))); | |
2825 XSETINT (*y, last_mouse_y - WINDOW_TOP_EDGE_LINE (XWINDOW (window))); | |
2826 gettimeofday(&now, 0); | 2811 gettimeofday(&now, 0); |
2827 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); | 2812 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); |
2828 } | 2813 } |
2829 | 2814 |
2830 /* Prepare a mouse-event in *RESULT for placement in the input queue. | 2815 /* Prepare a mouse-event in *RESULT for placement in the input queue. |
2867 result->modifiers |= triple_modifier; | 2852 result->modifiers |= triple_modifier; |
2868 | 2853 |
2869 if (event->type & GPM_DRAG) | 2854 if (event->type & GPM_DRAG) |
2870 result->modifiers |= drag_modifier; | 2855 result->modifiers |= drag_modifier; |
2871 | 2856 |
2872 if (!(event->type & (GPM_MOVE|GPM_DRAG))) { | 2857 if (!(event->type & (GPM_MOVE | GPM_DRAG))) { |
2873 | 2858 |
2874 /* 1 << KG_SHIFT */ | 2859 /* 1 << KG_SHIFT */ |
2875 if (event->modifiers & (1 << 0)) | 2860 if (event->modifiers & (1 << 0)) |
2876 result->modifiers |= shift_modifier; | 2861 result->modifiers |= shift_modifier; |
2877 | 2862 |
2883 if (event->modifiers & (1 << 3) | 2868 if (event->modifiers & (1 << 3) |
2884 || event->modifiers & (1 << 1)) | 2869 || event->modifiers & (1 << 1)) |
2885 result->modifiers |= meta_modifier; | 2870 result->modifiers |= meta_modifier; |
2886 } | 2871 } |
2887 | 2872 |
2888 XSETINT (result->x, event->x - 1); | 2873 XSETINT (result->x, event->x); |
2889 XSETINT (result->y, event->y - 1); | 2874 XSETINT (result->y, event->y); |
2890 XSETFRAME (result->frame_or_window, f); | 2875 XSETFRAME (result->frame_or_window, f); |
2891 result->arg = Qnil; | 2876 result->arg = Qnil; |
2892 return Qnil; | 2877 return Qnil; |
2893 } | 2878 } |
2894 | 2879 |
2903 | 2888 |
2904 EVENT_INIT (ie); | 2889 EVENT_INIT (ie); |
2905 ie.kind = NO_EVENT; | 2890 ie.kind = NO_EVENT; |
2906 ie.arg = Qnil; | 2891 ie.arg = Qnil; |
2907 | 2892 |
2908 if (event->type & GPM_MOVE) { | 2893 if (event->type & (GPM_MOVE | GPM_DRAG)) { |
2909 unsigned char buf[6 * sizeof (short)]; | 2894 unsigned char buf[6 * sizeof (short)]; |
2910 unsigned short *arg = (unsigned short *) buf + 1; | 2895 unsigned short *arg = (unsigned short *) buf + 1; |
2911 const char *name; | 2896 const char *name; |
2912 | 2897 |
2913 previous_help_echo_string = help_echo_string; | 2898 previous_help_echo_string = help_echo_string; |
2914 help_echo_string = Qnil; | 2899 help_echo_string = Qnil; |
2915 | 2900 |
2916 /* Display mouse pointer */ | 2901 /* Display mouse pointer */ |
2917 buf[sizeof(short) - 1] = 2; /* set selection */ | 2902 buf[sizeof(short) - 1] = 2; /* set selection */ |
2918 | 2903 |
2919 arg[0] = arg[2] = (unsigned short) event->x; | 2904 arg[0] = arg[2] = (unsigned short) event->x + gpm_zerobased; |
2920 arg[1] = arg[3] = (unsigned short) event->y; | 2905 arg[1] = arg[3] = (unsigned short) event->y + gpm_zerobased; |
2921 arg[4] = (unsigned short) 3; | 2906 arg[4] = (unsigned short) 3; |
2922 | 2907 |
2923 name = (const char *) ttyname (0); | 2908 name = (const char *) ttyname (0); |
2924 fd = open (name, O_WRONLY); | 2909 fd = open (name, O_WRONLY); |
2925 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); | 2910 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); |
2926 close (fd); | 2911 close (fd); |
2927 | 2912 |
2928 term_mouse_movement (f, event); | 2913 if (!term_mouse_movement (f, event)) |
2914 help_echo_string = previous_help_echo_string; | |
2929 | 2915 |
2930 /* If the contents of the global variable help_echo_string | 2916 /* If the contents of the global variable help_echo_string |
2931 has changed, generate a HELP_EVENT. */ | 2917 has changed, generate a HELP_EVENT. */ |
2932 if (!NILP (help_echo_string) | 2918 if (!NILP (help_echo_string) |
2933 || !NILP (previous_help_echo_string)) | 2919 || !NILP (previous_help_echo_string)) |
2975 | 2961 |
2976 connection.eventMask = ~0; | 2962 connection.eventMask = ~0; |
2977 connection.defaultMask = ~GPM_HARD; | 2963 connection.defaultMask = ~GPM_HARD; |
2978 connection.maxMod = ~0; | 2964 connection.maxMod = ~0; |
2979 connection.minMod = 0; | 2965 connection.minMod = 0; |
2966 gpm_zerobased = 1; | |
2980 | 2967 |
2981 /* We only support GPM on the controlling tty. */ | 2968 /* We only support GPM on the controlling tty. */ |
2982 if (term_gpm || tty->terminal->id > 1 | 2969 if (term_gpm || tty->terminal->id > 1 |
2983 || Gpm_Open (&connection, 0) < 0) | 2970 || Gpm_Open (&connection, 0) < 0) |
2984 return Qnil; | 2971 return Qnil; |