]> git.lizzy.rs Git - bspwm.git/blob - types.h
Just quit when the connection is closed
[bspwm.git] / types.h
1 /* * Copyright (c) 2012-2013 Bastien Dejean
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  *  * Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation and/or
11  * other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 ON
20  * 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
28 #include <stdbool.h>
29 #include <xcb/xcb.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_STATE            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     MOVE_PULL,
49     MOVE_PUSH
50 } fence_move_t;
51
52 typedef enum {
53     CHANGE_INCREASE,
54     CHANGE_DECREASE
55 } value_change_t;
56
57 typedef enum {
58     CLIENT_TYPE_ALL,
59     CLIENT_TYPE_FLOATING,
60     CLIENT_TYPE_TILED
61 } client_type_t;
62
63 typedef enum {
64     CLIENT_CLASS_ALL,
65     CLIENT_CLASS_EQUAL,
66     CLIENT_CLASS_DIFFER
67 } client_class_t;
68
69 typedef struct {
70     client_type_t type;
71     client_class_t class;
72     bool urgent;
73     bool manual;
74     bool local;
75 } client_select_t;
76
77 typedef enum {
78     ALTER_TOGGLE,
79     ALTER_SET
80 } alter_state_t;
81
82 typedef enum {
83     CYCLE_NEXT,
84     CYCLE_PREV
85 } cycle_dir_t;
86
87 typedef enum {
88     CIRCULATE_FORWARD,
89     CIRCULATE_BACKWARD
90 } circulate_dir_t;
91
92 typedef enum {
93     HISTORY_OLDER,
94     HISTORY_NEWER
95 } history_dir_t;
96
97 typedef enum {
98     DIR_RIGHT,
99     DIR_DOWN,
100     DIR_LEFT,
101     DIR_UP
102 } direction_t;
103
104 typedef enum {
105     CORNER_TOP_LEFT,
106     CORNER_TOP_RIGHT,
107     CORNER_BOTTOM_RIGHT,
108     CORNER_BOTTOM_LEFT
109 } corner_t;
110
111 typedef enum {
112     SIDE_LEFT,
113     SIDE_TOP,
114     SIDE_RIGHT,
115     SIDE_BOTTOM
116 } side_t;
117
118 typedef enum {
119     ACTION_NONE,
120     ACTION_FOCUS,
121     ACTION_MOVE,
122     ACTION_RESIZE_SIDE,
123     ACTION_RESIZE_CORNER
124 } pointer_action_t;
125
126 typedef enum {
127     LAYOUT_TILED,
128     LAYOUT_MONOCLE
129 } layout_t;
130
131 typedef enum {
132     FLIP_HORIZONTAL,
133     FLIP_VERTICAL
134 } flip_t;
135
136 typedef enum {
137     DESKTOP_STATUS_ALL,
138     DESKTOP_STATUS_FREE,
139     DESKTOP_STATUS_OCCUPIED
140 } desktop_status_t;
141
142 typedef enum {
143     DESKTOP_URGENCY_ALL,
144     DESKTOP_URGENCY_ON,
145     DESKTOP_URGENCY_OFF
146 } desktop_urgency_t;
147
148 typedef struct {
149     desktop_status_t status;
150     bool urgent;
151     bool local;
152 } desktop_select_t;
153
154 typedef struct {
155     xcb_window_t window;
156     char class_name[SMALEN];
157     unsigned int border_width;
158     bool floating;
159     bool transient;    /* transient window are always floating */
160     bool fullscreen;
161     bool locked;       /* protects window from being closed */
162     bool sticky;
163     bool urgent;
164     bool frame;
165     bool private;
166     bool icccm_focus;
167     xcb_rectangle_t floating_rectangle;
168     xcb_rectangle_t tiled_rectangle;
169     xcb_atom_t wm_state[MAX_STATE];
170     int num_states;
171 } client_t;
172
173 typedef struct node_t node_t;
174 struct node_t {
175     split_type_t split_type;
176     double split_ratio;
177     split_mode_t split_mode;
178     direction_t split_dir;
179     int birth_rotation;
180     xcb_rectangle_t rectangle;
181     bool vacant;          /* vacant nodes only hold floating clients */
182     int privacy_level;
183     node_t *first_child;
184     node_t *second_child;
185     node_t *parent;
186     client_t *client;     /* NULL except for leaves */
187 };
188
189 typedef struct desktop_t desktop_t;
190 struct desktop_t {
191     char name[SMALEN];
192     layout_t layout;
193     node_t *root;
194     node_t *focus;
195     desktop_t *prev;
196     desktop_t *next;
197     int window_gap;
198     unsigned int border_width;
199     bool floating;
200 };
201
202 typedef struct monitor_t monitor_t;
203 struct monitor_t {
204     char name[SMALEN];
205     xcb_randr_output_t id;
206     xcb_rectangle_t rectangle;
207     xcb_window_t root;
208     bool wired;
209     int top_padding;
210     int right_padding;
211     int bottom_padding;
212     int left_padding;
213     desktop_t *desk;
214     desktop_t *desk_head;
215     desktop_t *desk_tail;
216     monitor_t *prev;
217     monitor_t *next;
218     int num_sticky;
219 };
220
221 typedef struct {
222     monitor_t *monitor;
223     desktop_t *desktop;
224     node_t *node;
225 } coordinates_t;
226
227 typedef struct history_t history_t;
228 struct history_t {
229     coordinates_t loc;
230     bool latest;
231     history_t *prev;
232     history_t *next;
233 };
234
235 typedef struct stacking_list_t stacking_list_t;
236 struct stacking_list_t {
237     node_t *node;
238     stacking_list_t *prev;
239     stacking_list_t *next;
240 };
241
242 typedef struct subscriber_list_t subscriber_list_t;
243 struct subscriber_list_t {
244     int fd;
245     FILE *stream;
246     subscriber_list_t *prev;
247     subscriber_list_t *next;
248 };
249
250 typedef struct rule_t rule_t;
251 struct rule_t {
252     char cause[MAXLEN];
253     char effect[MAXLEN];
254     bool one_shot;
255     rule_t *prev;
256     rule_t *next;
257 };
258
259 typedef struct {
260     char class_name[SMALEN];
261     char instance_name[SMALEN];
262     char desktop_desc[MAXLEN];
263     char monitor_desc[MAXLEN];
264     bool floating;
265     bool transient;
266     bool fullscreen;
267     bool locked;
268     bool sticky;
269     bool private;
270     bool frame;
271     bool center;
272     bool lower;
273     bool follow;
274     bool manage;
275     bool focus;
276 } rule_consequence_t;
277
278 typedef struct pending_rule_t pending_rule_t;
279 struct pending_rule_t {
280     int fd;
281     xcb_window_t win;
282     rule_consequence_t *csq;
283     pending_rule_t *prev;
284     pending_rule_t *next;
285 };
286
287 typedef struct {
288     xcb_point_t position;
289     pointer_action_t action;
290     xcb_rectangle_t rectangle;
291     node_t *vertical_fence;
292     node_t *horizontal_fence;
293     monitor_t *monitor;
294     desktop_t *desktop;
295     node_t *node;
296     client_t *client;
297     xcb_window_t window;
298     bool is_tiled;
299     double vertical_ratio;
300     double horizontal_ratio;
301     corner_t corner;
302     side_t side;
303 } pointer_state_t;
304
305 typedef struct {
306     node_t *fence;
307     unsigned int distance;
308 } fence_distance_t;
309
310 #endif