shell/window-tracker: Track windows getting unmanaged

It makes sense to not rely on workspaces' ::window-removed
signal, and we already do that in ShellApp.

However it is odd to remove a tracked window from the app,
but still track it in the window tracker. Move the code
to remove unmanaged windows from both.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4751

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2029>
This commit is contained in:
Florian Müllner 2021-11-16 20:52:11 +01:00
parent 4f91cfb5a6
commit f8e531b52d
2 changed files with 9 additions and 9 deletions

View File

@ -942,13 +942,6 @@ shell_app_state_transition (ShellApp *app,
g_object_notify (G_OBJECT (app), "state"); g_object_notify (G_OBJECT (app), "state");
} }
static void
shell_app_on_unmanaged (MetaWindow *window,
ShellApp *app)
{
_shell_app_remove_window (app, window);
}
static void static void
shell_app_on_user_time_changed (MetaWindow *window, shell_app_on_user_time_changed (MetaWindow *window,
GParamSpec *pspec, GParamSpec *pspec,
@ -1115,7 +1108,6 @@ _shell_app_add_window (ShellApp *app,
app->running_state->window_sort_stale = TRUE; app->running_state->window_sort_stale = TRUE;
app->running_state->windows = g_slist_prepend (app->running_state->windows, g_object_ref (window)); app->running_state->windows = g_slist_prepend (app->running_state->windows, g_object_ref (window));
g_signal_connect_object (window, "unmanaged", G_CALLBACK(shell_app_on_unmanaged), app, 0);
g_signal_connect_object (window, "notify::user-time", G_CALLBACK(shell_app_on_user_time_changed), app, 0); g_signal_connect_object (window, "notify::user-time", G_CALLBACK(shell_app_on_user_time_changed), app, 0);
g_signal_connect_object (window, "notify::skip-taskbar", G_CALLBACK(shell_app_on_skip_taskbar_changed), app, 0); g_signal_connect_object (window, "notify::skip-taskbar", G_CALLBACK(shell_app_on_skip_taskbar_changed), app, 0);
@ -1144,7 +1136,6 @@ _shell_app_remove_window (ShellApp *app,
if (!g_slist_find (app->running_state->windows, window)) if (!g_slist_find (app->running_state->windows, window))
return; return;
g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_unmanaged), app);
g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_user_time_changed), app); g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_user_time_changed), app);
g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_skip_taskbar_changed), app); g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_skip_taskbar_changed), app);
app->running_state->windows = g_slist_remove (app->running_state->windows, window); app->running_state->windows = g_slist_remove (app->running_state->windows, window);

View File

@ -527,6 +527,13 @@ on_gtk_application_id_changed (MetaWindow *window,
tracked_window_changed (self, window); tracked_window_changed (self, window);
} }
static void
on_window_unmanaged (MetaWindow *window,
gpointer user_data)
{
disassociate_window (SHELL_WINDOW_TRACKER (user_data), window);
}
static void static void
track_window (ShellWindowTracker *self, track_window (ShellWindowTracker *self,
MetaWindow *window) MetaWindow *window)
@ -542,6 +549,7 @@ track_window (ShellWindowTracker *self,
g_signal_connect (window, "notify::wm-class", G_CALLBACK (on_wm_class_changed), self); g_signal_connect (window, "notify::wm-class", G_CALLBACK (on_wm_class_changed), self);
g_signal_connect (window, "notify::gtk-application-id", G_CALLBACK (on_gtk_application_id_changed), self); g_signal_connect (window, "notify::gtk-application-id", G_CALLBACK (on_gtk_application_id_changed), self);
g_signal_connect (window, "unmanaged", G_CALLBACK (on_window_unmanaged), self);
_shell_app_add_window (app, window); _shell_app_add_window (app, window);
@ -573,6 +581,7 @@ disassociate_window (ShellWindowTracker *self,
_shell_app_remove_window (app, window); _shell_app_remove_window (app, window);
g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_wm_class_changed), self); g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_wm_class_changed), self);
g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_gtk_application_id_changed), self); g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_gtk_application_id_changed), self);
g_signal_handlers_disconnect_by_func (window, G_CALLBACK (on_window_unmanaged), self);
g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0); g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0);