aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-01-27 10:03:56 +0800
committerPo Lu2022-01-27 10:03:56 +0800
commita0fbdb5166e6bd7eccb7a3327b587b5ca5404b3b (patch)
tree0c48ae17c3f934a8569b0f0a7180aa3398c73a91 /src
parent458024a3d9e3c58d11deeb879ffc73c96840f6f0 (diff)
downloademacs-a0fbdb5166e6bd7eccb7a3327b587b5ca5404b3b.tar.gz
emacs-a0fbdb5166e6bd7eccb7a3327b587b5ca5404b3b.zip
Improve XI2 valuator reset logic
* src/xterm.c (handle_one_xevent): Clear valuators on XI_Leave instead of XI_Enter.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/src/xterm.c b/src/xterm.c
index d52d7311bb1..30a3aee20ee 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10390,32 +10390,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
10390 { 10390 {
10391#ifdef HAVE_XWIDGETS 10391#ifdef HAVE_XWIDGETS
10392 struct xwidget_view *xwidget_view = xwidget_view_from_window (enter->event); 10392 struct xwidget_view *xwidget_view = xwidget_view_from_window (enter->event);
10393#else 10393#endif
10394 bool xwidget_view = false;
10395#endif
10396
10397 /* One problem behind the design of XInput 2 scrolling is
10398 that valuators are not unique to each window, but only
10399 the window that has grabbed the valuator's device or
10400 the window that the device's pointer is on top of can
10401 receive motion events. There is also no way to
10402 retrieve the value of a valuator outside of each motion
10403 event.
10404
10405 As such, to prevent wildly inaccurate results when the
10406 valuators have changed outside Emacs, we reset our
10407 records of each valuator's value whenever the pointer
10408 re-enters a frame after its valuators have potentially
10409 been changed elsewhere. */
10410 if (enter->detail != XINotifyInferior
10411 && enter->mode != XINotifyPassiveUngrab
10412 /* See the comment under FocusIn in
10413 `x_detect_focus_change'. The main relevant culprit
10414 these days seems to be XFCE. */
10415 && enter->mode != XINotifyUngrab
10416 && (xwidget_view
10417 || (any && enter->event == FRAME_X_WINDOW (any))))
10418 xi_reset_scroll_valuators_for_device_id (dpyinfo, enter->deviceid);
10419 10394
10420#ifdef HAVE_XWIDGETS 10395#ifdef HAVE_XWIDGETS
10421 if (xwidget_view) 10396 if (xwidget_view)
@@ -10457,6 +10432,22 @@ handle_one_xevent (struct x_display_info *dpyinfo,
10457 ev.window = leave->event; 10432 ev.window = leave->event;
10458 any = x_top_window_to_frame (dpyinfo, leave->event); 10433 any = x_top_window_to_frame (dpyinfo, leave->event);
10459 10434
10435 /* One problem behind the design of XInput 2 scrolling is
10436 that valuators are not unique to each window, but only
10437 the window that has grabbed the valuator's device or
10438 the window that the device's pointer is on top of can
10439 receive motion events. There is also no way to
10440 retrieve the value of a valuator outside of each motion
10441 event.
10442
10443 As such, to prevent wildly inaccurate results when the
10444 valuators have changed outside Emacs, we reset our
10445 records of each valuator's value whenever the pointer
10446 moves out of a frame (and not into one of its
10447 children, which we know about). */
10448 if (leave->detail != XINotifyInferior && any)
10449 xi_reset_scroll_valuators_for_device_id (dpyinfo, enter->deviceid);
10450
10460#ifdef HAVE_XWIDGETS 10451#ifdef HAVE_XWIDGETS
10461 { 10452 {
10462 struct xwidget_view *xvw 10453 struct xwidget_view *xvw