[gnome-shell] ShellWindowTracker: complete WM_CLASS fix
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] ShellWindowTracker: complete WM_CLASS fix
- Date: Thu, 8 Aug 2013 12:15:44 +0000 (UTC)
commit 2a95273b7920939760dedadccbb7e1ce88d5f394
Author: Giovanni Campagna <gcampagn redhat com>
Date: Thu Aug 8 10:40:01 2013 +0200
ShellWindowTracker: complete WM_CLASS fix
Chromium (but not google-chrome) has a StartupWMClass in the desktop
file, so we must match the instance part first to have chrome
web apps working.
Also, we must take care of apps without a wm_class or instance at
all.
https://bugzilla.gnome.org/show_bug.cgi?id=673657
src/shell-app-system.c | 7 +++++--
src/shell-window-tracker.c | 27 ++++++++++++++++-----------
2 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index a6587be..7f43bd4 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -541,7 +541,7 @@ shell_app_system_lookup_heuristic_basename (ShellAppSystem *system,
/**
* shell_app_system_lookup_desktop_wmclass:
* @system: a #ShellAppSystem
- * @wmclass: A WM_CLASS value
+ * @wmclass: (allow-none): A WM_CLASS value
*
* Find a valid application whose .desktop file, without the extension
* and properly canonicalized, matches @wmclass.
@@ -578,7 +578,7 @@ shell_app_system_lookup_desktop_wmclass (ShellAppSystem *system,
/**
* shell_app_system_lookup_startup_wmclass:
* @system: a #ShellAppSystem
- * @wmclass: A WM_CLASS value
+ * @wmclass: (allow-none): A WM_CLASS value
*
* Find a valid application whose .desktop file contains a
* StartupWMClass entry matching @wmclass.
@@ -589,6 +589,9 @@ ShellApp *
shell_app_system_lookup_startup_wmclass (ShellAppSystem *system,
const char *wmclass)
{
+ if (wmclass == NULL)
+ return NULL;
+
return g_hash_table_lookup (system->priv->startup_wm_class_to_app, wmclass);
}
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index 09653e4..e922cdd 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -225,31 +225,36 @@ get_app_from_window_wmclass (MetaWindow *window)
with
StartupWMClass=crx_blpcfgokakmgnkcojhhkbfbldkacnbeo
- */
- /* first try a match from WM_CLASS to StartupWMClass */
- wm_class = meta_window_get_wm_class (window);
- app = shell_app_system_lookup_startup_wmclass (appsys, wm_class);
- if (app != NULL)
- return g_object_ref (app);
+ Note that chromium (but not google-chrome!) includes a StartupWMClass=chromium
+ in their .desktop file, so we must match the instance first.
+
+ Also note that in the good case (regular gtk+ app without hacks), instance and
+ class are the same except for case and there is no StartupWMClass at all.
+ */
- /* then try a match from WM_CLASS (instance part) to StartupWMClass */
+ /* first try a match from WM_CLASS (instance part) to StartupWMClass */
wm_instance = meta_window_get_wm_class_instance (window);
app = shell_app_system_lookup_startup_wmclass (appsys, wm_instance);
if (app != NULL)
return g_object_ref (app);
- /* then try a match from WM_CLASS to .desktop */
- app = shell_app_system_lookup_desktop_wmclass (appsys, wm_class);
+ /* then try a match from WM_CLASS to StartupWMClass */
+ wm_class = meta_window_get_wm_class (window);
+ app = shell_app_system_lookup_startup_wmclass (appsys, wm_class);
if (app != NULL)
return g_object_ref (app);
- /* finally, try a match from WM_CLASS (instance part) to .desktop
- (unlikely to find anything at this point, but still worth a try) */
+ /* then try a match from WM_CLASS (instance part) to .desktop */
app = shell_app_system_lookup_desktop_wmclass (appsys, wm_instance);
if (app != NULL)
return g_object_ref (app);
+ /* finally, try a match from WM_CLASS to .desktop */
+ app = shell_app_system_lookup_desktop_wmclass (appsys, wm_class);
+ if (app != NULL)
+ return g_object_ref (app);
+
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]