diff options
Diffstat (limited to 'src/xterm.c')
| -rw-r--r-- | src/xterm.c | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/src/xterm.c b/src/xterm.c index 4355e9d6b83..bc7dd639c6b 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -133,6 +133,9 @@ extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *); | |||
| 133 | #include <X11/XKBlib.h> | 133 | #include <X11/XKBlib.h> |
| 134 | #endif | 134 | #endif |
| 135 | 135 | ||
| 136 | /* Default to using XGetMotionEvents. */ | ||
| 137 | #define X_MOTION_HISTORY 1 | ||
| 138 | |||
| 136 | /* Default to using XIM if available. */ | 139 | /* Default to using XIM if available. */ |
| 137 | #ifdef USE_XIM | 140 | #ifdef USE_XIM |
| 138 | int use_xim = 1; | 141 | int use_xim = 1; |
| @@ -221,15 +224,6 @@ static struct frame *last_mouse_glyph_frame; | |||
| 221 | 224 | ||
| 222 | static Lisp_Object last_mouse_scroll_bar; | 225 | static Lisp_Object last_mouse_scroll_bar; |
| 223 | 226 | ||
| 224 | /* This is a hack. We would really prefer that XTmouse_position would | ||
| 225 | return the time associated with the position it returns, but there | ||
| 226 | doesn't seem to be any way to wrest the time-stamp from the server | ||
| 227 | along with the position query. So, we just keep track of the time | ||
| 228 | of the last movement we received, and return that in hopes that | ||
| 229 | it's somewhat accurate. */ | ||
| 230 | |||
| 231 | static Time last_mouse_movement_time; | ||
| 232 | |||
| 233 | /* Time for last user interaction as returned in X events. */ | 227 | /* Time for last user interaction as returned in X events. */ |
| 234 | 228 | ||
| 235 | static Time last_user_time; | 229 | static Time last_user_time; |
| @@ -3722,7 +3716,44 @@ construct_mouse_click (struct input_event *result, XButtonEvent *event, struct f | |||
| 3722 | return Qnil; | 3716 | return Qnil; |
| 3723 | } | 3717 | } |
| 3724 | 3718 | ||
| 3725 | 3719 | #ifdef X_MOTION_HISTORY | |
| 3720 | |||
| 3721 | /* Here we assume that X server supports XGetMotionEvents. If you hit | ||
| 3722 | eassert in the function below, most probably your X server is too | ||
| 3723 | old and/or buggy. Undef X_MOTION_HISTORY to enable legacy code. */ | ||
| 3724 | |||
| 3725 | static Time | ||
| 3726 | x_last_mouse_movement_time (struct frame *f) | ||
| 3727 | { | ||
| 3728 | Time t; | ||
| 3729 | int nevents; | ||
| 3730 | XTimeCoord *xtc = XGetMotionEvents (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 3731 | 1, last_user_time, &nevents); | ||
| 3732 | eassert (xtc && nevents > 0); | ||
| 3733 | t = xtc[nevents - 1].time; | ||
| 3734 | XFree (xtc); | ||
| 3735 | return t; | ||
| 3736 | } | ||
| 3737 | |||
| 3738 | #else /* no X_MOTION_HISTORY */ | ||
| 3739 | |||
| 3740 | /* This is a hack. We would really prefer that XTmouse_position would | ||
| 3741 | return the time associated with the position it returns, but there | ||
| 3742 | doesn't seem to be any way to wrest the time-stamp from the server | ||
| 3743 | along with the position query. So, we just keep track of the time | ||
| 3744 | of the last movement we received, and return that in hopes that | ||
| 3745 | it's somewhat accurate. */ | ||
| 3746 | |||
| 3747 | static Time last_mouse_movement_time; | ||
| 3748 | |||
| 3749 | static Time | ||
| 3750 | x_last_mouse_movement_time (struct frame *f) | ||
| 3751 | { | ||
| 3752 | return last_mouse_movement_time; | ||
| 3753 | } | ||
| 3754 | |||
| 3755 | #endif /* X_MOTION_HISTORY */ | ||
| 3756 | |||
| 3726 | /* Function to report a mouse movement to the mainstream Emacs code. | 3757 | /* Function to report a mouse movement to the mainstream Emacs code. |
| 3727 | The input handler calls this. | 3758 | The input handler calls this. |
| 3728 | 3759 | ||
| @@ -3737,7 +3768,9 @@ static Lisp_Object last_mouse_motion_frame; | |||
| 3737 | static int | 3768 | static int |
| 3738 | note_mouse_movement (struct frame *frame, XMotionEvent *event) | 3769 | note_mouse_movement (struct frame *frame, XMotionEvent *event) |
| 3739 | { | 3770 | { |
| 3771 | #ifndef X_MOTION_HISTORY | ||
| 3740 | last_mouse_movement_time = event->time; | 3772 | last_mouse_movement_time = event->time; |
| 3773 | #endif /* legacy */ | ||
| 3741 | last_mouse_motion_event = *event; | 3774 | last_mouse_motion_event = *event; |
| 3742 | XSETFRAME (last_mouse_motion_frame, frame); | 3775 | XSETFRAME (last_mouse_motion_frame, frame); |
| 3743 | 3776 | ||
| @@ -3993,7 +4026,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, | |||
| 3993 | *fp = f1; | 4026 | *fp = f1; |
| 3994 | XSETINT (*x, win_x); | 4027 | XSETINT (*x, win_x); |
| 3995 | XSETINT (*y, win_y); | 4028 | XSETINT (*y, win_y); |
| 3996 | *timestamp = last_mouse_movement_time; | 4029 | *timestamp = x_last_mouse_movement_time (f1); |
| 3997 | } | 4030 | } |
| 3998 | } | 4031 | } |
| 3999 | } | 4032 | } |
| @@ -5499,9 +5532,9 @@ static void | |||
| 5499 | x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) | 5532 | x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) |
| 5500 | { | 5533 | { |
| 5501 | struct frame *f = XFRAME (XWINDOW (bar->window)->frame); | 5534 | struct frame *f = XFRAME (XWINDOW (bar->window)->frame); |
| 5502 | 5535 | #ifndef X_MOTION_HISTORY | |
| 5503 | last_mouse_movement_time = event->xmotion.time; | 5536 | last_mouse_movement_time = event->xmotion.time; |
| 5504 | 5537 | #endif /* legacy */ | |
| 5505 | f->mouse_moved = 1; | 5538 | f->mouse_moved = 1; |
| 5506 | XSETVECTOR (last_mouse_scroll_bar, bar); | 5539 | XSETVECTOR (last_mouse_scroll_bar, bar); |
| 5507 | 5540 | ||
| @@ -5586,10 +5619,9 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window, | |||
| 5586 | 5619 | ||
| 5587 | f->mouse_moved = 0; | 5620 | f->mouse_moved = 0; |
| 5588 | last_mouse_scroll_bar = Qnil; | 5621 | last_mouse_scroll_bar = Qnil; |
| 5622 | *timestamp = x_last_mouse_movement_time (f); | ||
| 5589 | } | 5623 | } |
| 5590 | 5624 | ||
| 5591 | *timestamp = last_mouse_movement_time; | ||
| 5592 | |||
| 5593 | unblock_input (); | 5625 | unblock_input (); |
| 5594 | } | 5626 | } |
| 5595 | 5627 | ||