diff options
author | Po Lu <luangruo@yahoo.com> | 2022-08-16 21:11:03 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-08-16 21:11:50 +0800 |
commit | b4879603fd8f9c8e82e30c5fbb65fa63d8166ee4 (patch) | |
tree | 1e22ea48430d56aa01474bb0c2d2d485f8c6e2cb | |
parent | 81ff64d3ca8d6e43e976f209399d2a0e9b4a7dd8 (diff) | |
download | emacs-b4879603fd8f9c8e82e30c5fbb65fa63d8166ee4.tar.gz |
Fix XInput hierarchy events not being delivered in daemon mode
* src/xfns.c (setup_xi_event_mask): Stop selecting for device
hierarchy events.
* src/xterm.c (xi_select_hierarchy_events, x_term_init): Select
those here instead, on the default root window.
-rw-r--r-- | src/xfns.c | 14 | ||||
-rw-r--r-- | src/xterm.c | 33 |
2 files changed, 39 insertions, 8 deletions
diff --git a/src/xfns.c b/src/xfns.c index 6ed93ee42ca..a275e3e11a8 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3773,14 +3773,11 @@ setup_xi_event_mask (struct frame *f) memset (m, 0, l); #endif - mask.deviceid = XIAllDevices; - - XISetMask (m, XI_PropertyEvent); - XISetMask (m, XI_HierarchyChanged); - XISetMask (m, XI_DeviceChanged); #ifdef HAVE_XINPUT2_2 if (FRAME_DISPLAY_INFO (f)->xi2_version >= 2) { + mask.deviceid = XIAllDevices; + XISetMask (m, XI_TouchBegin); XISetMask (m, XI_TouchUpdate); XISetMask (m, XI_TouchEnd); @@ -3792,11 +3789,12 @@ setup_xi_event_mask (struct frame *f) XISetMask (m, XI_GesturePinchEnd); } #endif + + XISelectEvents (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + &mask, 1); } #endif - XISelectEvents (FRAME_X_DISPLAY (f), - FRAME_X_WINDOW (f), - &mask, 1); #ifndef HAVE_XINPUT2_1 FRAME_X_OUTPUT (f)->xi_masks = selected; diff --git a/src/xterm.c b/src/xterm.c index ee0035234b5..7487450d649 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -27634,6 +27634,33 @@ my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, connection established. */ static unsigned x_display_id; +#if defined HAVE_XINPUT2 && !defined HAVE_GTK3 + +/* Select for device change events on the root window of DPYINFO. + These include device change and hierarchy change notifications. */ + +static void +xi_select_hierarchy_events (struct x_display_info *dpyinfo) +{ + XIEventMask mask; + ptrdiff_t l; + unsigned char *m; + + l = XIMaskLen (XI_LASTEVENT); + mask.mask = m = alloca (l); + memset (m, 0, l); + mask.mask_len = l; + + XISetMask (m, XI_PropertyEvent); + XISetMask (m, XI_HierarchyChanged); + XISetMask (m, XI_DeviceChanged); + + XISelectEvents (dpyinfo->display, dpyinfo->root_window, + &mask, 1); +} + +#endif + /* Open a connection to X display DISPLAY_NAME, and return the structure that describes the open display. If we cannot contact the display, return null. */ @@ -28263,6 +28290,12 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) if (rc == Success) { dpyinfo->supports_xi2 = true; +#ifndef HAVE_GTK3 + /* Select for hierarchy events on the root window. GTK 3.x + does this itself. */ + xi_select_hierarchy_events (dpyinfo); +#endif + x_cache_xi_devices (dpyinfo); } } |