From c1933cfd0990d1ce5cba8d0c7730624f76353822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 29 Jun 2020 01:06:30 +0200 Subject: [PATCH] workspace: Add :active convenience property There are a couple of places in gnome-shell where we aren't interested in which workspace is active, but whether a given workspace is active. Of course it's easy to use the former to determine the latter, but we can offer a convenience property on the workspace itself almost for free, so let's do that. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1336 --- src/core/workspace.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/workspace.c b/src/core/workspace.c index 6125481a1..7217ddcee 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -62,6 +62,7 @@ enum PROP_N_WINDOWS, PROP_WORKSPACE_INDEX, + PROP_ACTIVE, PROP_LAST, }; @@ -179,6 +180,9 @@ meta_workspace_get_property (GObject *object, case PROP_WORKSPACE_INDEX: g_value_set_uint (value, meta_workspace_index (ws)); break; + case PROP_ACTIVE: + g_value_set_boolean (value, ws->manager->active_workspace == ws); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -218,6 +222,11 @@ meta_workspace_class_init (MetaWorkspaceClass *klass) "The workspace's index", 0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_props[PROP_ACTIVE] = g_param_spec_boolean ("active", + "Active", + "Whether the workspace is currently active", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, PROP_LAST, obj_props); } @@ -551,9 +560,13 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace, g_signal_emit_by_name (workspace->manager, "active-workspace-changed"); + g_object_notify_by_pspec (G_OBJECT (workspace), obj_props[PROP_ACTIVE]); + if (old == NULL) return; + g_object_notify_by_pspec (G_OBJECT (old), obj_props[PROP_ACTIVE]); + /* If the "show desktop" mode is active for either the old workspace * or the new one *but not both*, then update the * _net_showing_desktop hint