]> icculus.org git repositories - dana/openbox.git/blob - openbox/unmanaged.c
Clean up the composite stuff a bunch.
[dana/openbox.git] / openbox / unmanaged.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    unmanaged.c for the Openbox window manager
4    Copyright (c) 2010        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 "unmanaged.h"
20 #include "composite.h"
21 #include "window.h"
22 #include "obt/display.h"
23
24 struct _ObUnmanaged {
25     ObWindow super;
26     Window win;
27     ObStackingLayer layer;
28     gint depth;
29
30 };
31
32 static GSList *unmanaged_list = NULL;
33
34 ObUnmanaged* unmanaged_new(Window w)
35 {
36     XWindowAttributes at;
37     ObUnmanaged *self;
38
39     if (w == composite_overlay)
40         return NULL;
41     if (!XGetWindowAttributes(obt_display, w, &at))
42         return NULL;        
43     if (at.class == InputOnly)
44         return NULL;
45
46     self = window_new(OB_WINDOW_CLASS_UNMANAGED, ObUnmanaged);
47     self->win = w;
48     self->layer = OB_STACKING_LAYER_ALL;
49     self->depth = at.depth;
50     
51     window_set_abstract(UNMANAGED_AS_WINDOW(self),
52                         &self->win,
53                         &self->layer,
54                         &self->depth);
55
56     window_add(&self->win, UNMANAGED_AS_WINDOW(self));
57     stacking_add(UNMANAGED_AS_WINDOW(self));
58     unmanaged_list = g_slist_prepend(unmanaged_list, self);
59
60     return self;
61 }
62
63 void unmanaged_destroy(ObUnmanaged *self)
64 {
65     window_cleanup(UNMANAGED_AS_WINDOW(self));
66     unmanaged_list = g_slist_remove(unmanaged_list, self);
67     stacking_remove(UNMANAGED_AS_WINDOW(self));
68     window_remove(self->win);
69     window_free(UNMANAGED_AS_WINDOW(self));
70 }
71
72 void unmanaged_destroy_all(void)
73 {
74     while (unmanaged_list)
75         unmanaged_destroy(unmanaged_list->data);
76 }