diff options
| author | Po Lu | 2022-06-22 09:49:16 +0800 |
|---|---|---|
| committer | Po Lu | 2022-06-22 09:49:16 +0800 |
| commit | d5a3fbe7c8b320cae26458ce353a5d933ded7bb9 (patch) | |
| tree | 628e8436729ebc40bf88ebb300418900f6a9f938 /src | |
| parent | 6f5f2ebfb4fe2652152bc0f69d6a1ffde3ec5c87 (diff) | |
| download | emacs-d5a3fbe7c8b320cae26458ce353a5d933ded7bb9.tar.gz emacs-d5a3fbe7c8b320cae26458ce353a5d933ded7bb9.zip | |
Fix setting user time for mouse movement events
* src/xterm.c (x_note_mouse_movement, XTmouse_position)
(x_scroll_bar_note_movement, handle_one_xevent): Record whether
or not mouse movement was send_event before using the mouse
movement time.
* src/xterm.h (struct x_display_info): New field
`last_mouse_movement_time_send_event'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 18 | ||||
| -rw-r--r-- | src/xterm.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/xterm.c b/src/xterm.c index ee78da085e2..f97452a2e56 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -12335,10 +12335,11 @@ x_construct_mouse_click (struct input_event *result, | |||
| 12335 | The XMotionEvent structure passed as EVENT might not come from the | 12335 | The XMotionEvent structure passed as EVENT might not come from the |
| 12336 | X server, and instead be artificially constructed from input | 12336 | X server, and instead be artificially constructed from input |
| 12337 | extension events. In these special events, the only fields that | 12337 | extension events. In these special events, the only fields that |
| 12338 | are initialized are `time', `window', and `x' and `y'. This | 12338 | are initialized are `time', `window', `send_event', `x' and `y'. |
| 12339 | function should not access any other fields in EVENT without also | 12339 | This function should not access any other fields in EVENT without |
| 12340 | initializing the corresponding fields in `ev' under the XI_Motion, | 12340 | also initializing the corresponding fields in `ev' under the |
| 12341 | XI_Enter and XI_Leave labels inside `handle_one_xevent'. */ | 12341 | XI_Motion, XI_Enter and XI_Leave labels inside |
| 12342 | `handle_one_xevent'. */ | ||
| 12342 | 12343 | ||
| 12343 | static bool | 12344 | static bool |
| 12344 | x_note_mouse_movement (struct frame *frame, const XMotionEvent *event, | 12345 | x_note_mouse_movement (struct frame *frame, const XMotionEvent *event, |
| @@ -12352,6 +12353,7 @@ x_note_mouse_movement (struct frame *frame, const XMotionEvent *event, | |||
| 12352 | 12353 | ||
| 12353 | dpyinfo = FRAME_DISPLAY_INFO (frame); | 12354 | dpyinfo = FRAME_DISPLAY_INFO (frame); |
| 12354 | dpyinfo->last_mouse_movement_time = event->time; | 12355 | dpyinfo->last_mouse_movement_time = event->time; |
| 12356 | dpyinfo->last_mouse_movement_time_send_event = event->send_event; | ||
| 12355 | dpyinfo->last_mouse_motion_frame = frame; | 12357 | dpyinfo->last_mouse_motion_frame = frame; |
| 12356 | dpyinfo->last_mouse_motion_x = event->x; | 12358 | dpyinfo->last_mouse_motion_x = event->x; |
| 12357 | dpyinfo->last_mouse_motion_y = event->y; | 12359 | dpyinfo->last_mouse_motion_y = event->y; |
| @@ -12667,7 +12669,8 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, | |||
| 12667 | && (dpyinfo->last_user_time | 12669 | && (dpyinfo->last_user_time |
| 12668 | < dpyinfo->last_mouse_movement_time)) | 12670 | < dpyinfo->last_mouse_movement_time)) |
| 12669 | x_display_set_last_user_time (dpyinfo, | 12671 | x_display_set_last_user_time (dpyinfo, |
| 12670 | dpyinfo->last_mouse_movement_time, false); | 12672 | dpyinfo->last_mouse_movement_time, |
| 12673 | dpyinfo->last_mouse_movement_time_send_event); | ||
| 12671 | 12674 | ||
| 12672 | if ((!f1 || FRAME_TOOLTIP_P (f1)) | 12675 | if ((!f1 || FRAME_TOOLTIP_P (f1)) |
| 12673 | && (EQ (track_mouse, Qdropping) | 12676 | && (EQ (track_mouse, Qdropping) |
| @@ -15075,6 +15078,7 @@ x_scroll_bar_note_movement (struct scroll_bar *bar, | |||
| 15075 | struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); | 15078 | struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); |
| 15076 | 15079 | ||
| 15077 | dpyinfo->last_mouse_movement_time = event->time; | 15080 | dpyinfo->last_mouse_movement_time = event->time; |
| 15081 | dpyinfo->last_mouse_movement_send_event = event->send_event; | ||
| 15078 | dpyinfo->last_mouse_scroll_bar = bar; | 15082 | dpyinfo->last_mouse_scroll_bar = bar; |
| 15079 | f->mouse_moved = true; | 15083 | f->mouse_moved = true; |
| 15080 | 15084 | ||
| @@ -19168,10 +19172,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 19168 | 19172 | ||
| 19169 | any = x_top_window_to_frame (dpyinfo, enter->event); | 19173 | any = x_top_window_to_frame (dpyinfo, enter->event); |
| 19170 | source = xi_device_from_id (dpyinfo, enter->sourceid); | 19174 | source = xi_device_from_id (dpyinfo, enter->sourceid); |
| 19175 | |||
| 19171 | ev.x = lrint (enter->event_x); | 19176 | ev.x = lrint (enter->event_x); |
| 19172 | ev.y = lrint (enter->event_y); | 19177 | ev.y = lrint (enter->event_y); |
| 19173 | ev.window = enter->event; | 19178 | ev.window = enter->event; |
| 19174 | ev.time = enter->time; | 19179 | ev.time = enter->time; |
| 19180 | ev.send_event = enter->send_event; | ||
| 19175 | 19181 | ||
| 19176 | x_display_set_last_user_time (dpyinfo, enter->time, | 19182 | x_display_set_last_user_time (dpyinfo, enter->time, |
| 19177 | enter->send_event); | 19183 | enter->send_event); |
| @@ -19262,6 +19268,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 19262 | ev.y = lrint (leave->event_y); | 19268 | ev.y = lrint (leave->event_y); |
| 19263 | ev.window = leave->event; | 19269 | ev.window = leave->event; |
| 19264 | ev.time = leave->time; | 19270 | ev.time = leave->time; |
| 19271 | ev.send_event = leave->send_event; | ||
| 19265 | #endif | 19272 | #endif |
| 19266 | 19273 | ||
| 19267 | any = x_top_window_to_frame (dpyinfo, leave->event); | 19274 | any = x_top_window_to_frame (dpyinfo, leave->event); |
| @@ -19680,6 +19687,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 19680 | ev.y = lrint (xev->event_y); | 19687 | ev.y = lrint (xev->event_y); |
| 19681 | ev.window = xev->event; | 19688 | ev.window = xev->event; |
| 19682 | ev.time = xev->time; | 19689 | ev.time = xev->time; |
| 19690 | ev.send_event = xev->send_event; | ||
| 19683 | 19691 | ||
| 19684 | #ifdef USE_MOTIF | 19692 | #ifdef USE_MOTIF |
| 19685 | use_copy = true; | 19693 | use_copy = true; |
diff --git a/src/xterm.h b/src/xterm.h index 3d243f3eabf..f136b6b97fe 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -515,6 +515,9 @@ struct x_display_info | |||
| 515 | received, and return that in hopes that it's somewhat accurate. */ | 515 | received, and return that in hopes that it's somewhat accurate. */ |
| 516 | Time last_mouse_movement_time; | 516 | Time last_mouse_movement_time; |
| 517 | 517 | ||
| 518 | /* Whether or not the last mouse motion was synthetic. */ | ||
| 519 | bool last_mouse_movement_time_send_event; | ||
| 520 | |||
| 518 | /* The gray pixmap. */ | 521 | /* The gray pixmap. */ |
| 519 | Pixmap gray; | 522 | Pixmap gray; |
| 520 | 523 | ||