1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00

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.
This commit is contained in:
Po Lu 2022-08-16 21:11:03 +08:00
parent 81ff64d3ca
commit b4879603fd
2 changed files with 39 additions and 8 deletions

View file

@ -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;

View file

@ -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);
}
}