]> git.lizzy.rs Git - bspwm.git/blob - src/types.h
Add an option to *subscribe*: --count
[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         STATE_TILED,
49         STATE_PSEUDO_TILED,
50         STATE_FLOATING,
51         STATE_FULLSCREEN
52 } client_state_t;
53
54 typedef enum {
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,
67 } wm_flags_t;
68
69 typedef enum {
70         LAYER_BELOW,
71         LAYER_NORMAL,
72         LAYER_ABOVE
73 } stack_layer_t;
74
75 typedef enum {
76         OPTION_NONE,
77         OPTION_TRUE,
78         OPTION_FALSE
79 } option_bool_t;
80
81 typedef enum {
82         ALTER_TOGGLE,
83         ALTER_SET
84 } alter_state_t;
85
86 typedef enum {
87         CYCLE_NEXT,
88         CYCLE_PREV
89 } cycle_dir_t;
90
91 typedef enum {
92         CIRCULATE_FORWARD,
93         CIRCULATE_BACKWARD
94 } circulate_dir_t;
95
96 typedef enum {
97         HISTORY_OLDER,
98         HISTORY_NEWER
99 } history_dir_t;
100
101 typedef enum {
102         DIR_NORTH,
103         DIR_WEST,
104         DIR_SOUTH,
105         DIR_EAST
106 } direction_t;
107
108 typedef enum {
109         HANDLE_LEFT = 1 << 0,
110         HANDLE_TOP = 1 << 1,
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
117 } resize_handle_t;
118
119 typedef enum {
120         ACTION_NONE,
121         ACTION_FOCUS,
122         ACTION_MOVE,
123         ACTION_RESIZE_SIDE,
124         ACTION_RESIZE_CORNER
125 } pointer_action_t;
126
127 typedef enum {
128         LAYOUT_TILED,
129         LAYOUT_MONOCLE
130 } layout_t;
131
132 typedef enum {
133         FLIP_HORIZONTAL,
134         FLIP_VERTICAL
135 } flip_t;
136
137 typedef enum {
138         FIRST_CHILD,
139         SECOND_CHILD
140 } child_polarity_t;
141
142 typedef enum {
143         TIGHTNESS_LOW,
144         TIGHTNESS_HIGH,
145 } tightness_t;
146
147 typedef struct {
148         option_bool_t automatic;
149         option_bool_t focused;
150         option_bool_t local;
151         option_bool_t active;
152         option_bool_t leaf;
153         option_bool_t window;
154         option_bool_t tiled;
155         option_bool_t pseudo_tiled;
156         option_bool_t floating;
157         option_bool_t fullscreen;
158         option_bool_t hidden;
159         option_bool_t sticky;
160         option_bool_t private;
161         option_bool_t locked;
162         option_bool_t urgent;
163         option_bool_t same_class;
164         option_bool_t descendant_of;
165         option_bool_t ancestor_of;
166         option_bool_t below;
167         option_bool_t normal;
168         option_bool_t above;
169 } node_select_t;
170
171 typedef struct {
172         option_bool_t occupied;
173         option_bool_t focused;
174         option_bool_t urgent;
175         option_bool_t local;
176 } desktop_select_t;
177
178 typedef struct {
179         option_bool_t occupied;
180         option_bool_t focused;
181 } monitor_select_t;
182
183 typedef struct icccm_props_t icccm_props_t;
184 struct icccm_props_t {
185         bool take_focus;
186         bool input_hint;
187         bool delete_window;
188 };
189
190 typedef struct {
191         char class_name[3 * SMALEN / 2];
192         char instance_name[3 * SMALEN / 2];
193         unsigned int border_width;
194         bool urgent;
195         bool shown;
196         client_state_t state;
197         client_state_t last_state;
198         stack_layer_t layer;
199         stack_layer_t last_layer;
200         xcb_rectangle_t floating_rectangle;
201         xcb_rectangle_t tiled_rectangle;
202         xcb_size_hints_t size_hints;
203         icccm_props_t icccm_props;
204         wm_flags_t wm_flags;
205 } client_t;
206
207 typedef struct presel_t presel_t;
208 struct presel_t {
209         double split_ratio;
210         direction_t split_dir;
211         xcb_window_t feedback;
212 };
213
214 typedef struct constraints_t constraints_t;
215 struct constraints_t {
216         uint16_t min_width;
217         uint16_t min_height;
218 };
219
220 typedef struct node_t node_t;
221 struct node_t {
222         uint32_t id;
223         split_type_t split_type;
224         double split_ratio;
225         int birth_rotation;
226         presel_t *presel;
227         xcb_rectangle_t rectangle;
228         constraints_t constraints;
229         bool vacant;
230         bool hidden;
231         bool sticky;
232         bool private;
233         bool locked;
234         node_t *first_child;
235         node_t *second_child;
236         node_t *parent;
237         client_t *client;
238 };
239
240 typedef struct padding_t padding_t;
241 struct padding_t {
242         int top;
243         int right;
244         int bottom;
245         int left;
246 };
247
248 typedef struct desktop_t desktop_t;
249 struct desktop_t {
250         char name[SMALEN];
251         uint32_t id;
252         layout_t layout;
253         node_t *root;
254         node_t *focus;
255         desktop_t *prev;
256         desktop_t *next;
257         padding_t padding;
258         int window_gap;
259         unsigned int border_width;
260 };
261
262 typedef struct monitor_t monitor_t;
263 struct monitor_t {
264         char name[SMALEN];
265         uint32_t id;
266         xcb_randr_output_t randr_id;
267         xcb_window_t root;
268         bool wired;
269         padding_t padding;
270         unsigned int sticky_count;
271         int window_gap;
272         unsigned int border_width;
273         xcb_rectangle_t rectangle;
274         desktop_t *desk;
275         desktop_t *desk_head;
276         desktop_t *desk_tail;
277         monitor_t *prev;
278         monitor_t *next;
279 };
280
281 typedef struct {
282         monitor_t *monitor;
283         desktop_t *desktop;
284         node_t *node;
285 } coordinates_t;
286
287 typedef struct history_t history_t;
288 struct history_t {
289         coordinates_t loc;
290         bool latest;
291         history_t *prev;
292         history_t *next;
293 };
294
295 typedef struct stacking_list_t stacking_list_t;
296 struct stacking_list_t {
297         node_t *node;
298         stacking_list_t *prev;
299         stacking_list_t *next;
300 };
301
302 typedef struct subscriber_list_t subscriber_list_t;
303 struct subscriber_list_t {
304         int fd;
305         FILE *stream;
306         int field;
307         int count;
308         subscriber_list_t *prev;
309         subscriber_list_t *next;
310 };
311
312 typedef struct rule_t rule_t;
313 struct rule_t {
314         char class_name[MAXLEN];
315         char instance_name[MAXLEN];
316         char effect[MAXLEN];
317         bool one_shot;
318         rule_t *prev;
319         rule_t *next;
320 };
321
322 typedef struct {
323         char class_name[3 * SMALEN / 2];
324         char instance_name[3 * SMALEN / 2];
325         char monitor_desc[MAXLEN];
326         char desktop_desc[MAXLEN];
327         char node_desc[MAXLEN];
328         char split_dir[SMALEN];
329         double split_ratio;
330         stack_layer_t *layer;
331         client_state_t *state;
332         bool hidden;
333         bool sticky;
334         bool private;
335         bool locked;
336         bool center;
337         bool follow;
338         bool manage;
339         bool focus;
340         bool border;
341         xcb_rectangle_t *rect;
342 } rule_consequence_t;
343
344 typedef struct pending_rule_t pending_rule_t;
345 struct pending_rule_t {
346         int fd;
347         xcb_window_t win;
348         rule_consequence_t *csq;
349         pending_rule_t *prev;
350         pending_rule_t *next;
351 };
352
353 #endif