1 /* Copyright (c) 2012, Bastien Dejean 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this 8 * list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 * and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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 20 * ON 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 #include <stdbool.h> 28 #include <xcb/xcb.h> 29 #include <xcb/xcb_icccm.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_WM_STATES 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 SCHEME_LONGEST_SIDE, 49 SCHEME_ALTERNATE, 50 SCHEME_SPIRAL 51 } automatic_scheme_t; 52 53 typedef enum { 54 STATE_TILED, 55 STATE_PSEUDO_TILED, 56 STATE_FLOATING, 57 STATE_FULLSCREEN 58 } client_state_t; 59 60 typedef enum { 61 WM_FLAG_MODAL = 1 << 0, 62 WM_FLAG_STICKY = 1 << 1, 63 WM_FLAG_MAXIMIZED_VERT = 1 << 2, 64 WM_FLAG_MAXIMIZED_HORZ = 1 << 3, 65 WM_FLAG_SHADED = 1 << 4, 66 WM_FLAG_SKIP_TASKBAR = 1 << 5, 67 WM_FLAG_SKIP_PAGER = 1 << 6, 68 WM_FLAG_HIDDEN = 1 << 7, 69 WM_FLAG_FULLSCREEN = 1 << 8, 70 WM_FLAG_ABOVE = 1 << 9, 71 WM_FLAG_BELOW = 1 << 10, 72 WM_FLAG_DEMANDS_ATTENTION = 1 << 11, 73 } wm_flags_t; 74 75 typedef enum { 76 LAYER_BELOW, 77 LAYER_NORMAL, 78 LAYER_ABOVE 79 } stack_layer_t; 80 81 typedef enum { 82 OPTION_NONE, 83 OPTION_TRUE, 84 OPTION_FALSE 85 } option_bool_t; 86 87 typedef enum { 88 ALTER_TOGGLE, 89 ALTER_SET 90 } alter_state_t; 91 92 typedef enum { 93 CYCLE_NEXT, 94 CYCLE_PREV 95 } cycle_dir_t; 96 97 typedef enum { 98 CIRCULATE_FORWARD, 99 CIRCULATE_BACKWARD 100 } circulate_dir_t; 101 102 typedef enum { 103 HISTORY_OLDER, 104 HISTORY_NEWER 105 } history_dir_t; 106 107 typedef enum { 108 DIR_NORTH, 109 DIR_WEST, 110 DIR_SOUTH, 111 DIR_EAST 112 } direction_t; 113 114 typedef enum { 115 HANDLE_LEFT = 1 << 0, 116 HANDLE_TOP = 1 << 1, 117 HANDLE_RIGHT = 1 << 2, 118 HANDLE_BOTTOM = 1 << 3, 119 HANDLE_TOP_LEFT = HANDLE_TOP | HANDLE_LEFT, 120 HANDLE_TOP_RIGHT = HANDLE_TOP | HANDLE_RIGHT, 121 HANDLE_BOTTOM_RIGHT = HANDLE_BOTTOM | HANDLE_RIGHT, 122 HANDLE_BOTTOM_LEFT = HANDLE_BOTTOM | HANDLE_LEFT 123 } resize_handle_t; 124 125 typedef enum { 126 ACTION_NONE, 127 ACTION_FOCUS, 128 ACTION_MOVE, 129 ACTION_RESIZE_SIDE, 130 ACTION_RESIZE_CORNER 131 } pointer_action_t; 132 133 typedef enum { 134 LAYOUT_TILED, 135 LAYOUT_MONOCLE 136 } layout_t; 137 138 typedef enum { 139 FLIP_HORIZONTAL, 140 FLIP_VERTICAL 141 } flip_t; 142 143 typedef enum { 144 FIRST_CHILD, 145 SECOND_CHILD 146 } child_polarity_t; 147 148 typedef enum { 149 TIGHTNESS_LOW, 150 TIGHTNESS_HIGH, 151 } tightness_t; 152 153 typedef enum { 154 AREA_BIGGEST, 155 AREA_SMALLEST, 156 } area_peak_t; 157 158 typedef enum { 159 STATE_TRANSITION_ENTER = 1 << 0, 160 STATE_TRANSITION_EXIT = 1 << 1, 161 } state_transition_t; 162 163 typedef struct { 164 option_bool_t automatic; 165 option_bool_t focused; 166 option_bool_t active; 167 option_bool_t local; 168 option_bool_t leaf; 169 option_bool_t window; 170 option_bool_t tiled; 171 option_bool_t pseudo_tiled; 172 option_bool_t floating; 173 option_bool_t fullscreen; 174 option_bool_t hidden; 175 option_bool_t sticky; 176 option_bool_t private; 177 option_bool_t locked; 178 option_bool_t marked; 179 option_bool_t urgent; 180 option_bool_t same_class; 181 option_bool_t descendant_of; 182 option_bool_t ancestor_of; 183 option_bool_t below; 184 option_bool_t normal; 185 option_bool_t above; 186 option_bool_t horizontal; 187 option_bool_t vertical; 188 } node_select_t; 189 190 typedef struct { 191 option_bool_t occupied; 192 option_bool_t focused; 193 option_bool_t active; 194 option_bool_t urgent; 195 option_bool_t local; 196 } desktop_select_t; 197 198 typedef struct { 199 option_bool_t occupied; 200 option_bool_t focused; 201 } monitor_select_t; 202 203 typedef struct icccm_props_t icccm_props_t; 204 struct icccm_props_t { 205 bool take_focus; 206 bool input_hint; 207 bool delete_window; 208 }; 209 210 typedef struct { 211 char class_name[MAXLEN]; 212 char instance_name[MAXLEN]; 213 char name[MAXLEN]; 214 unsigned int border_width; 215 bool urgent; 216 bool shown; 217 client_state_t state; 218 client_state_t last_state; 219 stack_layer_t layer; 220 stack_layer_t last_layer; 221 xcb_rectangle_t floating_rectangle; 222 xcb_rectangle_t tiled_rectangle; 223 xcb_size_hints_t size_hints; 224 icccm_props_t icccm_props; 225 wm_flags_t wm_flags; 226 } client_t; 227 228 typedef struct presel_t presel_t; 229 struct presel_t { 230 double split_ratio; 231 direction_t split_dir; 232 xcb_window_t feedback; 233 }; 234 235 typedef struct constraints_t constraints_t; 236 struct constraints_t { 237 uint16_t min_width; 238 uint16_t min_height; 239 }; 240 241 typedef struct node_t node_t; 242 struct node_t { 243 uint32_t id; 244 split_type_t split_type; 245 double split_ratio; 246 presel_t *presel; 247 xcb_rectangle_t rectangle; 248 constraints_t constraints; 249 bool vacant; 250 bool hidden; 251 bool sticky; 252 bool private; 253 bool locked; 254 bool marked; 255 node_t *first_child; 256 node_t *second_child; 257 node_t *parent; 258 client_t *client; 259 }; 260 261 typedef struct padding_t padding_t; 262 struct padding_t { 263 int top; 264 int right; 265 int bottom; 266 int left; 267 }; 268 269 typedef struct desktop_t desktop_t; 270 struct desktop_t { 271 char name[SMALEN]; 272 uint32_t id; 273 layout_t layout; 274 layout_t user_layout; 275 node_t *root; 276 node_t *focus; 277 desktop_t *prev; 278 desktop_t *next; 279 padding_t padding; 280 int window_gap; 281 unsigned int border_width; 282 }; 283 284 typedef struct monitor_t monitor_t; 285 struct monitor_t { 286 char name[SMALEN]; 287 uint32_t id; 288 xcb_randr_output_t randr_id; 289 xcb_window_t root; 290 bool wired; 291 padding_t padding; 292 unsigned int sticky_count; 293 int window_gap; 294 unsigned int border_width; 295 xcb_rectangle_t rectangle; 296 desktop_t *desk; 297 desktop_t *desk_head; 298 desktop_t *desk_tail; 299 monitor_t *prev; 300 monitor_t *next; 301 }; 302 303 typedef struct { 304 monitor_t *monitor; 305 desktop_t *desktop; 306 node_t *node; 307 } coordinates_t; 308 309 typedef struct history_t history_t; 310 struct history_t { 311 coordinates_t loc; 312 bool latest; 313 history_t *prev; 314 history_t *next; 315 }; 316 317 typedef struct stacking_list_t stacking_list_t; 318 struct stacking_list_t { 319 node_t *node; 320 stacking_list_t *prev; 321 stacking_list_t *next; 322 }; 323 324 typedef struct event_queue_t event_queue_t; 325 struct event_queue_t { 326 xcb_generic_event_t event; 327 event_queue_t *prev; 328 event_queue_t *next; 329 }; 330 331 typedef struct subscriber_list_t subscriber_list_t; 332 struct subscriber_list_t { 333 FILE *stream; 334 char* fifo_path; 335 int field; 336 int count; 337 subscriber_list_t *prev; 338 subscriber_list_t *next; 339 }; 340 341 typedef struct rule_t rule_t; 342 struct rule_t { 343 char class_name[MAXLEN]; 344 char instance_name[MAXLEN]; 345 char name[MAXLEN]; 346 char effect[MAXLEN]; 347 bool one_shot; 348 rule_t *prev; 349 rule_t *next; 350 }; 351 352 typedef struct { 353 char class_name[MAXLEN]; 354 char instance_name[MAXLEN]; 355 char name[MAXLEN]; 356 char monitor_desc[MAXLEN]; 357 char desktop_desc[MAXLEN]; 358 char node_desc[MAXLEN]; 359 direction_t *split_dir; 360 double split_ratio; 361 stack_layer_t *layer; 362 client_state_t *state; 363 bool hidden; 364 bool sticky; 365 bool private; 366 bool locked; 367 bool marked; 368 bool center; 369 bool follow; 370 bool manage; 371 bool focus; 372 bool border; 373 xcb_rectangle_t *rect; 374 } rule_consequence_t; 375 376 typedef struct pending_rule_t pending_rule_t; 377 struct pending_rule_t { 378 int fd; 379 xcb_window_t win; 380 rule_consequence_t *csq; 381 event_queue_t *event_head; 382 event_queue_t *event_tail; 383 pending_rule_t *prev; 384 pending_rule_t *next; 385 }; 386 387 #endif 388