From 8bf399ff0c056e6421631fedcc20d123d6bf4109 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 13 May 2020 16:40:47 +0200 Subject: [PATCH] xwayland: Match applications without WM_CLASS nor WM_NAME For X11 grabs, the pattern matching mechanism would simply ignore applications which have neither WM_CLASS nor WM_NAME set. When dealing with an override redirect window however, it is not uncommon that these window have neither value set as these window are supposed to be ignored by the window manager. When the WM_CLASS or the WM_NAME is not set by the client, assume the value is empty so the pattern matching can allow for these. https://gitlab.gnome.org/GNOME/mutter/-/issues/1249 Part-of: --- src/wayland/meta-xwayland-grab-keyboard.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/wayland/meta-xwayland-grab-keyboard.c b/src/wayland/meta-xwayland-grab-keyboard.c index 4cb8c58a8..66c80d809 100644 --- a/src/wayland/meta-xwayland-grab-keyboard.c +++ b/src/wayland/meta-xwayland-grab-keyboard.c @@ -164,14 +164,26 @@ static gboolean application_is_in_pattern_array (MetaWindow *window, GPtrArray *pattern_array) { + const char *class; + const char *name; guint i; + if (window->res_class) + class = window->res_class; + else + class = ""; + + if (window->res_name) + name = window->res_name; + else + name = ""; + for (i = 0; pattern_array && i < pattern_array->len; i++) { GPatternSpec *pattern = (GPatternSpec *) g_ptr_array_index (pattern_array, i); - if ((window->res_class && g_pattern_match_string (pattern, window->res_class)) || - (window->res_name && g_pattern_match_string (pattern, window->res_name))) + if (g_pattern_match_string (pattern, class) || + g_pattern_match_string (pattern, name)) return TRUE; }