Move raw event selection on GTK+ 2 to a more appropriate place

* src/xfns.c (setup_xi_event_mask): Stop selecting for
RawKeyPress on the root window.
* src/xterm.c (x_new_focus_frame): Select here instead, once a
frame becomes focused.
This commit is contained in:
Po Lu 2022-04-13 19:13:38 +08:00
parent 8259e36800
commit ed6237e039
2 changed files with 25 additions and 9 deletions

View file

@ -3688,15 +3688,6 @@ setup_xi_event_mask (struct frame *f)
XISelectEvents (FRAME_X_DISPLAY (f),
FRAME_X_WINDOW (f),
&mask, 1);
#if defined USE_GTK && !defined HAVE_GTK3
memset (m, 0, l);
XISetMask (m, XI_RawKeyPress);
XISelectEvents (FRAME_X_DISPLAY (f),
FRAME_DISPLAY_INFO (f)->root_window,
&mask, 1);
#endif
unblock_input ();
}
#endif

View file

@ -9067,6 +9067,20 @@ static void
x_new_focus_frame (struct x_display_info *dpyinfo, struct frame *frame)
{
struct frame *old_focus = dpyinfo->x_focus_frame;
#if defined USE_GTK && !defined HAVE_GTK3 && defined HAVE_XINPUT2
XIEventMask mask;
ptrdiff_t l;
if (dpyinfo->supports_xi2)
{
l = XIMaskLen (XI_LASTEVENT);
mask.mask = alloca (l);
mask.mask_len = l;
memset (mask.mask, 0, l);
mask.deviceid = XIAllDevices;
}
#endif
if (frame != dpyinfo->x_focus_frame)
{
@ -9074,6 +9088,17 @@ x_new_focus_frame (struct x_display_info *dpyinfo, struct frame *frame)
the correct value of x_focus_frame. */
dpyinfo->x_focus_frame = frame;
/* Once none of our frames are focused anymore, stop selecting
for raw input events from the root window. */
#if defined USE_GTK && !defined HAVE_GTK3 && defined HAVE_XINPUT2
if (frame && dpyinfo->supports_xi2)
XISetMask (mask.mask, XI_RawKeyPress);
if (dpyinfo->supports_xi2)
XISelectEvents (dpyinfo->display, dpyinfo->root_window, &mask, 1);
#endif
if (old_focus && old_focus->auto_lower)
x_lower_frame (old_focus);