summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2021-02-08 09:54:43 +0100
committerOlivier Fourdan <ofourdan@redhat.com>2021-02-23 13:24:46 +0100
commit2d34ee088adc5d9d816616783eec92c52d1758c9 (patch)
treecc6b73ad36d9601cc4f9e9680af652f8fbea1a21
parentcb7ac99fe51a5d3f3e09ee0667f45be3995e9359 (diff)
downloadmutter-2d34ee088adc5d9d816616783eec92c52d1758c9.tar.gz
core: Account for the globally active input case
Commit afa43154 tried to make sure the focus was properly changed when calling focus_default_window() by checking the focused window just after trying to set the focus. However, the X11 “Inter-Client Communication Conventions Manual” version 2.0 (ICCCM 2 for short) states that some X11 client may want to use a so called “globally active input” model in which case the client expects keyboard input and set input focus even when it's not one of its own window. To comply with this, when dealing with such clients, mutter will not change the focus and send a WM_TAKE_FOCUS message instead. That mechanism will defeat the logic introduced by commit afa43154 because the focused window is not changed in this case. As a result, the input focus will fallback to the no-focus window. To avoid this, only check that the focus change occurred for windows using a synchronous focus model. v2: Split specific test for "globally active input" model (Florian). v3: Remove the check for window->unmanaging which is useless (Jonas). Fixes: afa43154 - "core: Make sure focus_default_window() worked" Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/1620 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1716> (cherry picked from commit 2432508db78a235abc5cee198fb94043625db65f)
-rw-r--r--src/core/workspace.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/workspace.c b/src/core/workspace.c
index a80560b7b..a6edb5fff 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -1367,6 +1367,14 @@ try_to_set_focus_and_check (MetaWindow *window,
{
meta_window_focus (window, timestamp);
+ /* meta_focus_window() will not change focus for clients using the
+ * "globally active input" model of input handling, hence defeating
+ * the assumption that focus should be changed for such windows.
+ * See https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.7
+ */
+ if (meta_window_is_focus_async (window))
+ return TRUE;
+
/* meta_window_focus() does not guarantee that focus will end up
* where we expect, it can fail for various reasons, better check
* it did not actually changed or even left focus to the window we