1 /* Copyright (c) 2012, Bastien Dejean
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <xcb/xcb_icccm.h>
30 #include <xcb/randr.h>
31 #include <xcb/xcb_event.h>
34 #define MISSING_VALUE "N/A"
35 #define MAX_WM_STATES 4
55 WM_FLAG_MODAL = 1 << 0,
56 WM_FLAG_STICKY = 1 << 1,
57 WM_FLAG_MAXIMIZED_VERT = 1 << 2,
58 WM_FLAG_MAXIMIZED_HORZ = 1 << 3,
59 WM_FLAG_SHADED = 1 << 4,
60 WM_FLAG_SKIP_TASKBAR = 1 << 5,
61 WM_FLAG_SKIP_PAGER = 1 << 6,
62 WM_FLAG_HIDDEN = 1 << 7,
63 WM_FLAG_FULLSCREEN = 1 << 8,
64 WM_FLAG_ABOVE = 1 << 9,
65 WM_FLAG_BELOW = 1 << 10,
66 WM_FLAG_DEMANDS_ATTENTION = 1 << 11,
109 HANDLE_LEFT = 1 << 0,
111 HANDLE_RIGHT = 1 << 2,
112 HANDLE_BOTTOM = 1 << 3,
113 HANDLE_TOP_LEFT = HANDLE_TOP | HANDLE_LEFT,
114 HANDLE_TOP_RIGHT = HANDLE_TOP | HANDLE_RIGHT,
115 HANDLE_BOTTOM_RIGHT = HANDLE_BOTTOM | HANDLE_RIGHT,
116 HANDLE_BOTTOM_LEFT = HANDLE_BOTTOM | HANDLE_LEFT
142 option_bool_t automatic;
143 option_bool_t focused;
146 option_bool_t window;
148 option_bool_t pseudo_tiled;
149 option_bool_t floating;
150 option_bool_t fullscreen;
151 option_bool_t locked;
152 option_bool_t sticky;
153 option_bool_t private;
154 option_bool_t urgent;
155 option_bool_t same_class;
157 option_bool_t normal;
162 option_bool_t occupied;
163 option_bool_t focused;
164 option_bool_t urgent;
169 option_bool_t occupied;
170 option_bool_t focused;
173 typedef struct icccm_props_t icccm_props_t;
174 struct icccm_props_t {
180 char class_name[3 * SMALEN / 2];
181 char instance_name[3 * SMALEN / 2];
182 unsigned int border_width;
185 client_state_t state;
186 client_state_t last_state;
188 stack_layer_t last_layer;
189 xcb_rectangle_t floating_rectangle;
190 xcb_rectangle_t tiled_rectangle;
191 xcb_size_hints_t size_hints;
192 icccm_props_t icccm_props;
196 typedef struct presel_t presel_t;
199 direction_t split_dir;
200 xcb_window_t feedback;
203 typedef struct node_t node_t;
206 split_type_t split_type;
210 xcb_rectangle_t rectangle;
216 node_t *second_child;
221 typedef struct padding_t padding_t;
229 typedef struct desktop_t desktop_t;
240 unsigned int border_width;
243 typedef struct monitor_t monitor_t;
247 xcb_randr_output_t randr_id;
251 unsigned int sticky_count;
253 unsigned int border_width;
254 xcb_rectangle_t rectangle;
256 desktop_t *desk_head;
257 desktop_t *desk_tail;
268 typedef struct history_t history_t;
276 typedef struct stacking_list_t stacking_list_t;
277 struct stacking_list_t {
279 stacking_list_t *prev;
280 stacking_list_t *next;
283 typedef struct subscriber_list_t subscriber_list_t;
284 struct subscriber_list_t {
288 subscriber_list_t *prev;
289 subscriber_list_t *next;
292 typedef struct rule_t rule_t;
294 char class_name[MAXLEN];
295 char instance_name[MAXLEN];
303 char class_name[3 * SMALEN / 2];
304 char instance_name[3 * SMALEN / 2];
305 char monitor_desc[MAXLEN];
306 char desktop_desc[MAXLEN];
307 char node_desc[MAXLEN];
308 char split_dir[SMALEN];
310 stack_layer_t *layer;
311 client_state_t *state;
320 } rule_consequence_t;
322 typedef struct pending_rule_t pending_rule_t;
323 struct pending_rule_t {
326 rule_consequence_t *csq;
327 pending_rule_t *prev;
328 pending_rule_t *next;