]> git.lizzy.rs Git - bspwm.git/blob - types.h
4dd959cc7bcca0cbcdab84b3b13d96d82b4281f6
[bspwm.git] / types.h
1 #ifndef _TYPES_H
2 #define _TYPES_H
3
4 #include <stdbool.h>
5 #include <xcb/xcb.h>
6 #include <xcb/randr.h>
7 #include <xcb/xcb_event.h>
8 #include "helpers.h"
9
10 #define DEFAULT_DESK_NAME    "Desktop"
11 #define DEFAULT_MON_NAME     "Monitor"
12 #define MISSING_VALUE        "N/A"
13
14 typedef enum {
15     TYPE_HORIZONTAL,
16     TYPE_VERTICAL
17 } split_type_t;
18
19 typedef enum {
20     MODE_AUTOMATIC,
21     MODE_MANUAL
22 } split_mode_t;
23
24 typedef enum {
25     LAYOUT_TILED,
26     LAYOUT_MONOCLE
27 } layout_t;
28
29 typedef enum {
30     MOVE_PULL,
31     MOVE_PUSH
32 } fence_move_t;
33
34 typedef enum {
35     CHANGE_INCREASE,
36     CHANGE_DECREASE
37 } value_change_t;
38
39 typedef enum {
40     LIST_OPTION_VERBOSE,
41     LIST_OPTION_QUIET
42 } list_option_t;
43
44 typedef enum {
45     SEND_OPTION_FOLLOW,
46     SEND_OPTION_DONT_FOLLOW
47 } send_option_t;
48
49 typedef enum {
50     CLIENT_SKIP_NONE,
51     CLIENT_SKIP_FLOATING,
52     CLIENT_SKIP_TILED,
53     CLIENT_SKIP_CLASS_EQUAL,
54     CLIENT_SKIP_CLASS_DIFFER
55 } skip_client_t;
56
57 typedef enum {
58     DESKTOP_SKIP_NONE,
59     DESKTOP_SKIP_FREE,
60     DESKTOP_SKIP_OCCUPIED
61 } skip_desktop_t;
62
63 typedef enum {
64     CYCLE_NEXT,
65     CYCLE_PREV
66 } cycle_dir_t;
67
68 typedef enum {
69     NEAREST_OLDER,
70     NEAREST_NEWER
71 } nearest_arg_t;
72
73 typedef enum {
74     SWAP_BIGGEST,
75     SWAP_SMALLEST
76 } swap_arg_t;
77
78 typedef enum {
79     CIRCULATE_FORWARD,
80     CIRCULATE_BACKWARD
81 } circulate_dir_t;
82
83 typedef enum {
84     ROTATE_IDENTITY,
85     ROTATE_CLOCKWISE,
86     ROTATE_COUNTER_CLOCKWISE,
87     ROTATE_FULL_CYCLE
88 } rotate_t;
89
90 typedef enum {
91     FLIP_HORIZONTAL,
92     FLIP_VERTICAL
93 } flip_t;
94
95 typedef enum {
96     DIR_LEFT,
97     DIR_RIGHT,
98     DIR_UP,
99     DIR_DOWN
100 } direction_t;
101
102 typedef enum {
103     CORNER_TOP_LEFT,
104     CORNER_TOP_RIGHT,
105     CORNER_BOTTOM_LEFT,
106     CORNER_BOTTOM_RIGHT
107 } corner_t;
108
109 typedef enum {
110     SIDE_LEFT,
111     SIDE_TOP,
112     SIDE_RIGHT,
113     SIDE_BOTTOM
114 } side_t;
115
116 typedef enum {
117     ACTION_NONE,
118     ACTION_FOCUS,
119     ACTION_MOVE,
120     ACTION_RESIZE_SIDE,
121     ACTION_RESIZE_CORNER
122 } pointer_action_t;
123
124 typedef struct {
125     xcb_window_t window;
126     unsigned int uid;
127     char class_name[MAXLEN];
128     unsigned int border_width;
129     bool floating;
130     bool transient;  /* transient window are always floating */
131     bool fullscreen;
132     bool locked;     /* protects window from being closed */
133     bool urgent;
134     xcb_rectangle_t floating_rectangle;
135     xcb_rectangle_t tiled_rectangle;
136 } client_t;
137
138 typedef struct node_t node_t;
139 struct node_t {
140     split_type_t split_type;
141     double split_ratio;
142     rotate_t birth_rotation;
143     xcb_rectangle_t rectangle;
144     bool vacant;          /* vacant nodes only hold floating clients */
145     node_t *first_child;
146     node_t *second_child;
147     node_t *parent;
148     client_t *client;     /* NULL except for leaves */
149 };
150
151 typedef struct node_list_t node_list_t;
152 struct node_list_t {
153     node_t *node;
154     bool latest;          /* used for z-ordering tiled windows */
155     node_list_t *prev;
156     node_list_t *next;
157 };
158
159 typedef struct {
160     node_list_t *head;
161     node_list_t *tail;
162 } focus_history_t;
163
164 typedef struct desktop_t desktop_t;
165 struct desktop_t {
166     char name[MAXLEN];
167     layout_t layout;
168     node_t *root;
169     node_t *focus;
170     focus_history_t *history;
171     desktop_t *prev;
172     desktop_t *next;
173 };
174
175 typedef struct monitor_t monitor_t;
176 struct monitor_t {
177     char name[MAXLEN];
178     xcb_randr_output_t id;
179     xcb_rectangle_t rectangle;
180     bool wired;
181     int top_padding;
182     int right_padding;
183     int bottom_padding;
184     int left_padding;
185     desktop_t *desk;
186     desktop_t *last_desk;
187     desktop_t *desk_head;
188     desktop_t *desk_tail;
189     monitor_t *prev;
190     monitor_t *next;
191 };
192
193 typedef struct {
194     char name[MAXLEN];
195 } rule_cause_t;
196
197 typedef struct {
198     bool floating;
199     bool follow;
200     monitor_t *monitor;
201     desktop_t *desktop;
202 } rule_effect_t;
203
204 typedef struct rule_t rule_t;
205 struct rule_t {
206     unsigned int uid;
207     rule_cause_t cause;
208     rule_effect_t effect;
209     rule_t *prev;
210     rule_t *next;
211 };
212
213 typedef struct {
214     node_t *node;
215     desktop_t *desktop;
216     monitor_t *monitor;
217 } window_location_t;
218
219 typedef struct {
220     desktop_t *desktop;
221     monitor_t *monitor;
222 } desktop_location_t;
223
224 typedef struct {
225     xcb_point_t position;
226     pointer_action_t action;
227     xcb_rectangle_t rectangle;
228     node_t *vertical_fence;
229     node_t *horizontal_fence;
230     monitor_t *monitor;
231     desktop_t *desktop;
232     node_t *node;
233     client_t *client;
234     xcb_window_t window;
235     bool is_tiled;
236     double vertical_ratio;
237     double horizontal_ratio;
238     corner_t corner;
239     side_t side;
240 } pointer_state_t;
241
242 typedef struct {
243     node_t *fence;
244     unsigned int distance;
245 } fence_distance_t;
246
247 node_t *make_node(void);
248 monitor_t *make_monitor(xcb_rectangle_t *);
249 monitor_t *find_monitor(char *);
250 monitor_t *get_monitor_by_id(xcb_randr_output_t);
251 monitor_t *add_monitor(xcb_rectangle_t *);
252 void remove_monitor(monitor_t *);
253 void transfer_desktops(monitor_t *, monitor_t *);
254 desktop_t *make_desktop(const char *);
255 void add_desktop(monitor_t *, char *);
256 void empty_desktop(desktop_t *);
257 void remove_desktop(monitor_t *, desktop_t *);
258 rule_t *make_rule(void);
259 pointer_state_t *make_pointer_state(void);
260 client_t *make_client(xcb_window_t);
261 focus_history_t *make_focus_history(void);
262 node_list_t *make_node_list(void);
263 void history_add(focus_history_t *, node_t *);
264 void history_remove(focus_history_t *, node_t *);
265 void empty_history(focus_history_t *);
266 node_t *history_get(focus_history_t *, int);
267
268 #endif