From aa3aea75201120226e04450aaf5d58115482031e Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 12 Oct 2014 17:20:22 -0700 Subject: [PATCH] window-tracker: Also listen for changes in the gtk-application-id Wayland applications don't tend to have very useful WM Class properties, as GTK+ isn't very good at picking an appropriate application ID. While we should likely fix GTK+ to pick a better app ID, we do have the existing gtk_shell for more accurate information. The only problem is that the gtk_surface is set after the MetaWindow is constructed, and we're not listening for changes on the GTK+ application ID. Listen to changes on the GTK+ application ID to fix app tracking for most GTK+ applications under Wayland. --- src/shell-window-tracker.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c index 512f7ec1e..5c490085e 100644 --- a/src/shell-window-tracker.c +++ b/src/shell-window-tracker.c @@ -448,12 +448,9 @@ update_focus_app (ShellWindowTracker *self) } static void -on_wm_class_changed (MetaWindow *window, - GParamSpec *pspec, - gpointer user_data) +tracked_window_changed (ShellWindowTracker *self, + MetaWindow *window) { - ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data); - /* It's simplest to just treat this as a remove + add. */ disassociate_window (self, window); track_window (self, window); @@ -462,6 +459,24 @@ on_wm_class_changed (MetaWindow *window, update_focus_app (self); } +static void +on_wm_class_changed (MetaWindow *window, + GParamSpec *pspec, + gpointer user_data) +{ + ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data); + tracked_window_changed (self, window); +} + +static void +on_gtk_application_id_changed (MetaWindow *window, + GParamSpec *pspec, + gpointer user_data) +{ + ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data); + tracked_window_changed (self, window); +} + static void track_window (ShellWindowTracker *self, MetaWindow *window) @@ -476,6 +491,7 @@ track_window (ShellWindowTracker *self, g_hash_table_insert (self->window_to_app, window, app); 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); _shell_app_add_window (app, window); @@ -508,6 +524,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_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0);