]> git.lizzy.rs Git - bspwm.git/blob - types.h
*Frames* are unnecessary
[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 private;
165     bool icccm_focus;
166     xcb_rectangle_t floating_rectangle;
167     xcb_rectangle_t tiled_rectangle;
168     xcb_atom_t wm_state[MAX_STATE];
169     int num_states;
170 } client_t;
171
172 typedef struct node_t node_t;
173 struct node_t {
174     split_type_t split_type;
175     double split_ratio;
176     split_mode_t split_mode;
177     direction_t split_dir;
178     int birth_rotation;
179     xcb_rectangle_t rectangle;
180     bool vacant;          /* vacant nodes only hold floating clients */
181     int privacy_level;
182     node_t *first_child;
183     node_t *second_child;
184     node_t *parent;
185     client_t *client;     /* NULL except for leaves */
186 };
187
188 typedef struct desktop_t desktop_t;
189 struct desktop_t {
190     char name[SMALEN];
191     layout_t layout;
192     node_t *root;
193     node_t *focus;
194     desktop_t *prev;
195     desktop_t *next;
196     int top_padding;
197     int right_padding;
198     int bottom_padding;
199     int left_padding;
200     int window_gap;
201     unsigned int border_width;
202     bool floating;
203 };
204
205 typedef struct monitor_t monitor_t;
206 struct monitor_t {
207     char name[SMALEN];
208     xcb_randr_output_t id;
209     xcb_rectangle_t rectangle;
210     xcb_window_t root;
211     bool wired;
212     desktop_t *desk;
213     desktop_t *desk_head;
214     desktop_t *desk_tail;
215     monitor_t *prev;
216     monitor_t *next;
217     int num_sticky;
218 };
219
220 typedef struct {
221     monitor_t *monitor;
222     desktop_t *desktop;
223     node_t *node;
224 } coordinates_t;
225
226 typedef struct history_t history_t;
227 struct history_t {
228     coordinates_t loc;
229     bool latest;
230     history_t *prev;
231     history_t *next;
232 };
233
234 typedef struct stacking_list_t stacking_list_t;
235 struct stacking_list_t {
236     node_t *node;
237     stacking_list_t *prev;
238     stacking_list_t *next;
239 };
240
241 typedef struct subscriber_list_t subscriber_list_t;
242 struct subscriber_list_t {
243     int fd;
244     FILE *stream;
245     subscriber_list_t *prev;
246     subscriber_list_t *next;
247 };
248
249 typedef struct rule_t rule_t;
250 struct rule_t {
251     char cause[MAXLEN];
252     char effect[MAXLEN];
253     bool one_shot;
254     rule_t *prev;
255     rule_t *next;
256 };
257
258 typedef struct {
259     char class_name[SMALEN];
260     char instance_name[SMALEN];
261     char desktop_desc[MAXLEN];
262     char monitor_desc[MAXLEN];
263     bool floating;
264     bool transient;
265     bool fullscreen;
266     bool locked;
267     bool sticky;
268     bool private;
269     bool center;
270     bool lower;
271     bool follow;
272     bool manage;
273     bool focus;
274 } rule_consequence_t;
275
276 typedef struct pending_rule_t pending_rule_t;
277 struct pending_rule_t {
278     int fd;
279     xcb_window_t win;
280     rule_consequence_t *csq;
281     pending_rule_t *prev;
282     pending_rule_t *next;
283 };
284
285 typedef struct {
286     xcb_point_t position;
287     pointer_action_t action;
288     xcb_rectangle_t rectangle;
289     node_t *vertical_fence;
290     node_t *horizontal_fence;
291     monitor_t *monitor;
292     desktop_t *desktop;
293     node_t *node;
294     client_t *client;
295     xcb_window_t window;
296     bool is_tiled;
297     double vertical_ratio;
298     double horizontal_ratio;
299     corner_t corner;
300     side_t side;
301 } pointer_state_t;
302
303 typedef struct {
304     node_t *fence;
305     unsigned int distance;
306 } fence_distance_t;
307
308 #endif