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 #include <sys/time.h> 00021 00022 #include "queue.h" 00023 00024 /* 00025 * To get the big concept: There are helper structures like struct 00026 * Workspace_Assignment. Every struct which is also defined as type (see 00027 * forward definitions) is considered to be a major structure, thus important. 00028 * 00029 * The following things are all stored in a 'Con', from very high level (the 00030 * biggest Cons) to very small (a single window): 00031 * 00032 * 1) X11 root window (as big as all your outputs combined) 00033 * 2) output (like LVDS1) 00034 * 3) content container, dockarea containers 00035 * 4) workspaces 00036 * 5) split containers 00037 * ... (you can arbitrarily nest split containers) 00038 * 6) X11 window containers 00039 * 00040 */ 00041 00042 /* Forward definitions */ 00043 typedef struct Binding Binding; 00044 typedef struct Rect Rect; 00045 typedef struct xoutput Output; 00046 typedef struct Con Con; 00047 typedef struct Match Match; 00048 typedef struct Assignment Assignment; 00049 typedef struct Window i3Window; 00050 00051 00052 /****************************************************************************** 00053 * Helper types 00054 *****************************************************************************/ 00055 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t; 00056 typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t; 00057 typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_1PIXEL = 2 } border_style_t; 00058 00061 typedef enum { DONT_KILL_WINDOW = 0, KILL_WINDOW = 1, KILL_CLIENT = 2 } kill_window_t; 00062 00063 enum { 00064 BIND_NONE = 0, 00065 BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */ 00066 BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */ 00067 BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */ 00068 BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */ 00069 BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */ 00070 BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */ 00071 BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */ 00072 BIND_MODE_SWITCH = (1 << 8) 00073 }; 00074 00087 struct Rect { 00088 uint32_t x; 00089 uint32_t y; 00090 uint32_t width; 00091 uint32_t height; 00092 } __attribute__((packed)); 00093 00099 struct reservedpx { 00100 uint32_t left; 00101 uint32_t right; 00102 uint32_t top; 00103 uint32_t bottom; 00104 }; 00105 00111 struct width_height { 00112 uint32_t w; 00113 uint32_t h; 00114 }; 00115 00122 struct deco_render_params { 00123 struct Colortriple *color; 00124 int border_style; 00125 struct width_height con_rect; 00126 struct width_height con_window_rect; 00127 Rect con_deco_rect; 00128 uint32_t background; 00129 bool con_is_leaf; 00130 }; 00131 00136 struct Workspace_Assignment { 00137 char *name; 00138 char *output; 00139 00140 TAILQ_ENTRY(Workspace_Assignment) ws_assignments; 00141 }; 00142 00143 struct Ignore_Event { 00144 int sequence; 00145 int response_type; 00146 time_t added; 00147 00148 SLIST_ENTRY(Ignore_Event) ignore_events; 00149 }; 00150 00156 struct Startup_Sequence { 00158 char *id; 00160 char *workspace; 00162 SnLauncherContext *context; 00163 00164 TAILQ_ENTRY(Startup_Sequence) sequences; 00165 }; 00166 00176 struct regex { 00177 char *pattern; 00178 pcre *regex; 00179 pcre_extra *extra; 00180 }; 00181 00182 /****************************************************************************** 00183 * Major types 00184 *****************************************************************************/ 00185 00191 struct Binding { 00195 char *symbol; 00196 00202 xcb_keycode_t *translated_to; 00203 00204 uint32_t number_keycodes; 00205 00207 uint32_t keycode; 00208 00210 uint32_t mods; 00211 00213 char *command; 00214 00215 TAILQ_ENTRY(Binding) bindings; 00216 }; 00217 00225 struct Autostart { 00227 char *command; 00230 bool no_startup_id; 00231 TAILQ_ENTRY(Autostart) autostarts; 00232 TAILQ_ENTRY(Autostart) autostarts_always; 00233 }; 00234 00242 struct xoutput { 00244 xcb_randr_output_t id; 00246 char *name; 00247 00249 Con *con; 00250 00253 bool active; 00254 00257 bool changed; 00258 bool to_be_disabled; 00259 bool primary; 00260 00262 Rect rect; 00263 00264 TAILQ_ENTRY(xoutput) outputs; 00265 }; 00266 00272 struct Window { 00273 xcb_window_t id; 00274 00277 xcb_window_t leader; 00278 xcb_window_t transient_for; 00279 00280 char *class_class; 00281 char *class_instance; 00282 00285 char *name_x; 00286 00290 char *role; 00291 00293 bool name_x_changed; 00294 00297 char *name_json; 00298 00300 size_t name_len; 00301 00303 bool uses_net_wm_name; 00304 00306 bool needs_take_focus; 00307 00309 struct timeval urgent; 00310 00313 bool doesnt_accept_focus; 00314 00316 enum { W_NODOCK = 0, W_DOCK_TOP = 1, W_DOCK_BOTTOM = 2 } dock; 00317 00319 struct reservedpx reserved; 00320 00323 uint32_t nr_assignments; 00324 Assignment **ran_assignments; 00325 00327 uint16_t depth; 00328 }; 00329 00338 struct Match { 00339 struct regex *title; 00340 struct regex *application; 00341 struct regex *class; 00342 struct regex *instance; 00343 struct regex *mark; 00344 struct regex *role; 00345 enum { 00346 U_DONTCHECK = -1, 00347 U_LATEST = 0, 00348 U_OLDEST = 1 00349 } urgent; 00350 enum { 00351 M_DONTCHECK = -1, 00352 M_NODOCK = 0, 00353 M_DOCK_ANY = 1, 00354 M_DOCK_TOP = 2, 00355 M_DOCK_BOTTOM = 3 00356 } dock; 00357 xcb_window_t id; 00358 Con *con_id; 00359 enum { M_ANY = 0, M_TILING, M_FLOATING } floating; 00360 00361 /* Where the window looking for a match should be inserted: 00362 * 00363 * M_HERE = the matched container will be replaced by the window 00364 * (layout saving) 00365 * M_ASSIGN_WS = the matched container will be inserted in the target_ws. 00366 * M_BELOW = the window will be inserted as a child of the matched container 00367 * (dockareas) 00368 * 00369 */ 00370 enum { M_HERE = 0, M_ASSIGN_WS, M_BELOW } insert_where; 00371 00372 /* Whether this match was generated when restarting i3 inplace. 00373 * Leads to not setting focus when managing a new window, because the old 00374 * focus stack should be restored. */ 00375 bool restart_mode; 00376 00377 TAILQ_ENTRY(Match) matches; 00378 }; 00379 00388 struct Assignment { 00400 enum { 00401 A_ANY = 0, 00402 A_COMMAND = (1 << 0), 00403 A_TO_WORKSPACE = (1 << 1), 00404 A_TO_OUTPUT = (1 << 2) 00405 } type; 00406 00408 Match match; 00409 00411 union { 00412 char *command; 00413 char *workspace; 00414 char *output; 00415 } dest; 00416 00417 TAILQ_ENTRY(Assignment) assignments; 00418 }; 00419 00424 struct Con { 00425 bool mapped; 00426 enum { 00427 CT_ROOT = 0, 00428 CT_OUTPUT = 1, 00429 CT_CON = 2, 00430 CT_FLOATING_CON = 3, 00431 CT_WORKSPACE = 4, 00432 CT_DOCKAREA = 5 00433 } type; 00434 orientation_t orientation; 00435 struct Con *parent; 00436 00437 struct Rect rect; 00438 struct Rect window_rect; 00439 struct Rect deco_rect; 00441 struct Rect geometry; 00442 00443 char *name; 00444 00447 int num; 00448 00449 /* a sticky-group is an identifier which bundles several containers to a 00450 * group. The contents are shared between all of them, that is they are 00451 * displayed on whichever of the containers is currently visible */ 00452 char *sticky_group; 00453 00454 /* user-definable mark to jump to this container later */ 00455 char *mark; 00456 00457 double percent; 00458 00459 /* proportional width/height, calculated from WM_NORMAL_HINTS, used to 00460 * apply an aspect ratio to windows (think of MPlayer) */ 00461 int proportional_width; 00462 int proportional_height; 00463 /* the wanted size of the window, used in combination with size 00464 * increments (see below). */ 00465 int base_width; 00466 int base_height; 00467 00468 /* the x11 border pixel attribute */ 00469 int border_width; 00470 00471 /* minimum increment size specified for the window (in pixels) */ 00472 int width_increment; 00473 int height_increment; 00474 00475 struct Window *window; 00476 00477 /* Should this container be marked urgent? This gets set when the window 00478 * inside this container (if any) sets the urgency hint, for example. */ 00479 bool urgent; 00480 00481 /* ids/pixmap/graphics context for the frame window */ 00482 xcb_window_t frame; 00483 xcb_pixmap_t pixmap; 00484 xcb_gcontext_t pm_gc; 00485 bool pixmap_recreated; 00486 00488 struct deco_render_params *deco_render_params; 00489 00490 /* Only workspace-containers can have floating clients */ 00491 TAILQ_HEAD(floating_head, Con) floating_head; 00492 00493 TAILQ_HEAD(nodes_head, Con) nodes_head; 00494 TAILQ_HEAD(focus_head, Con) focus_head; 00495 00496 TAILQ_HEAD(swallow_head, Match) swallow_head; 00497 00498 enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode; 00499 enum { L_DEFAULT = 0, L_STACKED = 1, L_TABBED = 2, L_DOCKAREA = 3, L_OUTPUT = 4 } layout; 00500 border_style_t border_style; 00507 enum { 00508 FLOATING_AUTO_OFF = 0, 00509 FLOATING_USER_OFF = 1, 00510 FLOATING_AUTO_ON = 2, 00511 FLOATING_USER_ON = 3 00512 } floating; 00513 00519 uint8_t ignore_unmap; 00520 00521 TAILQ_ENTRY(Con) nodes; 00522 TAILQ_ENTRY(Con) focused; 00523 TAILQ_ENTRY(Con) all_cons; 00524 TAILQ_ENTRY(Con) floating_windows; 00525 00527 void(*on_remove_child)(Con *); 00528 00529 enum { 00530 SCRATCHPAD_NONE = 0, 00531 SCRATCHPAD_FRESH = 1, 00532 SCRATCHPAD_CHANGED = 2 00533 } scratchpad_state; 00534 00535 /* The ID of this container before restarting. Necessary to correctly 00536 * interpret back-references in the JSON (such as the focus stack). */ 00537 int old_id; 00538 }; 00539 00540 #endif