]> Dogcows Code - chaz/openbox/blob - openbox/window.c
Merge branch 'backport' into work
[chaz/openbox] / openbox / window.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 window.c for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
5
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.
10
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.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "window.h"
20 #include "menuframe.h"
21 #include "config.h"
22 #include "dock.h"
23 #include "client.h"
24 #include "frame.h"
25
26 static GHashTable *window_map;
27
28 static guint window_hash(Window *w) { return *w; }
29 static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
30
31 void window_startup(gboolean reconfig)
32 {
33 if (reconfig) return;
34
35 window_map = g_hash_table_new((GHashFunc)window_hash,
36 (GEqualFunc)window_comp);
37 }
38
39 void window_shutdown(gboolean reconfig)
40 {
41 if (reconfig) return;
42
43 g_hash_table_destroy(window_map);
44 }
45
46 Window window_top(ObWindow *self)
47 {
48 switch (self->type) {
49 case OB_WINDOW_CLASS_MENUFRAME:
50 return WINDOW_AS_MENUFRAME(self)->window;
51 case OB_WINDOW_CLASS_DOCK:
52 return WINDOW_AS_DOCK(self)->frame;
53 case OB_WINDOW_CLASS_CLIENT:
54 return WINDOW_AS_CLIENT(self)->frame->window;
55 case OB_WINDOW_CLASS_INTERNAL:
56 return WINDOW_AS_INTERNAL(self)->window;
57 }
58 g_assert_not_reached();
59 return None;
60 }
61
62 ObStackingLayer window_layer(ObWindow *self)
63 {
64 switch (self->type) {
65 case OB_WINDOW_CLASS_DOCK:
66 return config_dock_layer;
67 case OB_WINDOW_CLASS_CLIENT:
68 return ((ObClient*)self)->layer;
69 case OB_WINDOW_CLASS_MENUFRAME:
70 case OB_WINDOW_CLASS_INTERNAL:
71 return OB_STACKING_LAYER_INTERNAL;
72 }
73 g_assert_not_reached();
74 return None;
75 }
76
77 ObWindow* window_find(Window xwin)
78 {
79 return g_hash_table_lookup(window_map, &xwin);
80 }
81
82 void window_add(Window *xwin, ObWindow *win)
83 {
84 g_assert(xwin != NULL);
85 g_assert(win != NULL);
86 g_hash_table_insert(window_map, xwin, win);
87 }
88
89 void window_remove(Window xwin)
90 {
91 g_assert(xwin != None);
92 g_hash_table_remove(window_map, &xwin);
93 }
This page took 0.039646 seconds and 5 git commands to generate.