summaryrefslogtreecommitdiff
path: root/src/shell-app-system.c
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2013-10-02 18:16:45 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2013-11-02 20:12:36 -0400
commit2daa0d057b3bd54bbe4fcd10c304ad17ae85ec2a (patch)
tree197e07b9ca9905a3573121dd3dafb29d89025f01 /src/shell-app-system.c
parent76eca409a3d79a02c05ce8c2d8341ec6a1961838 (diff)
app-system: Map wmclass to ID rather than apps
This makes the refcounting and memory management easier to understand.
Diffstat (limited to 'src/shell-app-system.c')
-rw-r--r--src/shell-app-system.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index a825712b..9890bc57 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -43,7 +43,7 @@ struct _ShellAppSystemPrivate {
GHashTable *running_apps;
GHashTable *visible_id_to_app;
GHashTable *id_to_app;
- GHashTable *startup_wm_class_to_app;
+ GHashTable *startup_wm_class_to_id;
GSList *known_vendor_prefixes;
};
@@ -94,9 +94,7 @@ shell_app_system_init (ShellAppSystem *self)
/* All the objects in this hash table are owned by id_to_app */
priv->visible_id_to_app = g_hash_table_new (g_str_hash, g_str_equal);
- priv->startup_wm_class_to_app = g_hash_table_new_full (g_str_hash, g_str_equal,
- NULL,
- (GDestroyNotify)g_object_unref);
+ priv->startup_wm_class_to_id = g_hash_table_new (g_str_hash, g_str_equal);
/* We want to track NoDisplay apps, so we add INCLUDE_NODISPLAY. We'll
* filter NoDisplay apps out when showing them to the user. */
@@ -117,7 +115,7 @@ shell_app_system_finalize (GObject *object)
g_hash_table_destroy (priv->running_apps);
g_hash_table_destroy (priv->id_to_app);
g_hash_table_destroy (priv->visible_id_to_app);
- g_hash_table_destroy (priv->startup_wm_class_to_app);
+ g_hash_table_destroy (priv->startup_wm_class_to_id);
g_slist_free_full (priv->known_vendor_prefixes, g_free);
priv->known_vendor_prefixes = NULL;
@@ -353,7 +351,7 @@ on_apps_tree_changed_cb (GMenuTree *tree,
old_startup_wm_class = g_desktop_app_info_get_startup_wm_class (old_info);
if (old_startup_wm_class)
- g_hash_table_remove (self->priv->startup_wm_class_to_app, old_startup_wm_class);
+ g_hash_table_remove (self->priv->startup_wm_class_to_id, old_startup_wm_class);
_shell_app_set_app_info (app, info);
g_object_ref (app); /* Extra ref, removed in _replace below */
@@ -371,8 +369,8 @@ on_apps_tree_changed_cb (GMenuTree *tree,
startup_wm_class = g_desktop_app_info_get_startup_wm_class (info);
if (startup_wm_class)
- g_hash_table_replace (self->priv->startup_wm_class_to_app,
- (char*)startup_wm_class, g_object_ref (app));
+ g_hash_table_replace (self->priv->startup_wm_class_to_id,
+ (char*)startup_wm_class, (char*)id);
}
/* Now iterate over the apps again; we need to unreference any apps
* which have been removed. The JS code may still be holding a
@@ -568,10 +566,16 @@ ShellApp *
shell_app_system_lookup_startup_wmclass (ShellAppSystem *system,
const char *wmclass)
{
+ const char *id;
+
if (wmclass == NULL)
return NULL;
- return g_hash_table_lookup (system->priv->startup_wm_class_to_app, wmclass);
+ id = g_hash_table_lookup (system->priv->startup_wm_class_to_id, wmclass);
+ if (id == NULL)
+ return NULL;
+
+ return shell_app_system_lookup_app (system, id);
}
void