]> git.lizzy.rs Git - bspwm.git/blob - types.h
Keep the real wm name on the supporting window
[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     CLIENT_TYPE_ALL,
41     CLIENT_TYPE_FLOATING,
42     CLIENT_TYPE_TILED
43 } client_type_t;
44
45 typedef enum {
46     CLIENT_CLASS_ALL,
47     CLIENT_CLASS_EQUAL,
48     CLIENT_CLASS_DIFFER
49 } client_class_t;
50
51 typedef enum {
52     CLIENT_MODE_ALL,
53     CLIENT_MODE_AUTOMATIC,
54     CLIENT_MODE_MANUAL
55 } client_mode_t;
56
57 typedef enum {
58     CLIENT_URGENCY_ALL,
59     CLIENT_URGENCY_ON,
60     CLIENT_URGENCY_OFF
61 } client_urgency_t;
62
63 typedef struct {
64     client_type_t type;
65     client_class_t class;
66     client_mode_t mode;
67     client_urgency_t urgency;
68 } client_select_t;
69
70 typedef enum {
71     ALTER_NONE,
72     ALTER_TOGGLE,
73     ALTER_SET
74 } state_alter_t;
75
76 typedef enum {
77     DESKTOP_STATUS_ALL,
78     DESKTOP_STATUS_FREE,
79     DESKTOP_STATUS_OCCUPIED
80 } desktop_status_t;
81
82 typedef enum {
83     DESKTOP_URGENCY_ALL,
84     DESKTOP_URGENCY_ON,
85     DESKTOP_URGENCY_OFF
86 } desktop_urgency_t;
87
88 typedef struct {
89     desktop_status_t status;
90     desktop_urgency_t urgency;
91 } desktop_select_t;
92
93 typedef enum {
94     CYCLE_NEXT,
95     CYCLE_PREV
96 } cycle_dir_t;
97
98 typedef enum {
99     CIRCULATE_FORWARD,
100     CIRCULATE_BACKWARD
101 } circulate_dir_t;
102
103 typedef enum {
104     FLIP_HORIZONTAL,
105     FLIP_VERTICAL
106 } flip_t;
107
108 typedef enum {
109     DIR_RIGHT,
110     DIR_DOWN,
111     DIR_LEFT,
112     DIR_UP
113 } direction_t;
114
115 typedef enum {
116     CORNER_TOP_LEFT,
117     CORNER_TOP_RIGHT,
118     CORNER_BOTTOM_RIGHT,
119     CORNER_BOTTOM_LEFT
120 } corner_t;
121
122 typedef enum {
123     SIDE_LEFT,
124     SIDE_TOP,
125     SIDE_RIGHT,
126     SIDE_BOTTOM
127 } side_t;
128
129 typedef enum {
130     ACTION_NONE,
131     ACTION_FOCUS,
132     ACTION_MOVE,
133     ACTION_RESIZE_SIDE,
134     ACTION_RESIZE_CORNER
135 } pointer_action_t;
136
137 typedef struct {
138     xcb_window_t window;
139     char class_name[MAXLEN];
140     unsigned int border_width;
141     bool floating;
142     bool transient;  /* transient window are always floating */
143     bool fullscreen;
144     bool locked;     /* protects window from being closed */
145     bool urgent;
146     xcb_rectangle_t floating_rectangle;
147     xcb_rectangle_t tiled_rectangle;
148 } client_t;
149
150 typedef struct node_t node_t;
151 struct node_t {
152     split_type_t split_type;
153     double split_ratio;
154     split_mode_t split_mode;
155     direction_t split_dir;
156     int birth_rotation;
157     xcb_rectangle_t rectangle;
158     bool vacant;          /* vacant nodes only hold floating clients */
159     node_t *first_child;
160     node_t *second_child;
161     node_t *parent;
162     client_t *client;     /* NULL except for leaves */
163 };
164
165 typedef struct node_list_t node_list_t;
166 struct node_list_t {
167     node_t *node;
168     bool latest;          /* used for z-ordering tiled windows */
169     node_list_t *prev;
170     node_list_t *next;
171 };
172
173 typedef struct {
174     node_list_t *head;
175     node_list_t *tail;
176 } focus_history_t;
177
178 typedef struct desktop_t desktop_t;
179 struct desktop_t {
180     char name[MAXLEN];
181     layout_t layout;
182     node_t *root;
183     node_t *focus;
184     focus_history_t *history;
185     desktop_t *prev;
186     desktop_t *next;
187 };
188
189 typedef struct monitor_t monitor_t;
190 struct monitor_t {
191     char name[MAXLEN];
192     xcb_randr_output_t id;
193     xcb_rectangle_t rectangle;
194     bool wired;
195     int top_padding;
196     int right_padding;
197     int bottom_padding;
198     int left_padding;
199     desktop_t *desk;
200     desktop_t *last_desk;
201     desktop_t *desk_head;
202     desktop_t *desk_tail;
203     monitor_t *prev;
204     monitor_t *next;
205 };
206
207 typedef struct {
208     monitor_t *monitor;
209     desktop_t *desktop;
210     node_t *node;
211 } coordinates_t;
212
213 typedef struct {
214     char name[MAXLEN];
215 } rule_cause_t;
216
217 typedef struct {
218     bool floating;
219     bool follow;
220     bool focus;
221     char desc[MAXLEN];
222 } rule_effect_t;
223
224 typedef struct rule_t rule_t;
225 struct rule_t {
226     unsigned int uid;
227     rule_cause_t cause;
228     rule_effect_t effect;
229     rule_t *prev;
230     rule_t *next;
231 };
232
233 typedef struct {
234     xcb_point_t position;
235     pointer_action_t action;
236     xcb_rectangle_t rectangle;
237     node_t *vertical_fence;
238     node_t *horizontal_fence;
239     monitor_t *monitor;
240     desktop_t *desktop;
241     node_t *node;
242     client_t *client;
243     xcb_window_t window;
244     bool is_tiled;
245     double vertical_ratio;
246     double horizontal_ratio;
247     corner_t corner;
248     side_t side;
249 } pointer_state_t;
250
251 typedef struct {
252     node_t *fence;
253     unsigned int distance;
254 } fence_distance_t;
255
256 node_t *make_node(void);
257 monitor_t *make_monitor(xcb_rectangle_t *);
258 monitor_t *find_monitor(char *);
259 monitor_t *get_monitor_by_id(xcb_randr_output_t);
260 monitor_t *add_monitor(xcb_rectangle_t *);
261 void remove_monitor(monitor_t *);
262 void merge_monitors(monitor_t *, monitor_t *);
263 desktop_t *make_desktop(const char *);
264 void insert_desktop(monitor_t *, desktop_t *);
265 void add_desktop(monitor_t *, desktop_t *);
266 void empty_desktop(desktop_t *);
267 void unlink_desktop(monitor_t *, desktop_t *);
268 void remove_desktop(monitor_t *, desktop_t *);
269 void transfer_desktop(monitor_t *, monitor_t *, desktop_t *);
270 rule_t *make_rule(void);
271 pointer_state_t *make_pointer_state(void);
272 client_t *make_client(xcb_window_t);
273 focus_history_t *make_focus_history(void);
274 node_list_t *make_node_list(void);
275 void history_add(focus_history_t *, node_t *);
276 void history_remove(focus_history_t *, node_t *);
277 void empty_history(focus_history_t *);
278 node_t *history_get(focus_history_t *, int);
279 node_t *history_last(focus_history_t *, node_t *, client_select_t);
280 int history_rank(focus_history_t *, node_t *);
281
282 #endif