From e6d458195969aa054ef688d9095cfbfb3275e2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 4 Mar 2020 23:26:15 +0100 Subject: [PATCH] shell/tray-manager: Allow to unmanage screen Since support for legacy status icons is implemented by extensions nowadays, they need to undo the call to manage_screen() when they are disabled. Right now that means bypassing garbage collection with an explicit call to run_dispose() on the Shell.TrayManager. That works, but is rather ugly. An explicit unmanage_screen() method is a nicer option, and will be useful to us as well to deal with X11 going away (once Xwayland crashes don't bring down the entire session). https://gitlab.gnome.org/GNOME/gnome-shell/issues/2308 --- src/shell-tray-manager.c | 17 +++++++++++++++++ src/shell-tray-manager.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/shell-tray-manager.c b/src/shell-tray-manager.c index 269682bcf..ea7066be6 100644 --- a/src/shell-tray-manager.c +++ b/src/shell-tray-manager.c @@ -29,6 +29,7 @@ struct _ShellTrayManagerPrivate { ClutterColor bg_color; GHashTable *icons; + StWidget *theme_widget; }; typedef struct { @@ -228,6 +229,8 @@ void shell_tray_manager_manage_screen (ShellTrayManager *manager, StWidget *theme_widget) { + g_set_weak_pointer (&manager->priv->theme_widget, theme_widget); + shell_tray_manager_ensure_resources (manager); na_tray_manager_manage_screen (manager->priv->na_manager); @@ -238,6 +241,20 @@ shell_tray_manager_manage_screen (ShellTrayManager *manager, shell_tray_manager_style_changed (theme_widget, manager); } +void +shell_tray_manager_unmanage_screen (ShellTrayManager *manager) +{ + if (manager->priv->theme_widget != NULL) + { + g_signal_handlers_disconnect_by_func (manager->priv->theme_widget, + G_CALLBACK (shell_tray_manager_style_changed), + manager); + } + g_set_weak_pointer (&manager->priv->theme_widget, NULL); + + shell_tray_manager_release_resources (manager); +} + static void shell_tray_manager_child_on_realize (GtkWidget *widget, ShellTrayManagerChild *child) diff --git a/src/shell-tray-manager.h b/src/shell-tray-manager.h index 2e4c0f7bb..d6279d47c 100644 --- a/src/shell-tray-manager.h +++ b/src/shell-tray-manager.h @@ -15,6 +15,7 @@ G_DECLARE_FINAL_TYPE (ShellTrayManager, shell_tray_manager, ShellTrayManager *shell_tray_manager_new (void); void shell_tray_manager_manage_screen (ShellTrayManager *manager, StWidget *theme_widget); +void shell_tray_manager_unmanage_screen (ShellTrayManager *manager); G_END_DECLS