From 09fc3e966a294ea79b95c897df5169f8903fd4b0 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 14 Feb 2024 14:45:01 +0100 Subject: [PATCH] window: Move wm_client_machine to WindowX11 Also removes the public getter as nothing uses it and it no longer make sense to expose X11-ism as API Part-of: --- src/core/window-private.h | 1 - src/core/window.c | 21 --------------------- src/meta/window.h | 3 --- src/x11/window-props.c | 18 +++++++++++------- src/x11/window-x11-private.h | 1 + src/x11/window-x11.c | 1 + 6 files changed, 13 insertions(+), 32 deletions(-) diff --git a/src/core/window-private.h b/src/core/window-private.h index 8583eefca..582548c70 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -189,7 +189,6 @@ struct _MetaWindow char *res_class; char *res_name; char *role; - char *wm_client_machine; char *startup_id; char *mutter_hints; diff --git a/src/core/window.c b/src/core/window.c index be5f45859..1e457a691 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -324,7 +324,6 @@ meta_window_finalize (GObject *object) if (window->cgroup_path) g_object_unref (window->cgroup_path); - g_free (window->wm_client_machine); g_free (window->startup_id); g_free (window->role); g_free (window->res_class); @@ -1097,7 +1096,6 @@ meta_window_constructed (GObject *object) window->res_class = NULL; window->res_name = NULL; window->role = NULL; - window->wm_client_machine = NULL; window->is_remote = FALSE; window->startup_id = NULL; @@ -6815,25 +6813,6 @@ meta_window_unit_cgroup_equal (MetaWindow *window1, return g_file_equal (window1_file, window2_file); } -/** - * meta_window_get_client_machine: - * @window: a #MetaWindow - * - * Returns name of the client machine from which this windows was created, - * if known (obtained from the WM_CLIENT_MACHINE property). - * - * Returns: (transfer none) (nullable): the machine name, or %NULL; the string - * is owned by the window manager and should not be freed or modified by the - * caller. - */ -const char * -meta_window_get_client_machine (MetaWindow *window) -{ - g_return_val_if_fail (META_IS_WINDOW (window), NULL); - - return window->wm_client_machine; -} - /** * meta_window_is_remote: * @window: a #MetaWindow diff --git a/src/meta/window.h b/src/meta/window.h index 08980ef20..f4aa91f2b 100644 --- a/src/meta/window.h +++ b/src/meta/window.h @@ -332,9 +332,6 @@ guint32 meta_window_get_user_time (MetaWindow *window); META_EXPORT pid_t meta_window_get_pid (MetaWindow *window); -META_EXPORT -const char *meta_window_get_client_machine (MetaWindow *window); - META_EXPORT gboolean meta_window_is_remote (MetaWindow *window); diff --git a/src/x11/window-props.c b/src/x11/window-props.c index 96bf35d58..500a19109 100644 --- a/src/x11/window-props.c +++ b/src/x11/window-props.c @@ -211,16 +211,18 @@ reload_wm_client_machine (MetaWindow *window, MetaPropValue *value, gboolean initial) { - g_free (window->wm_client_machine); - window->wm_client_machine = NULL; + MetaWindowX11Private *priv = + meta_window_x11_get_private (META_WINDOW_X11 (window)); + + g_clear_pointer (&priv->wm_client_machine, g_free); if (value->type != META_PROP_VALUE_INVALID) - window->wm_client_machine = g_strdup (value->v.str); + priv->wm_client_machine = g_strdup (value->v.str); meta_verbose ("Window has client machine \"%s\"", - window->wm_client_machine ? window->wm_client_machine : "unset"); + priv->wm_client_machine ? priv->wm_client_machine : "unset"); - if (window->wm_client_machine == NULL) + if (priv->wm_client_machine == NULL) { window->is_remote = FALSE; } @@ -230,7 +232,7 @@ reload_wm_client_machine (MetaWindow *window, gethostname (hostname, HOST_NAME_MAX + 1); - window->is_remote = g_strcmp0 (window->wm_client_machine, hostname) != 0; + window->is_remote = g_strcmp0 (priv->wm_client_machine, hostname) != 0; } } @@ -503,6 +505,8 @@ set_title_text (MetaWindow *window, Atom atom, char **target) { + MetaWindowX11Private *priv = + meta_window_x11_get_private (META_WINDOW_X11 (window)); gboolean modified = FALSE; if (!target) @@ -522,7 +526,7 @@ set_title_text (MetaWindow *window, else if (meta_window_is_remote (window)) { *target = g_strdup_printf (_("%s (on %s)"), - title, window->wm_client_machine); + title, priv->wm_client_machine); modified = TRUE; } else diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 993a90465..7912d3ddb 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -96,6 +96,7 @@ struct _MetaWindowX11Private gboolean keys_grabbed; /* normal keybindings grabbed */ gboolean grab_on_frame; /* grabs are on the frame */ + char *wm_client_machine; char *sm_client_id; }; diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 0cdc032b2..35c9f172f 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -2149,6 +2149,7 @@ meta_window_x11_finalize (GObject *object) MetaWindowX11 *win = META_WINDOW_X11 (object); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (win); + g_clear_pointer (&priv->wm_client_machine, g_free); g_clear_pointer (&priv->sm_client_id, g_free); G_OBJECT_CLASS (meta_window_x11_parent_class)->finalize (object);