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