]> Dogcows Code - chaz/openbox/blob - openbox/group.c
save the new glist!
[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(gboolean reconfig)
10 {
11 if (reconfig) return;
12
13 group_map = g_hash_table_new((GHashFunc)map_hash,
14 (GEqualFunc)map_key_comp);
15 }
16
17 void group_shutdown(gboolean reconfig)
18 {
19 if (reconfig) return;
20
21 g_hash_table_destroy(group_map);
22 }
23
24 ObGroup *group_add(Window leader, ObClient *client)
25 {
26 ObGroup *self;
27
28 self = g_hash_table_lookup(group_map, &leader);
29 if (self == NULL) {
30 self = g_new(ObGroup, 1);
31 self->leader = leader;
32 self->members = NULL;
33 g_hash_table_insert(group_map, &self->leader, self);
34 }
35
36 self->members = g_slist_append(self->members, client);
37
38 return self;
39 }
40
41 void group_remove(ObGroup *self, ObClient *client)
42 {
43 self->members = g_slist_remove(self->members, client);
44 if (self->members == NULL) {
45 g_hash_table_remove(group_map, &self->leader);
46 g_free(self);
47 }
48 }
This page took 0.036149 seconds and 4 git commands to generate.