]> git.lizzy.rs Git - bspwm.git/blob - src/types.h
bspwm: port rounded corners patch to latest version
[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         option_bool_t horizontal;
187         option_bool_t vertical;
188 } node_select_t;
189
190 typedef struct {
191         option_bool_t occupied;
192         option_bool_t focused;
193         option_bool_t active;
194         option_bool_t urgent;
195         option_bool_t local;
196         option_bool_t tiled;
197         option_bool_t monocle;
198         option_bool_t user_tiled;
199         option_bool_t user_monocle;
200 } desktop_select_t;
201
202 typedef struct {
203         option_bool_t occupied;
204         option_bool_t focused;
205 } monitor_select_t;
206
207 typedef struct icccm_props_t icccm_props_t;
208 struct icccm_props_t {
209         bool take_focus;
210         bool input_hint;
211         bool delete_window;
212 };
213
214 typedef struct {
215         char class_name[MAXLEN];
216         char instance_name[MAXLEN];
217         char name[MAXLEN];
218         unsigned int border_width;
219     unsigned int border_radius;
220     unsigned int drawn_border_radius;
221         bool urgent;
222         bool shown;
223     bool sets_own_shape;
224         client_state_t state;
225         client_state_t last_state;
226         stack_layer_t layer;
227         stack_layer_t last_layer;
228         xcb_rectangle_t floating_rectangle;
229         xcb_rectangle_t tiled_rectangle;
230         xcb_size_hints_t size_hints;
231         icccm_props_t icccm_props;
232         wm_flags_t wm_flags;
233 } client_t;
234
235 typedef struct presel_t presel_t;
236 struct presel_t {
237         double split_ratio;
238         direction_t split_dir;
239         xcb_window_t feedback;
240 };
241
242 typedef struct constraints_t constraints_t;
243 struct constraints_t {
244         uint16_t min_width;
245         uint16_t min_height;
246 };
247
248 typedef struct node_t node_t;
249 struct node_t {
250         uint32_t id;
251         split_type_t split_type;
252         double split_ratio;
253         presel_t *presel;
254         xcb_rectangle_t rectangle;
255         constraints_t constraints;
256         bool vacant;
257         bool hidden;
258         bool sticky;
259         bool private;
260         bool locked;
261         bool marked;
262         node_t *first_child;
263         node_t *second_child;
264         node_t *parent;
265         client_t *client;
266 };
267
268 typedef struct padding_t padding_t;
269 struct padding_t {
270         int top;
271         int right;
272         int bottom;
273         int left;
274 };
275
276 typedef struct desktop_t desktop_t;
277 struct desktop_t {
278         char name[SMALEN];
279         uint32_t id;
280         layout_t layout;
281         layout_t user_layout;
282         node_t *root;
283         node_t *focus;
284         desktop_t *prev;
285         desktop_t *next;
286         padding_t padding;
287         int window_gap;
288         unsigned int border_width;
289         unsigned int border_radius;
290 };
291
292 typedef struct monitor_t monitor_t;
293 struct monitor_t {
294         char name[SMALEN];
295         uint32_t id;
296         xcb_randr_output_t randr_id;
297         xcb_window_t root;
298         bool wired;
299         padding_t padding;
300         unsigned int sticky_count;
301         int window_gap;
302         unsigned int border_width;
303         unsigned int border_radius;
304         xcb_rectangle_t rectangle;
305         desktop_t *desk;
306         desktop_t *desk_head;
307         desktop_t *desk_tail;
308         monitor_t *prev;
309         monitor_t *next;
310 };
311
312 typedef struct {
313         monitor_t *monitor;
314         desktop_t *desktop;
315         node_t *node;
316 } coordinates_t;
317
318 typedef struct history_t history_t;
319 struct history_t {
320         coordinates_t loc;
321         bool latest;
322         history_t *prev;
323         history_t *next;
324 };
325
326 typedef struct stacking_list_t stacking_list_t;
327 struct stacking_list_t {
328         node_t *node;
329         stacking_list_t *prev;
330         stacking_list_t *next;
331 };
332
333 typedef struct event_queue_t event_queue_t;
334 struct event_queue_t {
335         xcb_generic_event_t event;
336         event_queue_t *prev;
337         event_queue_t *next;
338 };
339
340 typedef struct subscriber_list_t subscriber_list_t;
341 struct subscriber_list_t {
342         FILE *stream;
343         char* fifo_path;
344         int field;
345         int count;
346         subscriber_list_t *prev;
347         subscriber_list_t *next;
348 };
349
350 typedef struct rule_t rule_t;
351 struct rule_t {
352         char class_name[MAXLEN];
353         char instance_name[MAXLEN];
354         char name[MAXLEN];
355         char effect[MAXLEN];
356         bool one_shot;
357         rule_t *prev;
358         rule_t *next;
359 };
360
361 typedef struct {
362         char class_name[MAXLEN];
363         char instance_name[MAXLEN];
364         char name[MAXLEN];
365         char monitor_desc[MAXLEN];
366         char desktop_desc[MAXLEN];
367         char node_desc[MAXLEN];
368         direction_t *split_dir;
369         double split_ratio;
370         stack_layer_t *layer;
371         client_state_t *state;
372         bool hidden;
373         bool sticky;
374         bool private;
375         bool locked;
376         bool marked;
377         bool center;
378         bool follow;
379         bool manage;
380         bool focus;
381         bool border;
382         xcb_rectangle_t *rect;
383 } rule_consequence_t;
384
385 typedef struct pending_rule_t pending_rule_t;
386 struct pending_rule_t {
387         int fd;
388         xcb_window_t win;
389         rule_consequence_t *csq;
390         event_queue_t *event_head;
391         event_queue_t *event_tail;
392         pending_rule_t *prev;
393         pending_rule_t *next;
394 };
395
396 #endif