From: Po Lu Date: Wed, 24 Aug 2022 11:10:44 +0000 (+0800) Subject: Fix input extension focus tracking with some window managers X-Git-Tag: emacs-29.0.90~1893^2~63 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e518146a3017669981b6d31c356d0bb105200928;p=emacs.git Fix input extension focus tracking with some window managers * src/xterm.c (handle_one_xevent): If a window manager sends us FocusIn and FocusOut with XSendEvent (they do that), don't detect focus changes when XInput 2 is enabled. The X server will tell us the actual truth if the focus really did change. --- diff --git a/src/xterm.c b/src/xterm.c index 3dfa908f1e2..0684402b147 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -19254,6 +19254,21 @@ handle_one_xevent (struct x_display_info *dpyinfo, goto OTHER; case FocusIn: +#if defined HAVE_XINPUT2 \ + && (defined HAVE_GTK3 || (!defined USE_GTK && !defined USE_X_TOOLKIT)) + /* If a FocusIn event is received (because the window manager + sent us one), don't set the core focus if XInput 2 is + enabled, since that would mess up the device-specific focus + tracking. + + The long looking preprocessor conditional only enables this + code on GTK 3 and no toolkit builds, since those are the only + builds where focus is tracked specific to each master device. + Other builds use core events and the client pointer to handle + focus, much like on a build without XInput 2. */ + if (dpyinfo->supports_xi2) + goto OTHER; +#endif #ifdef USE_GTK /* Some WMs (e.g. Mutter in Gnome Shell), don't unmap minimized/iconified windows; thus, for those WMs we won't get @@ -19367,6 +19382,21 @@ handle_one_xevent (struct x_display_info *dpyinfo, goto OTHER; case FocusOut: +#if defined HAVE_XINPUT2 \ + && (defined HAVE_GTK3 || (!defined USE_GTK && !defined USE_X_TOOLKIT)) + /* If a FocusIn event is received (because the window manager + sent us one), don't set the core focus if XInput 2 is + enabled, since that would mess up the device-specific focus + tracking. + + The long looking preprocessor conditional only enables this + code on GTK 3 and no toolkit builds, since those are the only + builds where focus is tracked specific to each master device. + Other builds use core events and the client pointer to handle + focus, much like on a build without XInput 2. */ + if (dpyinfo->supports_xi2) + goto OTHER; +#endif x_detect_focus_change (dpyinfo, any, event, &inev.ie); goto OTHER;