Fix compile failure when X_HAVE_UTF8_STRING is not defined
[openbox.git] / openbox / group.c
blob0712bf48d2e64eaf4ef0283b1e4cd2a6849f3de8
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 group.c for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 See the COPYING file for a copy of the GNU General Public License.
19 #include "group.h"
20 #include "client.h"
22 static GHashTable *group_map;
24 static guint window_hash(Window *w) { return *w; }
25 static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
27 void group_startup(gboolean reconfig)
29 if (reconfig) return;
31 group_map = g_hash_table_new((GHashFunc)window_hash,
32 (GEqualFunc)window_comp);
35 void group_shutdown(gboolean reconfig)
37 if (reconfig) return;
39 g_hash_table_destroy(group_map);
42 ObGroup *group_add(Window leader, ObClient *client)
44 ObGroup *self;
46 self = g_hash_table_lookup(group_map, &leader);
47 if (self == NULL) {
48 self = g_slice_new(ObGroup);
49 self->leader = leader;
50 self->members = NULL;
51 g_hash_table_insert(group_map, &self->leader, self);
54 self->members = g_slist_append(self->members, client);
56 return self;
59 void group_remove(ObGroup *self, ObClient *client)
61 self->members = g_slist_remove(self->members, client);
62 if (self->members == NULL) {
63 g_hash_table_remove(group_map, &self->leader);
64 g_slice_free(ObGroup, self);