mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
Remove mapping of workspace contexts to pid namespaces.
This is handled in gnome shell now.
This commit is contained in:
parent
ff2817bb2f
commit
901190c5a5
@ -53,9 +53,6 @@ struct _MetaWorkspaceContext
|
|||||||
// The rule above about not writing if context is currently active also applies to this field.
|
// The rule above about not writing if context is currently active also applies to this field.
|
||||||
MetaWorkspace *active_workspace;
|
MetaWorkspace *active_workspace;
|
||||||
|
|
||||||
// PID namespace
|
|
||||||
gchar *namespace;
|
|
||||||
|
|
||||||
// A unique ID value for this context.
|
// A unique ID value for this context.
|
||||||
guint id;
|
guint id;
|
||||||
};
|
};
|
||||||
@ -73,8 +70,6 @@ struct _MetaWorkspaceManager
|
|||||||
// List of WorkspaceContext
|
// List of WorkspaceContext
|
||||||
GList *context_list;
|
GList *context_list;
|
||||||
|
|
||||||
gchar *mutter_namespace;
|
|
||||||
|
|
||||||
// Current active WorkspaceContext. MetaWorkspaceManager state (workspaces, active_workspace)
|
// Current active WorkspaceContext. MetaWorkspaceManager state (workspaces, active_workspace)
|
||||||
// will be saved here when a new WorkspaceContext is made active.
|
// will be saved here when a new WorkspaceContext is made active.
|
||||||
MetaWorkspaceContext *active_context;
|
MetaWorkspaceContext *active_context;
|
||||||
@ -136,8 +131,6 @@ void meta_workspace_manager_update_num_workspaces (MetaWorkspaceManager *workspa
|
|||||||
guint32 timestamp,
|
guint32 timestamp,
|
||||||
int new_num);
|
int new_num);
|
||||||
|
|
||||||
MetaWorkspaceContext *meta_workspace_context_new (MetaWorkspaceManager *manager, const char *namespace);
|
|
||||||
|
|
||||||
void meta_workspace_context_make_active (MetaWorkspaceContext *context);
|
void meta_workspace_context_make_active (MetaWorkspaceContext *context);
|
||||||
|
|
||||||
MetaWorkspaceContext *meta_workspace_manager_lookup_context (MetaWorkspaceManager *workspace_manager,
|
MetaWorkspaceContext *meta_workspace_manager_lookup_context (MetaWorkspaceManager *workspace_manager,
|
||||||
@ -158,8 +151,4 @@ int meta_workspace_manager_get_workspace_id (MetaWorkspaceManager *workspace_man
|
|||||||
MetaWorkspace *
|
MetaWorkspace *
|
||||||
meta_workspace_manager_lookup_workspace_by_id (MetaWorkspaceManager *workspace_manager, int workspace_id);
|
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 */
|
#endif /* META_WORKSPACE_MANAGER_PRIVATE_H */
|
||||||
|
@ -267,9 +267,8 @@ meta_workspace_manager_new (MetaDisplay *display)
|
|||||||
workspace_manager->context_list = NULL;
|
workspace_manager->context_list = NULL;
|
||||||
workspace_manager->active_context = NULL;
|
workspace_manager->active_context = NULL;
|
||||||
workspace_manager->next_context_id = 1;
|
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->workspaces = g_steal_pointer (&context->workspaces);
|
||||||
workspace_manager->active_workspace = g_steal_pointer (&context->active_workspace);
|
workspace_manager->active_workspace = g_steal_pointer (&context->active_workspace);
|
||||||
@ -1170,20 +1169,11 @@ meta_workspace_manager_lookup_context (MetaWorkspaceManager *workspace_manager,
|
|||||||
return NULL;
|
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.
|
* 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
|
* 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)
|
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) {
|
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;
|
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 *
|
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;
|
return workspace_manager->active_context;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
@ -1344,7 +1308,6 @@ meta_workspace_context_remove (MetaWorkspaceContext *context)
|
|||||||
g_signal_emit (context->manager, workspace_manager_signals[CONTEXT_REMOVED],
|
g_signal_emit (context->manager, workspace_manager_signals[CONTEXT_REMOVED],
|
||||||
0, context->id);
|
0, context->id);
|
||||||
|
|
||||||
g_clear_pointer (&context->namespace, g_free);
|
|
||||||
context->manager->context_list = g_list_remove (context->manager->context_list, context);
|
context->manager->context_list = g_list_remove (context->manager->context_list, context);
|
||||||
g_object_unref (context);
|
g_object_unref (context);
|
||||||
}
|
}
|
||||||
@ -1360,7 +1323,7 @@ meta_workspace_context_init (MetaWorkspaceContext *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaWorkspaceContext *
|
MetaWorkspaceContext *
|
||||||
meta_workspace_context_new (MetaWorkspaceManager *manager, const char *namespace)
|
meta_workspace_context_new (MetaWorkspaceManager *manager)
|
||||||
{
|
{
|
||||||
guint context_id = manager->next_context_id++;
|
guint context_id = manager->next_context_id++;
|
||||||
|
|
||||||
@ -1369,13 +1332,8 @@ meta_workspace_context_new (MetaWorkspaceManager *manager, const char *namespace
|
|||||||
context->manager = manager;
|
context->manager = manager;
|
||||||
context->workspaces = NULL;
|
context->workspaces = NULL;
|
||||||
context->active_workspace = NULL;
|
context->active_workspace = NULL;
|
||||||
context->namespace = NULL;
|
|
||||||
context->id = context_id;
|
context->id = context_id;
|
||||||
|
|
||||||
if (namespace) {
|
|
||||||
context->namespace = g_strdup (namespace);
|
|
||||||
}
|
|
||||||
|
|
||||||
manager->context_list = g_list_append (manager->context_list, context);
|
manager->context_list = g_list_append (manager->context_list, context);
|
||||||
|
|
||||||
context->active_workspace = meta_workspace_new_with_context_id (manager, context_id);
|
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 */
|
/* Will set manager->active_workspace from context->active_workspace */
|
||||||
meta_workspace_activate ( g_steal_pointer (&context->active_workspace), timestamp);
|
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;
|
|
||||||
}
|
|
||||||
|
@ -51,6 +51,4 @@ void meta_init_debug_utils (void);
|
|||||||
(ycoord) >= (rect).y && \
|
(ycoord) >= (rect).y && \
|
||||||
(ycoord) < ((rect).y + (rect).height))
|
(ycoord) < ((rect).y + (rect).height))
|
||||||
|
|
||||||
char * meta_read_pid_namespace (pid_t pid);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -584,51 +584,3 @@ meta_get_debug_paint_flags (void)
|
|||||||
{
|
{
|
||||||
return debug_paint_flags;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -561,9 +561,6 @@ struct _MetaWindow
|
|||||||
gboolean has_valid_cgroup;
|
gboolean has_valid_cgroup;
|
||||||
GFile *cgroup_path;
|
GFile *cgroup_path;
|
||||||
|
|
||||||
guint namespace_set: 1;
|
|
||||||
gchar *namespace;
|
|
||||||
|
|
||||||
unsigned int events_during_ping;
|
unsigned int events_during_ping;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -327,7 +327,6 @@ meta_window_finalize (GObject *object)
|
|||||||
g_free (window->gtk_app_menu_object_path);
|
g_free (window->gtk_app_menu_object_path);
|
||||||
g_free (window->gtk_menubar_object_path);
|
g_free (window->gtk_menubar_object_path);
|
||||||
g_free (window->placement.rule);
|
g_free (window->placement.rule);
|
||||||
g_free (window->namespace);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_window_parent_class)->finalize (object);
|
G_OBJECT_CLASS (meta_window_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -8637,31 +8636,3 @@ meta_window_calculate_bounds (MetaWindow *window,
|
|||||||
return FALSE;
|
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);
|
|
||||||
}
|
|
||||||
|
@ -86,6 +86,11 @@ void meta_workspace_manager_override_workspace_layout (MetaWorkspaceManager *wor
|
|||||||
gboolean vertical_layout,
|
gboolean vertical_layout,
|
||||||
int n_rows,
|
int n_rows,
|
||||||
int n_columns);
|
int n_columns);
|
||||||
|
|
||||||
|
META_EXPORT
|
||||||
|
MetaWorkspaceContext *
|
||||||
|
meta_workspace_manager_active_context (MetaWorkspaceManager *workspace_manager);
|
||||||
|
|
||||||
META_EXPORT
|
META_EXPORT
|
||||||
guint meta_workspace_manager_active_context_id (MetaWorkspaceManager *workspace_manager);
|
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);
|
GSList *struts);
|
||||||
|
|
||||||
META_EXPORT
|
META_EXPORT
|
||||||
MetaWorkspaceContext *meta_workspace_manager_context_for_namespace (MetaWorkspaceManager *workspace_manager,
|
MetaWorkspaceContext *
|
||||||
const gchar *namespace);
|
meta_workspace_context_new (MetaWorkspaceManager *manager);
|
||||||
|
|
||||||
META_EXPORT
|
|
||||||
const char *meta_workspace_manager_mutter_namespace (MetaWorkspaceManager *workspace_manager);
|
|
||||||
|
|
||||||
META_EXPORT
|
META_EXPORT
|
||||||
void meta_workspace_context_activate (MetaWorkspaceContext *context);
|
void meta_workspace_context_activate (MetaWorkspaceContext *context);
|
||||||
|
@ -453,10 +453,4 @@ uint64_t meta_window_get_id (MetaWindow *window);
|
|||||||
META_EXPORT
|
META_EXPORT
|
||||||
MetaWindowClientType meta_window_get_client_type (MetaWindow *window);
|
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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user