[mutter] window-x11: Refactor meta_prop_get_latin1_string() calls



commit fa461525ee1f6dfb9b2c5dea50b084fca955472a
Author: Hans de Goede <hdegoede redhat com>
Date:   Tue Sep 10 12:24:49 2019 +0100

    window-x11: Refactor meta_prop_get_latin1_string() calls
    
    Instead of storing the result of meta_prop_get_latin1_string() into
    a temporary string value, g_strdup-ing that temp value storing the
    g_strdup result into window->sm_client_id and then g_free-ing the
    temporary string, we can pass window->sm_client_id as the place where
    meta_prop_get_latin1_string() stores its result, since the result
    from meta_prop_get_latin1_string() is itself a g_strdup-ed string,
    so there is no need to g_strdup it again.
    
    Note this drops the check to only issue the
    "Window %s sets SM_CLIENT_ID on itself ..." warning once. This check is
    not necessary as update_sm_hints() is only called once at window
    creation time and is never called again.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/786

 src/x11/window-x11.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)
---
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 6e502fd5d..31635a2f5 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -171,17 +171,11 @@ update_sm_hints (MetaWindow *window)
 
   if (leader != None)
     {
-      char *str;
-
       window->xclient_leader = leader;
 
-      if (meta_prop_get_latin1_string (window->display->x11_display, leader,
-                                       window->display->x11_display->atom_SM_CLIENT_ID,
-                                       &str))
-        {
-          window->sm_client_id = g_strdup (str);
-          g_free (str);
-        }
+      meta_prop_get_latin1_string (window->display->x11_display, leader,
+                                   window->display->x11_display->atom_SM_CLIENT_ID,
+                                   &window->sm_client_id);
     }
   else
     {
@@ -192,20 +186,13 @@ update_sm_hints (MetaWindow *window)
           /* Some broken apps (kdelibs fault?) set SM_CLIENT_ID on the app
            * instead of the client leader
            */
-          char *str;
-
-          str = NULL;
-          if (meta_prop_get_latin1_string (window->display->x11_display, window->xwindow,
-                                           window->display->x11_display->atom_SM_CLIENT_ID,
-                                           &str))
-            {
-              if (window->sm_client_id == NULL) /* first time through */
-                meta_warning ("Window %s sets SM_CLIENT_ID on itself, instead of on the WM_CLIENT_LEADER 
window as specified in the ICCCM.\n",
-                              window->desc);
+          meta_prop_get_latin1_string (window->display->x11_display, window->xwindow,
+                                       window->display->x11_display->atom_SM_CLIENT_ID,
+                                       &window->sm_client_id);
 
-              window->sm_client_id = g_strdup (str);
-              g_free (str);
-            }
+          if (window->sm_client_id)
+            meta_warning ("Window %s sets SM_CLIENT_ID on itself, instead of on the WM_CLIENT_LEADER window 
as specified in the ICCCM.\n",
+                          window->desc);
         }
     }
 


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