[gnome-shell] Track changes to WM_CLASS
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Track changes to WM_CLASS
- Date: Wed, 25 May 2011 16:10:40 +0000 (UTC)
commit d51e79d483a7ddccfc12dbcf938289757ff85c0e
Author: Colin Walters <walters verbum org>
Date: Tue May 24 19:42:07 2011 -0400
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 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index 1c7cf51..ef55526 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -509,6 +509,33 @@ on_transient_window_title_changed (MetaWindow *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);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]