shell-app-system: Do not compare startup-wm classes with full desktop IDs
When fetching the desktop ids into a map of startup-wm classes we meant to give the ones that match the desktop ID more priority, however this did not happen because we were always comparing a desktop file id, including the `.desktop` suffix, with a wm-class that generally does not include that. This is the case of gnome-system-monitor, that provides two desktop files, one of which is OnlyShowIn=KDE but both have the same StartupWMClass and thus the first parsed is preferred, even though its desktop-id is gnome-system-monitor-kde. As per this, remove the .desktop suffix when comparing it with the startup-wm-class, keeping the old check just in case. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2721>
This commit is contained in:
parent
8d1fe3b4cb
commit
e7a09946ca
@ -91,6 +91,25 @@ static void shell_app_system_class_init(ShellAppSystemClass *klass)
|
|||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether @wm_class matches @id exactly when ignoring the .desktop suffix
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
startup_wm_class_is_exact_match (const char *id,
|
||||||
|
const char *wm_class)
|
||||||
|
{
|
||||||
|
size_t wm_class_len;
|
||||||
|
|
||||||
|
if (!g_str_has_prefix (id, wm_class))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
wm_class_len = strlen (wm_class);
|
||||||
|
if (id[wm_class_len] == '\0')
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return g_str_equal (id + wm_class_len, ".desktop");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scan_startup_wm_class_to_id (ShellAppSystem *self)
|
scan_startup_wm_class_to_id (ShellAppSystem *self)
|
||||||
{
|
{
|
||||||
@ -116,7 +135,8 @@ scan_startup_wm_class_to_id (ShellAppSystem *self)
|
|||||||
/* In case multiple .desktop files set the same StartupWMClass, prefer
|
/* In case multiple .desktop files set the same StartupWMClass, prefer
|
||||||
* the one where ID and StartupWMClass match */
|
* the one where ID and StartupWMClass match */
|
||||||
old_id = g_hash_table_lookup (priv->startup_wm_class_to_id, startup_wm_class);
|
old_id = g_hash_table_lookup (priv->startup_wm_class_to_id, startup_wm_class);
|
||||||
if (old_id == NULL || strcmp (id, startup_wm_class) == 0)
|
if (old_id == NULL ||
|
||||||
|
startup_wm_class_is_exact_match (id, startup_wm_class))
|
||||||
g_hash_table_insert (priv->startup_wm_class_to_id,
|
g_hash_table_insert (priv->startup_wm_class_to_id,
|
||||||
g_strdup (startup_wm_class), g_strdup (id));
|
g_strdup (startup_wm_class), g_strdup (id));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user