i3
|
00001 /* 00002 * vim:ts=4:sw=4:expandtab 00003 * 00004 * i3 - an improved dynamic tiling window manager 00005 * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE) 00006 * 00007 * include/data.h: This file defines all data structures used by i3 00008 * 00009 */ 00010 #ifndef _DATA_H 00011 #define _DATA_H 00012 00013 #define SN_API_NOT_YET_FROZEN 1 00014 #include <libsn/sn-launcher.h> 00015 00016 #include <xcb/randr.h> 00017 #include <xcb/xcb_atom.h> 00018 #include <stdbool.h> 00019 #include <pcre.h> 00020 00021 #include "queue.h" 00022 00023 /* 00024 * To get the big concept: There are helper structures like struct Colorpixel 00025 * or struct Stack_Window. Everything which is also defined as type (see 00026 * forward definitions) is considered to be a major structure, thus important. 00027 * 00028 * Let’s start from the biggest to the smallest: 00029 * 00030 * TODO 00031 * 00032 */ 00033 00034 /* Forward definitions */ 00035 typedef struct Binding Binding; 00036 typedef struct Rect Rect; 00037 typedef struct xoutput Output; 00038 typedef struct Con Con; 00039 typedef struct Match Match; 00040 typedef struct Assignment Assignment; 00041 typedef struct Window i3Window; 00042 00043 00044 /****************************************************************************** 00045 * Helper types 00046 *****************************************************************************/ 00047 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t; 00048 typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t; 00049 typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_1PIXEL = 2 } border_style_t; 00050 00053 typedef enum { DONT_KILL_WINDOW = 0, KILL_WINDOW = 1, KILL_CLIENT = 2 } kill_window_t; 00054 00055 enum { 00056 BIND_NONE = 0, 00057 BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */ 00058 BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */ 00059 BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */ 00060 BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */ 00061 BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */ 00062 BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */ 00063 BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */ 00064 BIND_MODE_SWITCH = (1 << 8) 00065 }; 00066 00079 struct Rect { 00080 uint32_t x; 00081 uint32_t y; 00082 uint32_t width; 00083 uint32_t height; 00084 } __attribute__((packed)); 00085 00091 struct reservedpx { 00092 uint32_t left; 00093 uint32_t right; 00094 uint32_t top; 00095 uint32_t bottom; 00096 }; 00097 00103 struct width_height { 00104 uint32_t w; 00105 uint32_t h; 00106 }; 00107 00114 struct deco_render_params { 00115 struct Colortriple *color; 00116 int border_style; 00117 struct width_height con_rect; 00118 struct width_height con_window_rect; 00119 Rect con_deco_rect; 00120 uint32_t background; 00121 bool con_is_leaf; 00122 xcb_font_t font; 00123 }; 00124 00129 struct Workspace_Assignment { 00130 char *name; 00131 char *output; 00132 00133 TAILQ_ENTRY(Workspace_Assignment) ws_assignments; 00134 }; 00135 00136 struct Ignore_Event { 00137 int sequence; 00138 int response_type; 00139 time_t added; 00140 00141 SLIST_ENTRY(Ignore_Event) ignore_events; 00142 }; 00143 00149 struct Startup_Sequence { 00151 char *id; 00153 char *workspace; 00155 SnLauncherContext *context; 00156 00157 TAILQ_ENTRY(Startup_Sequence) sequences; 00158 }; 00159 00169 struct regex { 00170 char *pattern; 00171 pcre *regex; 00172 pcre_extra *extra; 00173 }; 00174 00175 /****************************************************************************** 00176 * Major types 00177 *****************************************************************************/ 00178 00184 struct Binding { 00188 char *symbol; 00189 00195 xcb_keycode_t *translated_to; 00196 00197 uint32_t number_keycodes; 00198 00200 uint32_t keycode; 00201 00203 uint32_t mods; 00204 00206 char *command; 00207 00208 TAILQ_ENTRY(Binding) bindings; 00209 }; 00210 00218 struct Autostart { 00220 char *command; 00223 bool no_startup_id; 00224 TAILQ_ENTRY(Autostart) autostarts; 00225 TAILQ_ENTRY(Autostart) autostarts_always; 00226 }; 00227 00235 struct xoutput { 00237 xcb_randr_output_t id; 00239 char *name; 00240 00242 Con *con; 00243 00246 bool active; 00247 00250 bool changed; 00251 bool to_be_disabled; 00252 bool primary; 00253 00255 Rect rect; 00256 00257 TAILQ_ENTRY(xoutput) outputs; 00258 }; 00259 00260 struct Window { 00261 xcb_window_t id; 00262 00265 xcb_window_t leader; 00266 xcb_window_t transient_for; 00267 00268 char *class_class; 00269 char *class_instance; 00270 00273 char *name_x; 00274 00278 char *role; 00279 00281 bool name_x_changed; 00282 00285 char *name_json; 00286 00288 int name_len; 00289 00291 bool uses_net_wm_name; 00292 00294 bool needs_take_focus; 00295 00298 bool doesnt_accept_focus; 00299 00301 enum { W_NODOCK = 0, W_DOCK_TOP = 1, W_DOCK_BOTTOM = 2 } dock; 00302 00304 struct reservedpx reserved; 00305 00308 uint32_t nr_assignments; 00309 Assignment **ran_assignments; 00310 }; 00311 00312 struct Match { 00313 struct regex *title; 00314 struct regex *application; 00315 struct regex *class; 00316 struct regex *instance; 00317 struct regex *mark; 00318 struct regex *role; 00319 enum { 00320 M_DONTCHECK = -1, 00321 M_NODOCK = 0, 00322 M_DOCK_ANY = 1, 00323 M_DOCK_TOP = 2, 00324 M_DOCK_BOTTOM = 3 00325 } dock; 00326 xcb_window_t id; 00327 Con *con_id; 00328 enum { M_ANY = 0, M_TILING, M_FLOATING } floating; 00329 00330 /* Where the window looking for a match should be inserted: 00331 * 00332 * M_HERE = the matched container will be replaced by the window 00333 * (layout saving) 00334 * M_ASSIGN_WS = the matched container will be inserted in the target_ws. 00335 * M_BELOW = the window will be inserted as a child of the matched container 00336 * (dockareas) 00337 * 00338 */ 00339 enum { M_HERE = 0, M_ASSIGN_WS, M_BELOW } insert_where; 00340 00341 TAILQ_ENTRY(Match) matches; 00342 }; 00343 00352 struct Assignment { 00364 enum { 00365 A_ANY = 0, 00366 A_COMMAND = (1 << 0), 00367 A_TO_WORKSPACE = (1 << 1), 00368 A_TO_OUTPUT = (1 << 2) 00369 } type; 00370 00372 Match match; 00373 00375 union { 00376 char *command; 00377 char *workspace; 00378 char *output; 00379 } dest; 00380 00381 TAILQ_ENTRY(Assignment) assignments; 00382 }; 00383 00384 struct Con { 00385 bool mapped; 00386 enum { 00387 CT_ROOT = 0, 00388 CT_OUTPUT = 1, 00389 CT_CON = 2, 00390 CT_FLOATING_CON = 3, 00391 CT_WORKSPACE = 4, 00392 CT_DOCKAREA = 5 00393 } type; 00394 orientation_t orientation; 00395 struct Con *parent; 00396 00397 struct Rect rect; 00398 struct Rect window_rect; 00399 struct Rect deco_rect; 00401 struct Rect geometry; 00402 00403 char *name; 00404 00407 int num; 00408 00409 /* a sticky-group is an identifier which bundles several containers to a 00410 * group. The contents are shared between all of them, that is they are 00411 * displayed on whichever of the containers is currently visible */ 00412 char *sticky_group; 00413 00414 /* user-definable mark to jump to this container later */ 00415 char *mark; 00416 00417 double percent; 00418 00419 /* proportional width/height, calculated from WM_NORMAL_HINTS, used to 00420 * apply an aspect ratio to windows (think of MPlayer) */ 00421 int proportional_width; 00422 int proportional_height; 00423 /* the wanted size of the window, used in combination with size 00424 * increments (see below). */ 00425 int base_width; 00426 int base_height; 00427 00428 /* the x11 border pixel attribute */ 00429 int border_width; 00430 00431 /* minimum increment size specified for the window (in pixels) */ 00432 int width_increment; 00433 int height_increment; 00434 00435 struct Window *window; 00436 00437 /* Should this container be marked urgent? This gets set when the window 00438 * inside this container (if any) sets the urgency hint, for example. */ 00439 bool urgent; 00440 00441 /* ids/pixmap/graphics context for the frame window */ 00442 xcb_window_t frame; 00443 xcb_pixmap_t pixmap; 00444 xcb_gcontext_t pm_gc; 00445 bool pixmap_recreated; 00446 00448 struct deco_render_params *deco_render_params; 00449 00450 /* Only workspace-containers can have floating clients */ 00451 TAILQ_HEAD(floating_head, Con) floating_head; 00452 00453 TAILQ_HEAD(nodes_head, Con) nodes_head; 00454 TAILQ_HEAD(focus_head, Con) focus_head; 00455 00456 TAILQ_HEAD(swallow_head, Match) swallow_head; 00457 00458 enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode; 00459 enum { L_DEFAULT = 0, L_STACKED = 1, L_TABBED = 2, L_DOCKAREA = 3, L_OUTPUT = 4 } layout; 00460 border_style_t border_style; 00467 enum { 00468 FLOATING_AUTO_OFF = 0, 00469 FLOATING_USER_OFF = 1, 00470 FLOATING_AUTO_ON = 2, 00471 FLOATING_USER_ON = 3 00472 } floating; 00473 00479 uint8_t ignore_unmap; 00480 00481 TAILQ_ENTRY(Con) nodes; 00482 TAILQ_ENTRY(Con) focused; 00483 TAILQ_ENTRY(Con) all_cons; 00484 TAILQ_ENTRY(Con) floating_windows; 00485 00487 void(*on_remove_child)(Con *); 00488 }; 00489 00490 #endif