From 3d11fd8cc0a3d64071ac1cdec34aabd795fe6a5d Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Sun, 18 Sep 2022 15:43:06 -0400 Subject: [PATCH] Remove mapping of workspace contexts to pid namespaces. This is handled in gnome shell now. --- src/core/meta-workspace-manager-private.h | 11 ---- src/core/meta-workspace-manager.c | 65 ++--------------------- src/core/util-private.h | 2 - src/core/util.c | 50 +---------------- src/core/window-private.h | 3 -- src/core/window.c | 31 +---------- src/meta/meta-workspace-manager.h | 12 +++-- src/meta/window.h | 6 --- 8 files changed, 14 insertions(+), 166 deletions(-) diff --git a/src/core/meta-workspace-manager-private.h b/src/core/meta-workspace-manager-private.h index 4b5d4f4e3..d123761ed 100644 --- a/src/core/meta-workspace-manager-private.h +++ b/src/core/meta-workspace-manager-private.h @@ -53,9 +53,6 @@ struct _MetaWorkspaceContext // The rule above about not writing if context is currently active also applies to this field. MetaWorkspace *active_workspace; - // PID namespace - gchar *namespace; - // A unique ID value for this context. guint id; }; @@ -73,8 +70,6 @@ struct _MetaWorkspaceManager // List of WorkspaceContext GList *context_list; - gchar *mutter_namespace; - // Current active WorkspaceContext. MetaWorkspaceManager state (workspaces, active_workspace) // will be saved here when a new WorkspaceContext is made active. MetaWorkspaceContext *active_context; @@ -136,8 +131,6 @@ void meta_workspace_manager_update_num_workspaces (MetaWorkspaceManager *workspa guint32 timestamp, int new_num); -MetaWorkspaceContext *meta_workspace_context_new (MetaWorkspaceManager *manager, const char *namespace); - void meta_workspace_context_make_active (MetaWorkspaceContext *context); MetaWorkspaceContext *meta_workspace_manager_lookup_context (MetaWorkspaceManager *workspace_manager, @@ -158,8 +151,4 @@ int meta_workspace_manager_get_workspace_id (MetaWorkspaceManager *workspace_man MetaWorkspace * meta_workspace_manager_lookup_workspace_by_id (MetaWorkspaceManager *workspace_manager, int workspace_id); -gboolean -meta_workspace_manager_is_window_on_foreign_context (MetaWorkspaceManager *workspace_manager, MetaWindow *window); - - #endif /* META_WORKSPACE_MANAGER_PRIVATE_H */ diff --git a/src/core/meta-workspace-manager.c b/src/core/meta-workspace-manager.c index 393ddf668..fd0e7b775 100644 --- a/src/core/meta-workspace-manager.c +++ b/src/core/meta-workspace-manager.c @@ -267,9 +267,8 @@ meta_workspace_manager_new (MetaDisplay *display) workspace_manager->context_list = NULL; workspace_manager->active_context = NULL; workspace_manager->next_context_id = 1; - workspace_manager->mutter_namespace = meta_read_pid_namespace (getpid()); - MetaWorkspaceContext *context = meta_workspace_context_new (workspace_manager, NULL); + MetaWorkspaceContext *context = meta_workspace_context_new (workspace_manager); workspace_manager->workspaces = g_steal_pointer (&context->workspaces); workspace_manager->active_workspace = g_steal_pointer (&context->active_workspace); @@ -1170,20 +1169,11 @@ meta_workspace_manager_lookup_context (MetaWorkspaceManager *workspace_manager, return NULL; } -const char * -meta_workspace_manager_mutter_namespace (MetaWorkspaceManager *workspace_manager) -{ - if (!workspace_manager->mutter_namespace) { - workspace_manager->mutter_namespace = meta_read_pid_namespace (getpid()); - } - return workspace_manager->mutter_namespace; -} - /* * Return pointer to the live workspace list depending on whether or not the context is currently active. * While a workspace context is active, the list must be accessed through the pointer workspace_manager->workspaces */ -GList ** +static GList ** meta_workspace_manager_workspace_list_for_context (MetaWorkspaceManager *workspace_manager, guint context_id) { if (workspace_manager->active_context && workspace_manager->active_context->id == context_id) { @@ -1276,36 +1266,10 @@ meta_workspace_manager_lookup_workspace_by_id (MetaWorkspaceManager *workspace_m return NULL; } -/** - * meta_workspace_manager_context_for_namespace: - * @workspace_manager: a #MetaWorkspaceManager - * @namespace: namespace of context - * - * Find an existing WorkspaceContext for the specified namespace. If no WorkspaceContext - * currently exists for namespace create a new one. - * - * Return value: (transfer none): the workspace context for the specified namespace - */ MetaWorkspaceContext * -meta_workspace_manager_context_for_namespace (MetaWorkspaceManager *workspace_manager, const gchar *namespace) +meta_workspace_manager_active_context (MetaWorkspaceManager * workspace_manager) { - MetaWorkspaceContext *anonymous_context = NULL; - - for (GList *iter = workspace_manager->context_list; iter; iter = iter->next) { - MetaWorkspaceContext *context = iter->data; - if (context->namespace == NULL && anonymous_context == NULL) { - anonymous_context = context; - } else if (!g_strcmp0 (context->namespace, namespace )) { - return context; - } - } - - if (anonymous_context) { - anonymous_context->namespace = g_strdup (namespace); - return anonymous_context; - } - - return meta_workspace_context_new (workspace_manager, namespace); + return workspace_manager->active_context; } guint @@ -1344,7 +1308,6 @@ meta_workspace_context_remove (MetaWorkspaceContext *context) g_signal_emit (context->manager, workspace_manager_signals[CONTEXT_REMOVED], 0, context->id); - g_clear_pointer (&context->namespace, g_free); context->manager->context_list = g_list_remove (context->manager->context_list, context); g_object_unref (context); } @@ -1360,7 +1323,7 @@ meta_workspace_context_init (MetaWorkspaceContext *context) } MetaWorkspaceContext * -meta_workspace_context_new (MetaWorkspaceManager *manager, const char *namespace) +meta_workspace_context_new (MetaWorkspaceManager *manager) { guint context_id = manager->next_context_id++; @@ -1369,13 +1332,8 @@ meta_workspace_context_new (MetaWorkspaceManager *manager, const char *namespace context->manager = manager; context->workspaces = NULL; context->active_workspace = NULL; - context->namespace = NULL; context->id = context_id; - if (namespace) { - context->namespace = g_strdup (namespace); - } - manager->context_list = g_list_append (manager->context_list, context); context->active_workspace = meta_workspace_new_with_context_id (manager, context_id); @@ -1483,16 +1441,3 @@ meta_workspace_context_activate (MetaWorkspaceContext *context) /* Will set manager->active_workspace from context->active_workspace */ meta_workspace_activate ( g_steal_pointer (&context->active_workspace), timestamp); } - -gboolean -meta_workspace_manager_is_window_on_foreign_context (MetaWorkspaceManager *workspace_manager, MetaWindow *window) -{ - const char *ns = meta_window_namespace (window); - - if (!ns || !g_strcmp0 (ns, workspace_manager->mutter_namespace) || !window->workspace) { - return FALSE; - } - - MetaWorkspaceContext *context = meta_workspace_manager_context_for_namespace (workspace_manager, ns); - return context->id != window->workspace->context_id; -} diff --git a/src/core/util-private.h b/src/core/util-private.h index 1c52fbc86..ff9d7ce42 100644 --- a/src/core/util-private.h +++ b/src/core/util-private.h @@ -54,6 +54,4 @@ void meta_init_debug_utils (void); (ycoord) >= (rect).y && \ (ycoord) < ((rect).y + (rect).height)) -char * meta_read_pid_namespace (pid_t pid); - #endif diff --git a/src/core/util.c b/src/core/util.c index 17bb7ccca..cdb6253c8 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -729,52 +729,4 @@ MetaDebugPaintFlag meta_get_debug_paint_flags (void) { return debug_paint_flags; -} - -static GFileInfo * -pid_namespace_file_info (pid_t pid) -{ - char *filename = g_strdup_printf("/proc/%u/ns/pid", pid); - GFile *file = g_file_new_for_path(filename); - g_free(filename); - - GError *error = NULL; - - GFileInfo *info = g_file_query_info(file, - G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK "," G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, - NULL, - &error); - - g_object_unref(file); - - if (info == NULL) { - g_warning("MetaWindow: Error attempting to read /proc/%u/ns/pid symlink: %s", pid, error->message); - g_error_free (error); - return NULL; - } - - if (!g_file_info_get_is_symlink (info)) { - g_warning("MetaWindow: /proc/%u/ns/pid exists but is not a symlink?", pid); - g_object_unref (info); - return NULL; - } - - return info; - -} - -char * -meta_read_pid_namespace (pid_t pid) -{ - char *value = NULL; - GFileInfo *info = pid_namespace_file_info (pid); - const char *target = g_file_info_get_symlink_target (info); - - if (target) { - value = g_strdup (target); - } - g_object_unref (info); - - return value; -} +} \ No newline at end of file diff --git a/src/core/window-private.h b/src/core/window-private.h index 7e6a02505..8d2d4a020 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -561,9 +561,6 @@ struct _MetaWindow gboolean has_valid_cgroup; GFile *cgroup_path; - guint namespace_set: 1; - gchar *namespace; - unsigned int events_during_ping; }; diff --git a/src/core/window.c b/src/core/window.c index bcfc1ea17..e3b3169fd 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -327,7 +327,6 @@ meta_window_finalize (GObject *object) g_free (window->gtk_app_menu_object_path); g_free (window->gtk_menubar_object_path); g_free (window->placement.rule); - g_free (window->namespace); G_OBJECT_CLASS (meta_window_parent_class)->finalize (object); } @@ -8605,32 +8604,4 @@ meta_window_calculate_bounds (MetaWindow *window, { return FALSE; } -} - -/** - * meta_window_namespace: - * @window: a #MetaWindow - * - * Returns string identifying PID namespace this window belongs to - * if known - * - * Return value: (transfer none): the pid namespace string, or %NULL - */ -const char * -meta_window_namespace (MetaWindow *window) -{ - if (!window->namespace_set) { - window->namespace_set = TRUE; - pid_t pid = meta_window_get_pid (window); - if (pid) { - window->namespace = meta_read_pid_namespace (pid); - } - } - return window->namespace; -} - -gboolean -meta_window_is_on_foreign_workspace_context (MetaWindow *window) -{ - return meta_workspace_manager_is_window_on_foreign_context (window->display->workspace_manager, window); -} +} \ No newline at end of file diff --git a/src/meta/meta-workspace-manager.h b/src/meta/meta-workspace-manager.h index d00948da7..a3d4bc1d0 100644 --- a/src/meta/meta-workspace-manager.h +++ b/src/meta/meta-workspace-manager.h @@ -86,6 +86,11 @@ void meta_workspace_manager_override_workspace_layout (MetaWorkspaceManager *wor gboolean vertical_layout, int n_rows, int n_columns); + +META_EXPORT +MetaWorkspaceContext * +meta_workspace_manager_active_context (MetaWorkspaceManager *workspace_manager); + META_EXPORT guint meta_workspace_manager_active_context_id (MetaWorkspaceManager *workspace_manager); @@ -94,11 +99,8 @@ void meta_workspace_manager_set_builtin_struts_all(MetaWorkspaceManager *workspa GSList *struts); META_EXPORT -MetaWorkspaceContext *meta_workspace_manager_context_for_namespace (MetaWorkspaceManager *workspace_manager, - const gchar *namespace); - -META_EXPORT -const char *meta_workspace_manager_mutter_namespace (MetaWorkspaceManager *workspace_manager); +MetaWorkspaceContext * +meta_workspace_context_new (MetaWorkspaceManager *manager); META_EXPORT void meta_workspace_context_activate (MetaWorkspaceContext *context); diff --git a/src/meta/window.h b/src/meta/window.h index 87dd1655e..d5d07a061 100644 --- a/src/meta/window.h +++ b/src/meta/window.h @@ -453,10 +453,4 @@ uint64_t meta_window_get_id (MetaWindow *window); META_EXPORT MetaWindowClientType meta_window_get_client_type (MetaWindow *window); -META_EXPORT -const char *meta_window_namespace (MetaWindow *window); - -META_EXPORT -gboolean meta_window_is_on_foreign_workspace_context (MetaWindow *window); - #endif