[metacity] window-props: re-add support for _NET_WM_PID



commit f46db3ec524d8880f64c847984f3a18e394bac2a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Sep 30 16:55:46 2022 +0300

    window-props: re-add support for _NET_WM_PID
    
    We will use _NET_WM_PID when xserver does not have XRes extension
    or its version is too old.
    
    This partially reverts 9135966673e9fd430b9e8252abdb9c946295e25b.

 src/core/window-private.h |  1 +
 src/core/window-props.c   | 28 ++++++++++++++++++++++++++++
 src/core/window.c         |  1 +
 3 files changed, 30 insertions(+)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 67ade36a..ff1a606c 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -131,6 +131,7 @@ struct _MetaWindow
   char *startup_id;
   char *gtk_theme_variant;
 
+  int net_wm_pid;
   pid_t client_pid;
 
   Window xtransient_for;
diff --git a/src/core/window-props.c b/src/core/window-props.c
index 23b10e29..0b42e569 100644
--- a/src/core/window-props.c
+++ b/src/core/window-props.c
@@ -388,6 +388,28 @@ reload_wm_window_role (MetaWindow    *window,
     window->role = g_strdup (value->v.str);
 }
 
+static void
+reload_net_wm_pid (MetaWindow    *window,
+                   MetaPropValue *value,
+                   gboolean       initial)
+{
+  if (value->type != META_PROP_VALUE_INVALID)
+    {
+      gulong cardinal = (int) value->v.cardinal;
+
+      if (cardinal <= 0)
+        {
+          g_warning ("Application set a bogus _NET_WM_PID %lu", cardinal);
+        }
+      else
+        {
+          window->net_wm_pid = cardinal;
+          meta_verbose ("Window has _NET_WM_PID %d\n",
+                        window->net_wm_pid);
+        }
+    }
+}
+
 static void
 reload_net_wm_user_time (MetaWindow    *window,
                          MetaPropValue *value,
@@ -1781,6 +1803,12 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
       reload_wm_class,
       LOAD_INIT | INCLUDE_OR
     },
+    {
+      display->atom__NET_WM_PID,
+      META_PROP_VALUE_CARDINAL,
+      reload_net_wm_pid,
+      LOAD_INIT | INCLUDE_OR
+    },
     {
       XA_WM_NAME,
       META_PROP_VALUE_TEXT_PROPERTY,
diff --git a/src/core/window.c b/src/core/window.c
index 7933a0f9..1512a18e 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -567,6 +567,7 @@ meta_window_new (MetaDisplay    *display,
   window->startup_id = NULL;
   window->gtk_theme_variant = NULL;
 
+  window->net_wm_pid = -1;
   window->client_pid = -1;
 
   window->xtransient_for = None;


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