]> git.lizzy.rs Git - bspwm.git/blob - src/types.h
a04fc8406ff3a1891cf4ce5b4f4ebe6f914f10fc
[bspwm.git] / src / types.h
1 /* Copyright (c) 2012, Bastien Dejean
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
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.
12  *
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.
23  */
24
25 #ifndef BSPWM_TYPES_H
26 #define BSPWM_TYPES_H
27 #include <stdbool.h>
28 #include <xcb/xcb.h>
29 #include <xcb/xcb_icccm.h>
30 #include <xcb/randr.h>
31 #include <xcb/xcb_event.h>
32 #include "helpers.h"
33
34 #define MISSING_VALUE        "N/A"
35 #define MAX_WM_STATES        4
36
37 typedef enum {
38         TYPE_HORIZONTAL,
39         TYPE_VERTICAL
40 } split_type_t;
41
42 typedef enum {
43         MODE_AUTOMATIC,
44         MODE_MANUAL
45 } split_mode_t;
46
47 typedef enum {
48         SCHEME_LONGEST_SIDE,
49         SCHEME_ALTERNATE,
50         SCHEME_SPIRAL
51 } automatic_scheme_t;
52
53 typedef enum {
54         STATE_TILED,
55         STATE_PSEUDO_TILED,
56         STATE_FLOATING,
57         STATE_FULLSCREEN
58 } client_state_t;
59
60 typedef enum {
61         WM_FLAG_MODAL = 1 << 0,
62         WM_FLAG_STICKY = 1 << 1,
63         WM_FLAG_MAXIMIZED_VERT = 1 << 2,
64         WM_FLAG_MAXIMIZED_HORZ = 1 << 3,
65         WM_FLAG_SHADED = 1 << 4,
66         WM_FLAG_SKIP_TASKBAR = 1 << 5,
67         WM_FLAG_SKIP_PAGER = 1 << 6,
68         WM_FLAG_HIDDEN = 1 << 7,
69         WM_FLAG_FULLSCREEN = 1 << 8,
70         WM_FLAG_ABOVE = 1 << 9,
71         WM_FLAG_BELOW = 1 << 10,
72         WM_FLAG_DEMANDS_ATTENTION = 1 << 11,
73 } wm_flags_t;
74
75 typedef enum {
76         LAYER_BELOW,
77         LAYER_NORMAL,
78         LAYER_ABOVE
79 } stack_layer_t;
80
81 typedef enum {
82         OPTION_NONE,
83         OPTION_TRUE,
84         OPTION_FALSE
85 } option_bool_t;
86
87 typedef enum {
88         ALTER_TOGGLE,
89         ALTER_SET
90 } alter_state_t;
91
92 typedef enum {
93         CYCLE_NEXT,
94         CYCLE_PREV
95 } cycle_dir_t;
96
97 typedef enum {
98         CIRCULATE_FORWARD,
99         CIRCULATE_BACKWARD
100 } circulate_dir_t;
101
102 typedef enum {
103         HISTORY_OLDER,
104         HISTORY_NEWER
105 } history_dir_t;
106
107 typedef enum {
108         DIR_NORTH,
109         DIR_WEST,
110         DIR_SOUTH,
111         DIR_EAST
112 } direction_t;
113
114 typedef enum {
115         HANDLE_LEFT = 1 << 0,
116         HANDLE_TOP = 1 << 1,
117         HANDLE_RIGHT = 1 << 2,
118         HANDLE_BOTTOM = 1 << 3,
119         HANDLE_TOP_LEFT = HANDLE_TOP | HANDLE_LEFT,
120         HANDLE_TOP_RIGHT = HANDLE_TOP | HANDLE_RIGHT,
121         HANDLE_BOTTOM_RIGHT = HANDLE_BOTTOM | HANDLE_RIGHT,
122         HANDLE_BOTTOM_LEFT = HANDLE_BOTTOM | HANDLE_LEFT
123 } resize_handle_t;
124
125 typedef enum {
126         ACTION_NONE,
127         ACTION_FOCUS,
128         ACTION_MOVE,
129         ACTION_RESIZE_SIDE,
130         ACTION_RESIZE_CORNER
131 } pointer_action_t;
132
133 typedef enum {
134         LAYOUT_TILED,
135         LAYOUT_MONOCLE
136 } layout_t;
137
138 typedef enum {
139         FLIP_HORIZONTAL,
140         FLIP_VERTICAL
141 } flip_t;
142
143 typedef enum {
144         FIRST_CHILD,
145         SECOND_CHILD
146 } child_polarity_t;
147
148 typedef enum {
149         TIGHTNESS_LOW,
150         TIGHTNESS_HIGH,
151 } tightness_t;
152
153 typedef enum {
154         AREA_BIGGEST,
155         AREA_SMALLEST,
156 } area_peak_t;
157
158 typedef enum {
159         STATE_TRANSITION_ENTER = 1 << 0,
160         STATE_TRANSITION_EXIT = 1 << 1,
161 } state_transition_t;
162
163 typedef struct {
164         option_bool_t automatic;
165         option_bool_t focused;
166         option_bool_t active;
167         option_bool_t local;
168         option_bool_t leaf;
169         option_bool_t window;
170         option_bool_t tiled;
171         option_bool_t pseudo_tiled;
172         option_bool_t floating;
173         option_bool_t fullscreen;
174         option_bool_t hidden;
175         option_bool_t sticky;
176         option_bool_t private;
177         option_bool_t locked;
178         option_bool_t marked;
179         option_bool_t urgent;
180         option_bool_t same_class;
181         option_bool_t descendant_of;
182         option_bool_t ancestor_of;
183         option_bool_t below;
184         option_bool_t normal;
185         option_bool_t above;
186 } node_select_t;
187
188 typedef struct {
189         option_bool_t occupied;
190         option_bool_t focused;
191         option_bool_t active;
192         option_bool_t urgent;
193         option_bool_t local;
194 } desktop_select_t;
195
196 typedef struct {
197         option_bool_t occupied;
198         option_bool_t focused;
199 } monitor_select_t;
200
201 typedef struct icccm_props_t icccm_props_t;
202 struct icccm_props_t {
203         bool take_focus;
204         bool input_hint;
205         bool delete_window;
206 };
207
208 typedef struct {
209         char class_name[3 * SMALEN / 2];
210         char instance_name[3 * SMALEN / 2];
211         unsigned int border_width;
212         bool urgent;
213         bool shown;
214         client_state_t state;
215         client_state_t last_state;
216         stack_layer_t layer;
217         stack_layer_t last_layer;
218         xcb_rectangle_t floating_rectangle;
219         xcb_rectangle_t tiled_rectangle;
220         xcb_size_hints_t size_hints;
221         icccm_props_t icccm_props;
222         wm_flags_t wm_flags;
223 } client_t;
224
225 typedef struct presel_t presel_t;
226 struct presel_t {
227         double split_ratio;
228         direction_t split_dir;
229         xcb_window_t feedback;
230 };
231
232 typedef struct constraints_t constraints_t;
233 struct constraints_t {
234         uint16_t min_width;
235         uint16_t min_height;
236 };
237
238 typedef struct node_t node_t;
239 struct node_t {
240         uint32_t id;
241         split_type_t split_type;
242         double split_ratio;
243         presel_t *presel;
244         xcb_rectangle_t rectangle;
245         constraints_t constraints;
246         bool vacant;
247         bool hidden;
248         bool sticky;
249         bool private;
250         bool locked;
251         bool marked;
252         node_t *first_child;
253         node_t *second_child;
254         node_t *parent;
255         client_t *client;
256 };
257
258 typedef struct padding_t padding_t;
259 struct padding_t {
260         int top;
261         int right;
262         int bottom;
263         int left;
264 };
265
266 typedef struct desktop_t desktop_t;
267 struct desktop_t {
268         char name[SMALEN];
269         uint32_t id;
270         layout_t layout;
271         node_t *root;
272         node_t *focus;
273         desktop_t *prev;
274         desktop_t *next;
275         padding_t padding;
276         int window_gap;
277         unsigned int border_width;
278 };
279
280 typedef struct monitor_t monitor_t;
281 struct monitor_t {
282         char name[SMALEN];
283         uint32_t id;
284         xcb_randr_output_t randr_id;
285         xcb_window_t root;
286         bool wired;
287         padding_t padding;
288         unsigned int sticky_count;
289         int window_gap;
290         unsigned int border_width;
291         xcb_rectangle_t rectangle;
292         desktop_t *desk;
293         desktop_t *desk_head;
294         desktop_t *desk_tail;
295         monitor_t *prev;
296         monitor_t *next;
297 };
298
299 typedef struct {
300         monitor_t *monitor;
301         desktop_t *desktop;
302         node_t *node;
303 } coordinates_t;
304
305 typedef struct history_t history_t;
306 struct history_t {
307         coordinates_t loc;
308         bool latest;
309         history_t *prev;
310         history_t *next;
311 };
312
313 typedef struct stacking_list_t stacking_list_t;
314 struct stacking_list_t {
315         node_t *node;
316         stacking_list_t *prev;
317         stacking_list_t *next;
318 };
319
320 typedef struct event_queue_t event_queue_t;
321 struct event_queue_t {
322         xcb_generic_event_t event;
323         event_queue_t *prev;
324         event_queue_t *next;
325 };
326
327 typedef struct subscriber_list_t subscriber_list_t;
328 struct subscriber_list_t {
329         FILE *stream;
330         char* fifo_path;
331         int field;
332         int count;
333         subscriber_list_t *prev;
334         subscriber_list_t *next;
335 };
336
337 typedef struct rule_t rule_t;
338 struct rule_t {
339         char class_name[MAXLEN];
340         char instance_name[MAXLEN];
341         char effect[MAXLEN];
342         bool one_shot;
343         rule_t *prev;
344         rule_t *next;
345 };
346
347 typedef struct {
348         char class_name[3 * SMALEN / 2];
349         char instance_name[3 * SMALEN / 2];
350         char monitor_desc[MAXLEN];
351         char desktop_desc[MAXLEN];
352         char node_desc[MAXLEN];
353         char split_dir[SMALEN];
354         double split_ratio;
355         stack_layer_t *layer;
356         client_state_t *state;
357         bool hidden;
358         bool sticky;
359         bool private;
360         bool locked;
361         bool marked;
362         bool center;
363         bool follow;
364         bool manage;
365         bool focus;
366         bool border;
367         xcb_rectangle_t *rect;
368 } rule_consequence_t;
369
370 typedef struct pending_rule_t pending_rule_t;
371 struct pending_rule_t {
372         int fd;
373         xcb_window_t win;
374         rule_consequence_t *csq;
375         event_queue_t *event_head;
376         event_queue_t *event_tail;
377         pending_rule_t *prev;
378         pending_rule_t *next;
379 };
380
381 #endif