[mutter] xwayland: Match applications without WM_CLASS nor WM_NAME



commit 8bf399ff0c056e6421631fedcc20d123d6bf4109
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Wed May 13 16:40:47 2020 +0200

    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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1254>

 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 4cb8c58a8f..66c80d8091 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;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]