mirror of
https://github.com/brl/mutter.git
synced 2024-11-27 18:40:40 -05:00
Remove mapping of workspace contexts to pid namespaces.
This is handled in gnome shell now.
This commit is contained in:
parent
db5ce3d87d
commit
8acc2e2a4d
@ -52,9 +52,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;
|
||||||
};
|
};
|
||||||
@ -72,8 +69,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;
|
||||||
@ -135,8 +130,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,
|
||||||
@ -157,6 +150,3 @@ 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);
|
|
||||||
|
|
||||||
|
@ -248,9 +248,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);
|
||||||
@ -1141,20 +1140,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) {
|
||||||
@ -1247,36 +1237,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
|
||||||
@ -1315,7 +1279,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);
|
||||||
}
|
}
|
||||||
@ -1331,7 +1294,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++;
|
||||||
|
|
||||||
@ -1340,13 +1303,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);
|
||||||
@ -1454,16 +1412,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;
|
|
||||||
}
|
|
||||||
|
@ -55,6 +55,3 @@ meta_timeval_to_microseconds (const struct timeval *tv)
|
|||||||
|
|
||||||
#define META_CONTAINER_OF(ptr, type, member) \
|
#define META_CONTAINER_OF(ptr, type, member) \
|
||||||
(type *) ((uint8_t *) (ptr) - G_STRUCT_OFFSET (type, member))
|
(type *) ((uint8_t *) (ptr) - G_STRUCT_OFFSET (type, member))
|
||||||
|
|
||||||
char * meta_read_pid_namespace (pid_t pid);
|
|
||||||
|
|
||||||
|
@ -598,50 +598,3 @@ meta_log (const char *format, ...)
|
|||||||
g_logv (G_LOG_DOMAIN, mutter_log_level, format, args);
|
g_logv (G_LOG_DOMAIN, mutter_log_level, format, args);
|
||||||
va_end (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;
|
|
||||||
}
|
|
||||||
|
@ -558,10 +558,6 @@ struct _MetaWindow
|
|||||||
guint is_alive : 1;
|
guint is_alive : 1;
|
||||||
|
|
||||||
guint in_workspace_change : 1;
|
guint in_workspace_change : 1;
|
||||||
|
|
||||||
guint namespace_set: 1;
|
|
||||||
gchar *namespace;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MetaWindowClass
|
struct _MetaWindowClass
|
||||||
|
@ -336,7 +336,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);
|
||||||
}
|
}
|
||||||
@ -7764,32 +7763,3 @@ meta_get_window_suspend_timeout_s (void)
|
|||||||
{
|
{
|
||||||
return SUSPEND_HIDDEN_TIMEOUT_S;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -86,6 +86,13 @@ void meta_workspace_manager_override_workspace_layout (MetaWorkspaceManager *wor
|
|||||||
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
|
||||||
|
guint meta_workspace_manager_active_context_id (MetaWorkspaceManager *workspace_manager);
|
||||||
|
|
||||||
META_EXPORT
|
META_EXPORT
|
||||||
int meta_workspace_manager_get_layout_columns (MetaWorkspaceManager *workspace_manager);
|
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);
|
guint meta_workspace_manager_active_context_id (MetaWorkspaceManager *workspace_manager);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -440,10 +440,3 @@ MetaWindowClientType meta_window_get_client_type (MetaWindow *window);
|
|||||||
|
|
||||||
META_EXPORT
|
META_EXPORT
|
||||||
gboolean meta_window_has_pointer (MetaWindow *window);
|
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);
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user