From 1b7577298a608d9bdffc75755bd9bc15177b68df Mon Sep 17 00:00:00 2001 From: Mario Sanchez Prada Date: Fri, 20 Apr 2018 14:02:35 +0100 Subject: [PATCH] window-tracker: check WM_CLASS for sandboxed apps before the app's ID For sandboxed apps, the shell needs to consider the app's ID when matching its windows against the right .desktop file, but that check can't be done before having attempted to match using the WM_CLASS property of the app's window, otherwise apps installing multiple desktop files (e.g. LibreOffice) will always match every single window against the same .desktop file, ignoring hints such as the StartupWMClass key. This commit moves the call to get_app_from_sandboxed_app_id() after get_app_from_window_wmclass() and before get_app_from_window_pid(), so that we only rely on the sandboxed app's ID when no match has succeed using the WM_CLASS property, but before checking by PID to prevent wrong groups that could be created when the PID of the app inside the sandbox matches the one from a process outside of it. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/219 --- src/shell-window-tracker.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c index 85c787096..4b4f1895e 100644 --- a/src/shell-window-tracker.c +++ b/src/shell-window-tracker.c @@ -395,13 +395,6 @@ get_app_for_window (ShellWindowTracker *tracker, if (meta_window_is_remote (window)) return _shell_app_new_for_window (window); - /* Check if the window was opened from within a sandbox; if this - * is the case, a corresponding .desktop file is guaranteed to match; - */ - result = get_app_from_sandboxed_app_id (window); - if (result != NULL) - return result; - /* Check if the window has a GApplication ID attached; this is * canonical if it does */ @@ -416,6 +409,15 @@ get_app_for_window (ShellWindowTracker *tracker, if (result != NULL) return result; + /* Check if the window was opened from within a sandbox; if this + * is the case, a corresponding .desktop file is guaranteed to match; + * Do this after having checked by WM_CLASS so that sandboxed apps + * installing multiple .desktop files can properly match their windows. + */ + result = get_app_from_sandboxed_app_id (window); + if (result != NULL) + return result; + result = get_app_from_window_pid (tracker, window); if (result != NULL) return result;