aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-03-01 14:59:32 +0800
committerPo Lu2022-03-01 14:59:32 +0800
commit54474a6db2bccdfe862307bf343af44ab3c79829 (patch)
tree392452584871298889121f0a0aa08941d0221a4e /src
parentdb9b9435cddb1201bc57c65f44f90208e7047582 (diff)
downloademacs-54474a6db2bccdfe862307bf343af44ab3c79829.tar.gz
emacs-54474a6db2bccdfe862307bf343af44ab3c79829.zip
Avoid duplicate wheel and button events on non-toolkit scroll bars
* src/xterm.c (x_scroll_bar_create): Set appropriate input extension event mask. (handle_one_xevent): Move some ifdefs around and handle input extension button events on scroll bars.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 3e35ae50b83..ec17203fcdb 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8489,6 +8489,30 @@ x_scroll_bar_create (struct window *w, int top, int left,
8489 CopyFromParent, 8489 CopyFromParent,
8490 /* Attributes. */ 8490 /* Attributes. */
8491 mask, &a); 8491 mask, &a);
8492
8493#ifdef HAVE_XINPUT2
8494 /* Ask for input extension button and motion events. This lets us
8495 send the proper `wheel-up' or `wheel-down' events to Emacs. */
8496 if (FRAME_DISPLAY_INFO (f)->supports_xi2)
8497 {
8498 XIEventMask mask;
8499 ptrdiff_t l = XIMaskLen (XI_LASTEVENT);
8500 unsigned char *m;
8501
8502 mask.mask = m = alloca (l);
8503 memset (m, 0, l);
8504 mask.mask_len = l;
8505
8506 mask.deviceid = XIAllMasterDevices;
8507 XISetMask (m, XI_ButtonPress);
8508 XISetMask (m, XI_ButtonRelease);
8509 XISetMask (m, XI_Motion);
8510 XISetMask (m, XI_Enter);
8511 XISetMask (m, XI_Leave);
8512
8513 XISelectEvents (FRAME_X_DISPLAY (f), window, &mask, 1);
8514 }
8515#endif
8492 bar->x_window = window; 8516 bar->x_window = window;
8493 } 8517 }
8494#endif /* not USE_TOOLKIT_SCROLL_BARS */ 8518#endif /* not USE_TOOLKIT_SCROLL_BARS */
@@ -11725,7 +11749,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
11725 11749
11726 if (!f) 11750 if (!f)
11727 { 11751 {
11728#if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS 11752#if defined USE_MOTIF || !defined USE_TOOLKIT_SCROLL_BARS
11729 struct scroll_bar *bar 11753 struct scroll_bar *bar
11730 = x_window_to_scroll_bar (xi_event->display, 11754 = x_window_to_scroll_bar (xi_event->display,
11731 xev->event, 2); 11755 xev->event, 2);
@@ -12207,6 +12231,17 @@ handle_one_xevent (struct x_display_info *dpyinfo,
12207 xembed_send_message (f, xev->time, 12231 xembed_send_message (f, xev->time,
12208 XEMBED_REQUEST_FOCUS, 0, 0, 0); 12232 XEMBED_REQUEST_FOCUS, 0, 0, 0);
12209 } 12233 }
12234#ifndef USE_TOOLKIT_SCROLL_BARS
12235 else
12236 {
12237 struct scroll_bar *bar
12238 = x_window_to_scroll_bar (dpyinfo->display,
12239 xev->event, 2);
12240
12241 if (bar)
12242 x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev.ie);
12243 }
12244#endif
12210 12245
12211 if (xev->evtype == XI_ButtonPress) 12246 if (xev->evtype == XI_ButtonPress)
12212 { 12247 {