diff options
| author | Po Lu | 2022-02-14 13:13:13 +0800 |
|---|---|---|
| committer | Po Lu | 2022-02-14 13:14:54 +0800 |
| commit | 32fbda5c37d7c11201df8232c1cc6e2b5d88791e (patch) | |
| tree | 8dd2d80cdc609fbd50a1802502339ac2ed161610 /src | |
| parent | 80f8dd654014aff065df76095aedfd09c21faf92 (diff) | |
| download | emacs-32fbda5c37d7c11201df8232c1cc6e2b5d88791e.tar.gz emacs-32fbda5c37d7c11201df8232c1cc6e2b5d88791e.zip | |
Ensure bad values don't leak into scroll valuators after DeviceChange
* src/xterm.c (xi_reset_scroll_valuators_for_device_id): New
argument `pending_only'.
(handle_one_xevent): Reset pending scroll valuators on XI_Enter
and mark valuators updated via DeviceChanged events as pending.
* src/xterm.h (struct xi_scroll_valuator_t): New field
`pending_enter_reset'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 23 | ||||
| -rw-r--r-- | src/xterm.h | 1 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/xterm.c b/src/xterm.c index 98c8a224080..9cde6c9a683 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -791,7 +791,8 @@ xi_find_touch_point (struct xi_device_t *device, int detail) | |||
| 791 | #endif /* XI_TouchBegin */ | 791 | #endif /* XI_TouchBegin */ |
| 792 | 792 | ||
| 793 | static void | 793 | static void |
| 794 | xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo, int id) | 794 | xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo, int id, |
| 795 | bool pending_only) | ||
| 795 | { | 796 | { |
| 796 | struct xi_device_t *device = xi_device_from_id (dpyinfo, id); | 797 | struct xi_device_t *device = xi_device_from_id (dpyinfo, id); |
| 797 | struct xi_scroll_valuator_t *valuator; | 798 | struct xi_scroll_valuator_t *valuator; |
| @@ -805,6 +806,11 @@ xi_reset_scroll_valuators_for_device_id (struct x_display_info *dpyinfo, int id) | |||
| 805 | for (int i = 0; i < device->scroll_valuator_count; ++i) | 806 | for (int i = 0; i < device->scroll_valuator_count; ++i) |
| 806 | { | 807 | { |
| 807 | valuator = &device->valuators[i]; | 808 | valuator = &device->valuators[i]; |
| 809 | |||
| 810 | if (pending_only && !valuator->pending_enter_reset) | ||
| 811 | continue; | ||
| 812 | |||
| 813 | valuator->pending_enter_reset = false; | ||
| 808 | valuator->invalid_p = true; | 814 | valuator->invalid_p = true; |
| 809 | valuator->emacs_value = 0.0; | 815 | valuator->emacs_value = 0.0; |
| 810 | } | 816 | } |
| @@ -10853,6 +10859,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 10853 | if (!any) | 10859 | if (!any) |
| 10854 | any = x_any_window_to_frame (dpyinfo, enter->event); | 10860 | any = x_any_window_to_frame (dpyinfo, enter->event); |
| 10855 | 10861 | ||
| 10862 | xi_reset_scroll_valuators_for_device_id (dpyinfo, enter->deviceid, | ||
| 10863 | true); | ||
| 10864 | |||
| 10856 | { | 10865 | { |
| 10857 | #ifdef HAVE_XWIDGETS | 10866 | #ifdef HAVE_XWIDGETS |
| 10858 | struct xwidget_view *xwidget_view = xwidget_view_from_window (enter->event); | 10867 | struct xwidget_view *xwidget_view = xwidget_view_from_window (enter->event); |
| @@ -10916,7 +10925,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 10916 | moves out of a frame (and not into one of its | 10925 | moves out of a frame (and not into one of its |
| 10917 | children, which we know about). */ | 10926 | children, which we know about). */ |
| 10918 | if (leave->detail != XINotifyInferior && any) | 10927 | if (leave->detail != XINotifyInferior && any) |
| 10919 | xi_reset_scroll_valuators_for_device_id (dpyinfo, enter->deviceid); | 10928 | xi_reset_scroll_valuators_for_device_id (dpyinfo, |
| 10929 | enter->deviceid, false); | ||
| 10920 | 10930 | ||
| 10921 | #ifdef HAVE_XWIDGETS | 10931 | #ifdef HAVE_XWIDGETS |
| 10922 | { | 10932 | { |
| @@ -11937,6 +11947,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 11937 | { | 11947 | { |
| 11938 | device->valuators[i].invalid_p = false; | 11948 | device->valuators[i].invalid_p = false; |
| 11939 | device->valuators[i].current_value = info->value; | 11949 | device->valuators[i].current_value = info->value; |
| 11950 | |||
| 11951 | /* Make sure that this is reset if the | ||
| 11952 | pointer moves into a window of ours. | ||
| 11953 | |||
| 11954 | Otherwise the valuator state could be | ||
| 11955 | left invalid if the DeviceChange | ||
| 11956 | event happened with the pointer | ||
| 11957 | outside any Emacs frame. */ | ||
| 11958 | device->valuators[i].pending_enter_reset = true; | ||
| 11940 | } | 11959 | } |
| 11941 | } | 11960 | } |
| 11942 | } | 11961 | } |
diff --git a/src/xterm.h b/src/xterm.h index 99c86ced56c..f58fa0fe54d 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -184,6 +184,7 @@ struct color_name_cache_entry | |||
| 184 | struct xi_scroll_valuator_t | 184 | struct xi_scroll_valuator_t |
| 185 | { | 185 | { |
| 186 | bool invalid_p; | 186 | bool invalid_p; |
| 187 | bool pending_enter_reset; | ||
| 187 | double current_value; | 188 | double current_value; |
| 188 | double emacs_value; | 189 | double emacs_value; |
| 189 | double increment; | 190 | double increment; |