From: Po Lu Date: Wed, 13 Apr 2022 11:13:38 +0000 (+0800) Subject: Move raw event selection on GTK+ 2 to a more appropriate place X-Git-Tag: emacs-29.0.90~1931^2~607 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ed6237e039e6fb51229054d0fce74df074903f19;p=emacs.git 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. --- diff --git a/src/xfns.c b/src/xfns.c index 2f90534c484..5cf3eb41996 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -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 diff --git a/src/xterm.c b/src/xterm.c index 0c1c70340de..86db1a5c5f8 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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);