diff options
| author | Dmitry Antipov | 2013-09-02 19:48:59 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-09-02 19:48:59 +0400 |
| commit | b594a96c8729c73619c1cccdcb092653910fc70a (patch) | |
| tree | 82e019c6cdd05d13c32934ea64af2dbfad90a7bd /src | |
| parent | 96edb677815a79f2952d49959a0d4a8be6da08d6 (diff) | |
| download | emacs-b594a96c8729c73619c1cccdcb092653910fc70a.tar.gz emacs-b594a96c8729c73619c1cccdcb092653910fc70a.zip | |
* xterm.c (x_last_mouse_movement_time): Revert last change.
This code should use XDisplayMotionBufferSize to check display's
motion history first, and there are few other issues as well.
(x_scroll_bar_note_movement): Pass XMotionEvent rather than XEvent.
(handle_one_xevent): Adjust user.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/xterm.c | 73 |
2 files changed, 26 insertions, 55 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1af0a8193cf..2507f898c5a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2013-09-02 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * xterm.c (x_last_mouse_movement_time): Revert last change. | ||
| 4 | This code should use XDisplayMotionBufferSize to check display's | ||
| 5 | motion history first, and there are few other issues as well. | ||
| 6 | (x_scroll_bar_note_movement): Pass XMotionEvent rather than XEvent. | ||
| 7 | (handle_one_xevent): Adjust user. | ||
| 8 | |||
| 1 | 2013-09-02 Martin Rudalics <rudalics@gmx.at> | 9 | 2013-09-02 Martin Rudalics <rudalics@gmx.at> |
| 2 | 10 | ||
| 3 | * frame.c (check_minibuf_window): Don't abort if no window was | 11 | * frame.c (check_minibuf_window): Don't abort if no window was |
diff --git a/src/xterm.c b/src/xterm.c index 2def3ef11d5..f470afea446 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -133,9 +133,6 @@ 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 | |||
| 139 | /* Default to using XIM if available. */ | 136 | /* Default to using XIM if available. */ |
| 140 | #ifdef USE_XIM | 137 | #ifdef USE_XIM |
| 141 | int use_xim = 1; | 138 | int use_xim = 1; |
| @@ -224,6 +221,15 @@ static struct frame *last_mouse_glyph_frame; | |||
| 224 | 221 | ||
| 225 | static Lisp_Object last_mouse_scroll_bar; | 222 | static Lisp_Object last_mouse_scroll_bar; |
| 226 | 223 | ||
| 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 | |||
| 227 | /* Time for last user interaction as returned in X events. */ | 233 | /* Time for last user interaction as returned in X events. */ |
| 228 | 234 | ||
| 229 | static Time last_user_time; | 235 | static Time last_user_time; |
| @@ -3716,48 +3722,6 @@ construct_mouse_click (struct input_event *result, XButtonEvent *event, struct f | |||
| 3716 | return Qnil; | 3722 | return Qnil; |
| 3717 | } | 3723 | } |
| 3718 | 3724 | ||
| 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; | ||
| 3731 | |||
| 3732 | block_input (); | ||
| 3733 | xtc = XGetMotionEvents (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 3734 | 1, last_user_time, &nevents); | ||
| 3735 | eassert (xtc && nevents > 0); | ||
| 3736 | t = xtc[nevents - 1].time; | ||
| 3737 | XFree (xtc); | ||
| 3738 | unblock_input (); | ||
| 3739 | return t; | ||
| 3740 | } | ||
| 3741 | |||
| 3742 | #else /* no X_MOTION_HISTORY */ | ||
| 3743 | |||
| 3744 | /* This is a hack. We would really prefer that XTmouse_position would | ||
| 3745 | return the time associated with the position it returns, but there | ||
| 3746 | doesn't seem to be any way to wrest the time-stamp from the server | ||
| 3747 | along with the position query. So, we just keep track of the time | ||
| 3748 | of the last movement we received, and return that in hopes that | ||
| 3749 | it's somewhat accurate. */ | ||
| 3750 | |||
| 3751 | static Time last_mouse_movement_time; | ||
| 3752 | |||
| 3753 | static Time | ||
| 3754 | x_last_mouse_movement_time (struct frame *f) | ||
| 3755 | { | ||
| 3756 | return last_mouse_movement_time; | ||
| 3757 | } | ||
| 3758 | |||
| 3759 | #endif /* X_MOTION_HISTORY */ | ||
| 3760 | |||
| 3761 | /* Function to report a mouse movement to the mainstream Emacs code. | 3725 | /* Function to report a mouse movement to the mainstream Emacs code. |
| 3762 | The input handler calls this. | 3726 | The input handler calls this. |
| 3763 | 3727 | ||
| @@ -3772,9 +3736,7 @@ static Lisp_Object last_mouse_motion_frame; | |||
| 3772 | static int | 3736 | static int |
| 3773 | note_mouse_movement (struct frame *frame, XMotionEvent *event) | 3737 | note_mouse_movement (struct frame *frame, XMotionEvent *event) |
| 3774 | { | 3738 | { |
| 3775 | #ifndef X_MOTION_HISTORY | ||
| 3776 | last_mouse_movement_time = event->time; | 3739 | last_mouse_movement_time = event->time; |
| 3777 | #endif /* legacy */ | ||
| 3778 | last_mouse_motion_event = *event; | 3740 | last_mouse_motion_event = *event; |
| 3779 | XSETFRAME (last_mouse_motion_frame, frame); | 3741 | XSETFRAME (last_mouse_motion_frame, frame); |
| 3780 | 3742 | ||
| @@ -4030,7 +3992,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, | |||
| 4030 | *fp = f1; | 3992 | *fp = f1; |
| 4031 | XSETINT (*x, win_x); | 3993 | XSETINT (*x, win_x); |
| 4032 | XSETINT (*y, win_y); | 3994 | XSETINT (*y, win_y); |
| 4033 | *timestamp = x_last_mouse_movement_time (f1); | 3995 | *timestamp = last_mouse_movement_time; |
| 4034 | } | 3996 | } |
| 4035 | } | 3997 | } |
| 4036 | } | 3998 | } |
| @@ -5533,12 +5495,12 @@ x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_e | |||
| 5533 | mark bits. */ | 5495 | mark bits. */ |
| 5534 | 5496 | ||
| 5535 | static void | 5497 | static void |
| 5536 | x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) | 5498 | x_scroll_bar_note_movement (struct scroll_bar *bar, XMotionEvent *event) |
| 5537 | { | 5499 | { |
| 5538 | struct frame *f = XFRAME (XWINDOW (bar->window)->frame); | 5500 | struct frame *f = XFRAME (XWINDOW (bar->window)->frame); |
| 5539 | #ifndef X_MOTION_HISTORY | 5501 | |
| 5540 | last_mouse_movement_time = event->xmotion.time; | 5502 | last_mouse_movement_time = event->time; |
| 5541 | #endif /* legacy */ | 5503 | |
| 5542 | f->mouse_moved = 1; | 5504 | f->mouse_moved = 1; |
| 5543 | XSETVECTOR (last_mouse_scroll_bar, bar); | 5505 | XSETVECTOR (last_mouse_scroll_bar, bar); |
| 5544 | 5506 | ||
| @@ -5546,7 +5508,7 @@ x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) | |||
| 5546 | if (! NILP (bar->dragging)) | 5508 | if (! NILP (bar->dragging)) |
| 5547 | { | 5509 | { |
| 5548 | /* Where should the handle be now? */ | 5510 | /* Where should the handle be now? */ |
| 5549 | int new_start = event->xmotion.y - XINT (bar->dragging); | 5511 | int new_start = event->y - XINT (bar->dragging); |
| 5550 | 5512 | ||
| 5551 | if (new_start != bar->start) | 5513 | if (new_start != bar->start) |
| 5552 | { | 5514 | { |
| @@ -5623,9 +5585,10 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window, | |||
| 5623 | 5585 | ||
| 5624 | f->mouse_moved = 0; | 5586 | f->mouse_moved = 0; |
| 5625 | last_mouse_scroll_bar = Qnil; | 5587 | last_mouse_scroll_bar = Qnil; |
| 5626 | *timestamp = x_last_mouse_movement_time (f); | ||
| 5627 | } | 5588 | } |
| 5628 | 5589 | ||
| 5590 | *timestamp = last_mouse_movement_time; | ||
| 5591 | |||
| 5629 | unblock_input (); | 5592 | unblock_input (); |
| 5630 | } | 5593 | } |
| 5631 | 5594 | ||
| @@ -6722,7 +6685,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6722 | event.xmotion.window); | 6685 | event.xmotion.window); |
| 6723 | 6686 | ||
| 6724 | if (bar) | 6687 | if (bar) |
| 6725 | x_scroll_bar_note_movement (bar, &event); | 6688 | x_scroll_bar_note_movement (bar, &event.xmotion); |
| 6726 | #endif /* USE_TOOLKIT_SCROLL_BARS */ | 6689 | #endif /* USE_TOOLKIT_SCROLL_BARS */ |
| 6727 | 6690 | ||
| 6728 | /* If we move outside the frame, then we're | 6691 | /* If we move outside the frame, then we're |