]> Dogcows Code - chaz/openbox/blob - openbox/group.c
0a03aeefb8124f5b8b0525419499739e437d7334
[chaz/openbox] / openbox / group.c
1 #include "group.h"
2 #include "client.h"
3
4 GHashTable *group_map = NULL;
5
6 static guint map_hash(Window *w) { return *w; }
7 static gboolean map_key_comp(Window *w1, Window *w2) { return *w1 == *w2; }
8
9 void group_startup()
10 {
11 group_map = g_hash_table_new((GHashFunc)map_hash,
12 (GEqualFunc)map_key_comp);
13 }
14
15 void group_shutdown()
16 {
17 g_hash_table_destroy(group_map);
18 }
19
20 Group *group_add(Window leader, ObClient *client)
21 {
22 Group *self;
23
24 self = g_hash_table_lookup(group_map, &leader);
25 if (self == NULL) {
26 self = g_new(Group, 1);
27 self->leader = leader;
28 self->members = NULL;
29 g_hash_table_insert(group_map, &self->leader, self);
30 }
31
32 self->members = g_slist_append(self->members, client);
33
34 return self;
35 }
36
37 void group_remove(Group *self, ObClient *client)
38 {
39 self->members = g_slist_remove(self->members, client);
40 if (self->members == NULL) {
41 g_hash_table_remove(group_map, &self->leader);
42 g_free(self);
43 }
44 }
This page took 0.035247 seconds and 4 git commands to generate.