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
This commit is contained in:
Florian Müllner 2020-03-04 23:26:15 +01:00 committed by Florian Müllner
parent 07bbcb1b48
commit e6d4581959
2 changed files with 18 additions and 0 deletions

View File

@ -29,6 +29,7 @@ struct _ShellTrayManagerPrivate {
ClutterColor bg_color; ClutterColor bg_color;
GHashTable *icons; GHashTable *icons;
StWidget *theme_widget;
}; };
typedef struct { typedef struct {
@ -228,6 +229,8 @@ void
shell_tray_manager_manage_screen (ShellTrayManager *manager, shell_tray_manager_manage_screen (ShellTrayManager *manager,
StWidget *theme_widget) StWidget *theme_widget)
{ {
g_set_weak_pointer (&manager->priv->theme_widget, theme_widget);
shell_tray_manager_ensure_resources (manager); shell_tray_manager_ensure_resources (manager);
na_tray_manager_manage_screen (manager->priv->na_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); 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 static void
shell_tray_manager_child_on_realize (GtkWidget *widget, shell_tray_manager_child_on_realize (GtkWidget *widget,
ShellTrayManagerChild *child) ShellTrayManagerChild *child)

View File

@ -15,6 +15,7 @@ G_DECLARE_FINAL_TYPE (ShellTrayManager, shell_tray_manager,
ShellTrayManager *shell_tray_manager_new (void); ShellTrayManager *shell_tray_manager_new (void);
void shell_tray_manager_manage_screen (ShellTrayManager *manager, void shell_tray_manager_manage_screen (ShellTrayManager *manager,
StWidget *theme_widget); StWidget *theme_widget);
void shell_tray_manager_unmanage_screen (ShellTrayManager *manager);
G_END_DECLS G_END_DECLS