aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
authorNick Roberts2007-06-03 00:55:34 +0000
committerNick Roberts2007-06-03 00:55:34 +0000
commit80fb2ce07c307b39d012d25f30393ac7da255887 (patch)
treed71bf8c331491d6343f42f7d093c73adc46637a8 /src/term.c
parentdb1213a9935c8b417f55197f65f23b02ebcdd323 (diff)
downloademacs-80fb2ce07c307b39d012d25f30393ac7da255887.tar.gz
emacs-80fb2ce07c307b39d012d25f30393ac7da255887.zip
(term_mouse_highlight): Remove unused variables.
(Fterm_open_connection): Set gpm_zerobased to 1. (term_mouse_movement, term_mouse_click, handle_one_term_event): Use zero based co-ordinates. (handle_one_term_event): Report a drag as mouse movement too.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/term.c b/src/term.c
index 7abb5d2e049..88bb181fb81 100644
--- a/src/term.c
+++ b/src/term.c
@@ -428,11 +428,6 @@ static int mouse_face_past_end;
428static Lisp_Object Qmouse_face_window; 428static Lisp_Object Qmouse_face_window;
429static int mouse_face_face_id; 429static int mouse_face_face_id;
430 430
431/* FRAME and X, Y position of mouse when last checked for
432 highlighting. X and Y can be negative or out of range for the frame. */
433struct frame *mouse_face_mouse_frame;
434int mouse_face_mouse_x, mouse_face_mouse_y;
435
436static int pos_x, pos_y; 431static int pos_x, pos_y;
437static int last_mouse_x, last_mouse_y; 432static int last_mouse_x, last_mouse_y;
438#endif /* HAVE_GPM */ 433#endif /* HAVE_GPM */
@@ -2387,13 +2382,13 @@ term_mouse_moveto (int x, int y)
2387{ 2382{
2388 const char *name; 2383 const char *name;
2389 int fd; 2384 int fd;
2385 /* TODO: how to set mouse position?
2390 name = (const char *) ttyname (0); 2386 name = (const char *) ttyname (0);
2391 fd = open (name, O_WRONLY); 2387 fd = open (name, O_WRONLY);
2392 /* TODO: how to set mouse position? 2388 SOME_FUNCTION (x, y, fd);
2393 SOME_FUNCTION (x, y, fd); */
2394 close (fd); 2389 close (fd);
2395 last_mouse_x = x; 2390 last_mouse_x = x;
2396 last_mouse_y = y; 2391 last_mouse_y = y; */
2397} 2392}
2398 2393
2399static void 2394static void
@@ -2570,10 +2565,6 @@ term_mouse_highlight (struct frame *f, int x, int y)
2570 || !f->glyphs_initialized_p) 2565 || !f->glyphs_initialized_p)
2571 return; 2566 return;
2572 2567
2573 mouse_face_mouse_x = x;
2574 mouse_face_mouse_y = y;
2575 mouse_face_mouse_frame = f;
2576
2577 /* Which window is that in? */ 2568 /* Which window is that in? */
2578 window = window_from_coordinates (f, x, y, &part, &x, &y, 0); 2569 window = window_from_coordinates (f, x, y, &part, &x, &y, 0);
2579 2570
@@ -2815,7 +2806,7 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2815 if (event->x != last_mouse_x || event->y != last_mouse_y) 2806 if (event->x != last_mouse_x || event->y != last_mouse_y)
2816 { 2807 {
2817 frame->mouse_moved = 1; 2808 frame->mouse_moved = 1;
2818 term_mouse_highlight (frame, event->x - 1, event->y - 1); 2809 term_mouse_highlight (frame, event->x, event->y);
2819 /* Remember which glyph we're now on. */ 2810 /* Remember which glyph we're now on. */
2820 last_mouse_x = event->x; 2811 last_mouse_x = event->x;
2821 last_mouse_y = event->y; 2812 last_mouse_y = event->y;
@@ -2835,7 +2826,7 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2835 2826
2836 Set *time to the time the mouse was at the returned position. 2827 Set *time to the time the mouse was at the returned position.
2837 2828
2838 This should clear mouse_moved until the next motion 2829 This clears mouse_moved until the next motion
2839 event arrives. */ 2830 event arrives. */
2840static void 2831static void
2841term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, 2832term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
@@ -2843,8 +2834,6 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2843 Lisp_Object *y, unsigned long *time) 2834 Lisp_Object *y, unsigned long *time)
2844{ 2835{
2845 struct timeval now; 2836 struct timeval now;
2846 Lisp_Object frame, window;
2847 struct window *w;
2848 2837
2849 *fp = SELECTED_FRAME (); 2838 *fp = SELECTED_FRAME ();
2850 (*fp)->mouse_moved = 0; 2839 (*fp)->mouse_moved = 0;
@@ -2852,13 +2841,8 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
2852 *bar_window = Qnil; 2841 *bar_window = Qnil;
2853 *part = 0; 2842 *part = 0;
2854 2843
2855 XSETINT (*x, last_mouse_x); 2844 XSETINT (*x, last_mouse_x);
2856 XSETINT (*y, last_mouse_y); 2845 XSETINT (*y, last_mouse_y);
2857 XSETFRAME (frame, *fp);
2858 window = Fwindow_at (*x, *y, frame);
2859
2860 XSETINT (*x, last_mouse_x - WINDOW_LEFT_EDGE_COL (XWINDOW (window)));
2861 XSETINT (*y, last_mouse_y - WINDOW_TOP_EDGE_LINE (XWINDOW (window)));
2862 gettimeofday(&now, 0); 2846 gettimeofday(&now, 0);
2863 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000); 2847 *time = (now.tv_sec * 1000) + (now.tv_usec / 1000);
2864} 2848}
@@ -2905,7 +2889,7 @@ term_mouse_click (struct input_event *result, Gpm_Event *event,
2905 if (event->type & GPM_DRAG) 2889 if (event->type & GPM_DRAG)
2906 result->modifiers |= drag_modifier; 2890 result->modifiers |= drag_modifier;
2907 2891
2908 if (!(event->type & (GPM_MOVE|GPM_DRAG))) { 2892 if (!(event->type & (GPM_MOVE | GPM_DRAG))) {
2909 2893
2910 /* 1 << KG_SHIFT */ 2894 /* 1 << KG_SHIFT */
2911 if (event->modifiers & (1 << 0)) 2895 if (event->modifiers & (1 << 0))
@@ -2921,8 +2905,8 @@ term_mouse_click (struct input_event *result, Gpm_Event *event,
2921 result->modifiers |= meta_modifier; 2905 result->modifiers |= meta_modifier;
2922 } 2906 }
2923 2907
2924 XSETINT (result->x, event->x - 1); 2908 XSETINT (result->x, event->x);
2925 XSETINT (result->y, event->y - 1); 2909 XSETINT (result->y, event->y);
2926 XSETFRAME (result->frame_or_window, f); 2910 XSETFRAME (result->frame_or_window, f);
2927 result->arg = Qnil; 2911 result->arg = Qnil;
2928 return Qnil; 2912 return Qnil;
@@ -2941,7 +2925,7 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit)
2941 ie.kind = NO_EVENT; 2925 ie.kind = NO_EVENT;
2942 ie.arg = Qnil; 2926 ie.arg = Qnil;
2943 2927
2944 if (event->type & GPM_MOVE) { 2928 if (event->type & (GPM_MOVE | GPM_DRAG)) {
2945 unsigned char buf[6 * sizeof (short)]; 2929 unsigned char buf[6 * sizeof (short)];
2946 unsigned short *arg = (unsigned short *) buf + 1; 2930 unsigned short *arg = (unsigned short *) buf + 1;
2947 const char *name; 2931 const char *name;
@@ -2952,8 +2936,8 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit)
2952 /* Display mouse pointer */ 2936 /* Display mouse pointer */
2953 buf[sizeof(short) - 1] = 2; /* set selection */ 2937 buf[sizeof(short) - 1] = 2; /* set selection */
2954 2938
2955 arg[0] = arg[2] = (unsigned short) event->x; 2939 arg[0] = arg[2] = (unsigned short) event->x + gpm_zerobased;
2956 arg[1] = arg[3] = (unsigned short) event->y; 2940 arg[1] = arg[3] = (unsigned short) event->y + gpm_zerobased;
2957 arg[4] = (unsigned short) 3; 2941 arg[4] = (unsigned short) 3;
2958 2942
2959 name = (const char *) ttyname (0); 2943 name = (const char *) ttyname (0);
@@ -2961,7 +2945,8 @@ handle_one_term_event (Gpm_Event *event, struct input_event* hold_quit)
2961 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1); 2945 ioctl (fd, TIOCLINUX, buf + sizeof (short) - 1);
2962 close (fd); 2946 close (fd);
2963 2947
2964 term_mouse_movement (f, event); 2948 if (!term_mouse_movement (f, event))
2949 help_echo_string = previous_help_echo_string;
2965 2950
2966 /* If the contents of the global variable help_echo_string 2951 /* If the contents of the global variable help_echo_string
2967 has changed, generate a HELP_EVENT. */ 2952 has changed, generate a HELP_EVENT. */
@@ -3012,6 +2997,7 @@ DEFUN ("term-open-connection", Fterm_open_connection, Sterm_open_connection,
3012 connection.defaultMask = ~GPM_HARD; 2997 connection.defaultMask = ~GPM_HARD;
3013 connection.maxMod = ~0; 2998 connection.maxMod = ~0;
3014 connection.minMod = 0; 2999 connection.minMod = 0;
3000 gpm_zerobased = 1;
3015 3001
3016 if (Gpm_Open (&connection, 0) < 0) 3002 if (Gpm_Open (&connection, 0) < 0)
3017 return Qnil; 3003 return Qnil;