1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 unmanaged.c for the Openbox window manager
4 Copyright (c) 2010 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 "unmanaged.h"
20 #include "composite.h"
22 #include "obt/display.h"
28 ObStackingLayer layer;
34 static GSList *unmanaged_list = NULL;
36 ObUnmanaged* unmanaged_new(Window w)
42 if (w == composite_overlay)
44 if (!XGetWindowAttributes(obt_display, w, &at))
47 self = window_new(OB_WINDOW_CLASS_UNMANAGED, ObUnmanaged);
49 self->layer = OB_STACKING_LAYER_INVALID;
50 self->depth = at.depth;
51 self->alpha = 0xffffffff;
52 self->output = at.class != InputOnly;
54 self->super.mapped = at.map_state != IsUnmapped;
56 XSelectInput(obt_display, self->window, PropertyChangeMask);
58 XShapeSelectInput(obt_display, self->window, ShapeNotifyMask);
61 if (self->output) unmanaged_update_opacity(self);
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),
67 (self->output ? &self->window : NULL),
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);
79 void unmanaged_destroy(ObUnmanaged *self)
81 XSelectInput(obt_display, self->window, NoEventMask);
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));
90 void unmanaged_destroy_all(void)
92 while (unmanaged_list)
93 unmanaged_destroy(unmanaged_list->data);
96 void unmanaged_update_opacity(ObUnmanaged *self)
98 if (!OBT_PROP_GET32(self->window, NET_WM_WINDOW_OPACITY, CARDINAL,
100 self->alpha = 0xffffffff;