diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-04-07 05:47:20 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-04-07 05:47:20 +0000 |
| commit | 5f42ecfacbbf0bcfe43137c51a20b60d8ea368e3 (patch) | |
| tree | 5be32cfa3f91b3b46f6cf0c972e4559bab1fe07f /openbox/group.c | |
| parent | aaae49d6291ffd202cfd7e6a9a31df816433d356 (diff) | |
track window groups
iconify all its transients when a window is iconified
Diffstat (limited to 'openbox/group.c')
| -rw-r--r-- | openbox/group.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/openbox/group.c b/openbox/group.c new file mode 100644 index 00000000..69d2ccb2 --- /dev/null +++ b/openbox/group.c @@ -0,0 +1,46 @@ +#include "group.h" +#include "client.h" + +GHashTable *group_map = NULL; + +static guint map_hash(Window *w) { return *w; } +static gboolean map_key_comp(Window *w1, Window *w2) { return *w1 == *w2; } + +void group_startup() +{ + group_map = g_hash_table_new((GHashFunc)map_hash, + (GEqualFunc)map_key_comp); +} + +void group_shutdown() +{ + g_hash_table_destroy(group_map); +} + +Group *group_add(Window leader, Client *client) +{ + Group *self; + + self = g_hash_table_lookup(group_map, &leader); + if (self == NULL) { + self = g_new(Group, 1); + self->leader = leader; + self->members = NULL; + g_hash_table_insert(group_map, &self->leader, self); + g_message("NEW GROUP FOR %lx", leader); + } else + g_message("REUSING GROUP FOR %lx", leader); + + self->members = g_slist_append(self->members, client); + + return self; +} + +void group_remove(Group *self, Client *client) +{ + self->members = g_slist_remove(self->members, client); + if (self->members == NULL) { + g_hash_table_remove(group_map, &self->leader); + g_free(self); + } +} |
