summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2023-03-24 00:25:06 +0100
committerMarge Bot <marge-bot@gnome.org>2023-04-20 15:11:58 +0000
commit12bb3a601d590206c77d51be15ebc1890d1373a5 (patch)
treeceae62e73a0af785febc1596be8551020a79191d
parente7a09946ca44a4f4fae6fa847f08e681cfd877cb (diff)
downloadgnome-shell-12bb3a601d590206c77d51be15ebc1890d1373a5.tar.gz
shell-app-system: Give priority to .desktop IDs that should be shown
If we have multiple desktop ID's that share the same startup-wm class and none of them is actually matching the desktop-id, then we should exclude the ones that should not be shown in the current desktop. This will help preventing cases such as the previous one in case no desktop file ID would match the startup-wm-class exactly. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2721>
-rw-r--r--src/shell-app-system.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index e042a6747..294179351 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -114,17 +114,20 @@ static void
scan_startup_wm_class_to_id (ShellAppSystem *self)
{
ShellAppSystemPrivate *priv = self->priv;
+ g_autoptr(GPtrArray) no_show_ids = NULL;
const GList *l;
GList *all;
g_hash_table_remove_all (priv->startup_wm_class_to_id);
all = shell_app_cache_get_all (shell_app_cache_get_default ());
+ no_show_ids = g_ptr_array_new ();
for (l = all; l != NULL; l = l->next)
{
GAppInfo *info = l->data;
const char *startup_wm_class, *id, *old_id;
+ gboolean should_show;
id = g_app_info_get_id (info);
startup_wm_class = g_desktop_app_info_get_startup_wm_class (G_DESKTOP_APP_INFO (info));
@@ -132,11 +135,23 @@ scan_startup_wm_class_to_id (ShellAppSystem *self)
if (startup_wm_class == NULL)
continue;
+ should_show = g_app_info_should_show (info);
+ if (!should_show)
+ g_ptr_array_add (no_show_ids, (char *) id);
+
/* In case multiple .desktop files set the same StartupWMClass, prefer
* the one where ID and StartupWMClass match */
old_id = g_hash_table_lookup (priv->startup_wm_class_to_id, startup_wm_class);
- if (old_id == NULL ||
- startup_wm_class_is_exact_match (id, startup_wm_class))
+
+ if (old_id && startup_wm_class_is_exact_match (id, startup_wm_class))
+ old_id = NULL;
+
+ /* Give priority to the desktop files that should be shown */
+ if (old_id && should_show &&
+ g_ptr_array_find_with_equal_func (no_show_ids, old_id, g_str_equal, NULL))
+ old_id = NULL;
+
+ if (!old_id)
g_hash_table_insert (priv->startup_wm_class_to_id,
g_strdup (startup_wm_class), g_strdup (id));
}