[gnome-shell] shell/window-tracker: Track windows getting unmanaged



commit f8e531b52ded6a62c41ab8a825124ae6f859de79
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Nov 16 20:52:11 2021 +0100

    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>

 src/shell-app.c            | 9 ---------
 src/shell-window-tracker.c | 9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 1e3b53257f..3e4d4a5e81 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -942,13 +942,6 @@ shell_app_state_transition (ShellApp      *app,
   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
 shell_app_on_user_time_changed (MetaWindow *window,
                                 GParamSpec *pspec,
@@ -1115,7 +1108,6 @@ _shell_app_add_window (ShellApp        *app,
 
   app->running_state->window_sort_stale = TRUE;
   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::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))
     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_skip_taskbar_changed), app);
   app->running_state->windows = g_slist_remove (app->running_state->windows, window);
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index 4fb2542640..cc03fb5f6e 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -527,6 +527,13 @@ on_gtk_application_id_changed (MetaWindow  *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
 track_window (ShellWindowTracker *self,
               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::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);
 
@@ -573,6 +581,7 @@ disassociate_window (ShellWindowTracker   *self,
   _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_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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]