]> icculus.org git repositories - dana/openbox.git/blob - openbox/unmanaged.c
make the root background color a config option, and add name_window_pixmap() helper...
[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 #include "obt/prop.h"
24
25 struct _ObUnmanaged {
26     ObWindow super;
27     Window window;
28     ObStackingLayer layer;
29     gint depth;
30     guint32 alpha;
31     gboolean output;
32 };
33
34 static GSList *unmanaged_list = NULL;
35
36 ObUnmanaged* unmanaged_new(Window w)
37 {
38     XWindowAttributes at;
39     ObUnmanaged *self;
40     Rect r;
41
42     if (w == composite_overlay)
43         return NULL;
44     if (!XGetWindowAttributes(obt_display, w, &at))
45         return NULL;
46
47     self = window_new(OB_WINDOW_CLASS_UNMANAGED, ObUnmanaged);
48     self->window = w;
49     self->layer = OB_STACKING_LAYER_INVALID;
50     self->depth = at.depth;
51     self->alpha = 0xffffffff;
52     self->output = at.class != InputOnly;
53
54     self->super.mapped = at.map_state != IsUnmapped;
55
56     XSelectInput(obt_display, self->window, PropertyChangeMask);
57 #ifdef SHAPE
58     XShapeSelectInput(obt_display, self->window, ShapeNotifyMask);
59 #endif
60
61     if (self->output) unmanaged_update_opacity(self);
62
63     RECT_SET(r, at.x, at.y, at.width, at.height);
64     window_set_top_area(UNMANAGED_AS_WINDOW(self), &r, at.border_width);
65     window_set_abstract(UNMANAGED_AS_WINDOW(self),
66                         &self->window,
67                         (self->output ? &self->window : NULL),
68                         &self->layer,
69                         &self->depth,
70                         &self->alpha);
71
72     window_add(&self->window, UNMANAGED_AS_WINDOW(self));
73     stacking_add(UNMANAGED_AS_WINDOW(self));
74     unmanaged_list = g_slist_prepend(unmanaged_list, self);
75
76     return self;
77 }
78
79 void unmanaged_destroy(ObUnmanaged *self)
80 {
81     XSelectInput(obt_display, self->window, NoEventMask);
82
83     window_cleanup(UNMANAGED_AS_WINDOW(self));
84     unmanaged_list = g_slist_remove(unmanaged_list, self);
85     stacking_remove(UNMANAGED_AS_WINDOW(self));
86     window_remove(self->window);
87     window_free(UNMANAGED_AS_WINDOW(self));
88 }
89
90 void unmanaged_destroy_all(void)
91 {
92     while (unmanaged_list)
93         unmanaged_destroy(unmanaged_list->data);
94 }
95
96 void unmanaged_update_opacity(ObUnmanaged *self)
97 {
98     if (!OBT_PROP_GET32(self->window, NET_WM_WINDOW_OPACITY, CARDINAL,
99                         &self->alpha))
100         self->alpha = 0xffffffff;
101 }