diff --git a/src/core/meta-workspace-manager-private.h b/src/core/meta-workspace-manager-private.h index 18240f1d1..6bcd02e33 100644 --- a/src/core/meta-workspace-manager-private.h +++ b/src/core/meta-workspace-manager-private.h @@ -52,9 +52,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; }; @@ -72,8 +69,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; @@ -135,8 +130,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, @@ -157,6 +150,3 @@ 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); - diff --git a/src/core/meta-workspace-manager.c b/src/core/meta-workspace-manager.c index fbba796bb..777ae18b9 100644 --- a/src/core/meta-workspace-manager.c +++ b/src/core/meta-workspace-manager.c @@ -248,9 +248,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); @@ -1141,20 +1140,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) { @@ -1247,36 +1237,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 @@ -1315,7 +1279,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); } @@ -1331,7 +1294,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++; @@ -1340,13 +1303,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); @@ -1454,16 +1412,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 5621fb62a..1d2638cc2 100644 --- a/src/core/util-private.h +++ b/src/core/util-private.h @@ -55,6 +55,3 @@ meta_timeval_to_microseconds (const struct timeval *tv) #define META_CONTAINER_OF(ptr, type, member) \ (type *) ((uint8_t *) (ptr) - G_STRUCT_OFFSET (type, member)) - -char * meta_read_pid_namespace (pid_t pid); - diff --git a/src/core/util.c b/src/core/util.c index 47e21fdbb..05a0dea39 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -598,50 +598,3 @@ meta_log (const char *format, ...) g_logv (G_LOG_DOMAIN, mutter_log_level, format, args); va_end (args); } - -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; -} diff --git a/src/core/window-private.h b/src/core/window-private.h index 28b1115a7..3c6d94ef3 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -558,10 +558,6 @@ struct _MetaWindow guint is_alive : 1; guint in_workspace_change : 1; - - guint namespace_set: 1; - gchar *namespace; - }; struct _MetaWindowClass diff --git a/src/core/window.c b/src/core/window.c index eff79fb9d..43d3fe2e8 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -336,7 +336,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); } @@ -7764,32 +7763,3 @@ meta_get_window_suspend_timeout_s (void) { return SUSPEND_HIDDEN_TIMEOUT_S; } - -/** - * 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); -} - diff --git a/src/meta/meta-workspace-manager.h b/src/meta/meta-workspace-manager.h index f3927d143..df5116b3c 100644 --- a/src/meta/meta-workspace-manager.h +++ b/src/meta/meta-workspace-manager.h @@ -86,6 +86,13 @@ void meta_workspace_manager_override_workspace_layout (MetaWorkspaceManager *wor 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); + META_EXPORT int meta_workspace_manager_get_layout_columns (MetaWorkspaceManager *workspace_manager); @@ -96,11 +103,8 @@ META_EXPORT guint meta_workspace_manager_active_context_id (MetaWorkspaceManager *workspace_manager); 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 a8380ed0d..d6f7e0e31 100644 --- a/src/meta/window.h +++ b/src/meta/window.h @@ -440,10 +440,3 @@ MetaWindowClientType meta_window_get_client_type (MetaWindow *window); META_EXPORT gboolean meta_window_has_pointer (MetaWindow *window); - -META_EXPORT -const char *meta_window_namespace (MetaWindow *window); - -META_EXPORT -gboolean meta_window_is_on_foreign_workspace_context (MetaWindow *window); -