]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/window.c
Make ObPrompt windows get managed as clients, and make them able to reconfigure as...
[mikachu/openbox.git] / 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 #include "prompt.h"
26
27 GHashTable *window_map;
28
29 static guint window_hash(Window *w) { return *w; }
30 static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
31
32 void window_startup(gboolean reconfig)
33 {
34     if (reconfig) return;
35
36     window_map = g_hash_table_new((GHashFunc)window_hash,
37                                   (GEqualFunc)window_comp);
38 }
39
40 void window_shutdown(gboolean reconfig)
41 {
42     if (reconfig) return;
43
44     g_hash_table_destroy(window_map);
45 }
46
47 Window window_top(ObWindow *self)
48 {
49     switch (self->type) {
50     case Window_Menu:
51         return ((ObMenuFrame*)self)->window;
52     case Window_Dock:
53         return ((ObDock*)self)->frame;
54     case Window_DockApp:
55         /* not to be used for stacking */
56         g_assert_not_reached();
57         break;
58     case Window_Client:
59         return ((ObClient*)self)->frame->window;
60     case Window_Internal:
61         return ((InternalWindow*)self)->window;
62     case Window_Prompt:
63         return ((ObPrompt*)self)->super.window;
64     }
65     g_assert_not_reached();
66     return None;
67 }
68
69 ObStackingLayer window_layer(ObWindow *self)
70 {
71     switch (self->type) {
72     case Window_Menu:
73         return OB_STACKING_LAYER_INTERNAL;
74     case Window_Dock:
75         return config_dock_layer;
76     case Window_DockApp:
77         /* not to be used for stacking */
78         g_assert_not_reached();
79         break;
80     case Window_Client:
81         return ((ObClient*)self)->layer;
82     case Window_Internal:
83     case Window_Prompt:
84         return OB_STACKING_LAYER_INTERNAL;
85     }
86     g_assert_not_reached();
87     return None;
88 }