From d51e79d483a7ddccfc12dbcf938289757ff85c0e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 24 May 2011 19:42:07 -0400 Subject: [PATCH] Track changes to WM_CLASS LibreOffice changes applications dynamically; we should support this. https://bugzilla.gnome.org/show_bug.cgi?id=649315 --- src/shell-window-tracker.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c index 1c7cf5144..ef555261f 100644 --- a/src/shell-window-tracker.c +++ b/src/shell-window-tracker.c @@ -508,6 +508,33 @@ on_transient_window_title_changed (MetaWindow *window, track_window (self, window); } +static void +update_focus_app (ShellWindowTracker *self) +{ + MetaWindow *new_focus_win; + ShellApp *new_focus_app; + + new_focus_win = meta_display_get_focus_window (meta_screen_get_display (shell_global_get_screen (shell_global_get ()))); + new_focus_app = new_focus_win ? shell_window_tracker_get_window_app (self, new_focus_win) : NULL; + + set_focus_app (self, new_focus_app); +} + +static void +on_wm_class_changed (MetaWindow *window, + GParamSpec *pspec, + gpointer user_data) +{ + 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); + /* also just recaulcuate the focused app, in case it was the focused + window that changed */ + update_focus_app (self); +} + static void track_window (ShellWindowTracker *self, MetaWindow *window) @@ -534,6 +561,8 @@ track_window (ShellWindowTracker *self, g_signal_connect (window, "notify::title", G_CALLBACK (on_transient_window_title_changed), self); } + g_signal_connect (window, "notify::wm-class", G_CALLBACK (on_wm_class_changed), self); + _shell_app_add_window (app, window); g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0); @@ -884,13 +913,7 @@ on_focus_window_changed (MetaDisplay *display, GParamSpec *spec, ShellWindowTracker *tracker) { - MetaWindow *new_focus_win; - ShellApp *new_focus_app; - - new_focus_win = meta_display_get_focus_window (display); - new_focus_app = new_focus_win ? shell_window_tracker_get_window_app (tracker, new_focus_win) : NULL; - - set_focus_app (tracker, new_focus_app); + update_focus_app (tracker); } /**