i3
|
00001 /* 00002 * vim:ts=4:sw=4:expandtab 00003 * 00004 * i3 - an improved dynamic tiling window manager 00005 * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) 00006 * 00007 * include/data.h: This file defines all data structures used by i3 00008 * 00009 */ 00010 #include <xcb/randr.h> 00011 #include <xcb/xcb_atom.h> 00012 #include <stdbool.h> 00013 00014 #ifndef _DATA_H 00015 #define _DATA_H 00016 #include "queue.h" 00017 00018 /* 00019 * To get the big concept: There are helper structures like struct Colorpixel 00020 * or struct Stack_Window. Everything which is also defined as type (see 00021 * forward definitions) is considered to be a major structure, thus important. 00022 * 00023 * Let’s start from the biggest to the smallest: 00024 * 00025 * TODO 00026 * 00027 */ 00028 00029 /* Forward definitions */ 00030 typedef struct Font i3Font; 00031 typedef struct Binding Binding; 00032 typedef struct Rect Rect; 00033 typedef struct xoutput Output; 00034 typedef struct Con Con; 00035 typedef struct Match Match; 00036 typedef struct Assignment Assignment; 00037 typedef struct Window i3Window; 00038 00039 00040 /****************************************************************************** 00041 * Helper types 00042 *****************************************************************************/ 00043 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t; 00044 typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t; 00045 typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_1PIXEL = 2 } border_style_t; 00046 00049 typedef enum { DONT_KILL_WINDOW = 0, KILL_WINDOW = 1, KILL_CLIENT = 2 } kill_window_t; 00050 00051 enum { 00052 BIND_NONE = 0, 00053 BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */ 00054 BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */ 00055 BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */ 00056 BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */ 00057 BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */ 00058 BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */ 00059 BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */ 00060 BIND_MODE_SWITCH = (1 << 8) 00061 }; 00062 00075 struct Rect { 00076 uint32_t x; 00077 uint32_t y; 00078 uint32_t width; 00079 uint32_t height; 00080 } __attribute__((packed)); 00081 00087 struct reservedpx { 00088 uint32_t left; 00089 uint32_t right; 00090 uint32_t top; 00091 uint32_t bottom; 00092 }; 00093 00099 struct width_height { 00100 uint32_t w; 00101 uint32_t h; 00102 }; 00103 00110 struct deco_render_params { 00111 struct Colortriple *color; 00112 int border_style; 00113 struct width_height con_rect; 00114 struct width_height con_window_rect; 00115 Rect con_deco_rect; 00116 uint32_t background; 00117 bool con_is_leaf; 00118 xcb_font_t font; 00119 }; 00120 00125 struct Workspace_Assignment { 00126 char *name; 00127 char *output; 00128 00129 TAILQ_ENTRY(Workspace_Assignment) ws_assignments; 00130 }; 00131 00132 struct Ignore_Event { 00133 int sequence; 00134 int response_type; 00135 time_t added; 00136 00137 SLIST_ENTRY(Ignore_Event) ignore_events; 00138 }; 00139 00140 /****************************************************************************** 00141 * Major types 00142 *****************************************************************************/ 00143 00149 struct Binding { 00153 char *symbol; 00154 00160 xcb_keycode_t *translated_to; 00161 00162 uint32_t number_keycodes; 00163 00165 uint32_t keycode; 00166 00168 uint32_t mods; 00169 00171 char *command; 00172 00173 TAILQ_ENTRY(Binding) bindings; 00174 }; 00175 00183 struct Autostart { 00185 char *command; 00186 TAILQ_ENTRY(Autostart) autostarts; 00187 TAILQ_ENTRY(Autostart) autostarts_always; 00188 }; 00189 00196 struct Font { 00198 int height; 00200 xcb_font_t id; 00201 }; 00202 00203 00211 struct xoutput { 00213 xcb_randr_output_t id; 00215 char *name; 00216 00218 Con *con; 00219 00222 bool active; 00223 00226 bool changed; 00227 bool to_be_disabled; 00228 bool primary; 00229 00231 Rect rect; 00232 00233 #if 0 00234 00235 xcb_window_t bar; 00236 xcb_gcontext_t bargc; 00237 00240 SLIST_HEAD(dock_clients_head, Client) dock_clients; 00241 #endif 00242 00243 TAILQ_ENTRY(xoutput) outputs; 00244 }; 00245 00246 struct Window { 00247 xcb_window_t id; 00248 00251 xcb_window_t leader; 00252 xcb_window_t transient_for; 00253 00254 char *class_class; 00255 char *class_instance; 00256 00259 char *name_x; 00260 00262 bool name_x_changed; 00263 00266 char *name_json; 00267 00269 int name_len; 00270 00272 bool uses_net_wm_name; 00273 00275 bool needs_take_focus; 00276 00278 enum { W_NODOCK = 0, W_DOCK_TOP = 1, W_DOCK_BOTTOM = 2 } dock; 00279 00281 struct reservedpx reserved; 00282 00285 uint32_t nr_assignments; 00286 Assignment **ran_assignments; 00287 }; 00288 00289 struct Match { 00290 char *title; 00291 int title_len; 00292 char *application; 00293 char *class; 00294 char *instance; 00295 char *mark; 00296 enum { 00297 M_DONTCHECK = -1, 00298 M_NODOCK = 0, 00299 M_DOCK_ANY = 1, 00300 M_DOCK_TOP = 2, 00301 M_DOCK_BOTTOM = 3 00302 } dock; 00303 xcb_window_t id; 00304 Con *con_id; 00305 enum { M_ANY = 0, M_TILING, M_FLOATING } floating; 00306 00307 /* Where the window looking for a match should be inserted: 00308 * 00309 * M_HERE = the matched container will be replaced by the window 00310 * (layout saving) 00311 * M_ASSIGN_WS = the matched container will be inserted in the target_ws. 00312 * M_BELOW = the window will be inserted as a child of the matched container 00313 * (dockareas) 00314 * 00315 */ 00316 enum { M_HERE = 0, M_ASSIGN_WS, M_BELOW } insert_where; 00317 00318 TAILQ_ENTRY(Match) matches; 00319 }; 00320 00329 struct Assignment { 00341 enum { 00342 A_ANY = 0, 00343 A_COMMAND = (1 << 0), 00344 A_TO_WORKSPACE = (1 << 1), 00345 A_TO_OUTPUT = (1 << 2) 00346 } type; 00347 00349 Match match; 00350 00352 union { 00353 char *command; 00354 char *workspace; 00355 char *output; 00356 } dest; 00357 00358 TAILQ_ENTRY(Assignment) assignments; 00359 }; 00360 00361 struct Con { 00362 bool mapped; 00363 enum { 00364 CT_ROOT = 0, 00365 CT_OUTPUT = 1, 00366 CT_CON = 2, 00367 CT_FLOATING_CON = 3, 00368 CT_WORKSPACE = 4, 00369 CT_DOCKAREA = 5 00370 } type; 00371 orientation_t orientation; 00372 struct Con *parent; 00373 00374 struct Rect rect; 00375 struct Rect window_rect; 00376 struct Rect deco_rect; 00378 struct Rect geometry; 00379 00380 char *name; 00381 00384 int num; 00385 00386 /* a sticky-group is an identifier which bundles several containers to a 00387 * group. The contents are shared between all of them, that is they are 00388 * displayed on whichever of the containers is currently visible */ 00389 char *sticky_group; 00390 00391 /* user-definable mark to jump to this container later */ 00392 char *mark; 00393 00394 double percent; 00395 00396 /* proportional width/height, calculated from WM_NORMAL_HINTS, used to 00397 * apply an aspect ratio to windows (think of MPlayer) */ 00398 int proportional_width; 00399 int proportional_height; 00400 /* the wanted size of the window, used in combination with size 00401 * increments (see below). */ 00402 int base_width; 00403 int base_height; 00404 00405 /* the x11 border pixel attribute */ 00406 int border_width; 00407 00408 /* minimum increment size specified for the window (in pixels) */ 00409 int width_increment; 00410 int height_increment; 00411 00412 struct Window *window; 00413 00414 /* Should this container be marked urgent? This gets set when the window 00415 * inside this container (if any) sets the urgency hint, for example. */ 00416 bool urgent; 00417 00418 /* ids/pixmap/graphics context for the frame window */ 00419 xcb_window_t frame; 00420 xcb_pixmap_t pixmap; 00421 xcb_gcontext_t pm_gc; 00422 bool pixmap_recreated; 00423 00425 struct deco_render_params *deco_render_params; 00426 00427 /* Only workspace-containers can have floating clients */ 00428 TAILQ_HEAD(floating_head, Con) floating_head; 00429 00430 TAILQ_HEAD(nodes_head, Con) nodes_head; 00431 TAILQ_HEAD(focus_head, Con) focus_head; 00432 00433 TAILQ_HEAD(swallow_head, Match) swallow_head; 00434 00435 enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode; 00436 enum { L_DEFAULT = 0, L_STACKED = 1, L_TABBED = 2, L_DOCKAREA = 3, L_OUTPUT = 4 } layout; 00437 border_style_t border_style; 00444 enum { 00445 FLOATING_AUTO_OFF = 0, 00446 FLOATING_USER_OFF = 1, 00447 FLOATING_AUTO_ON = 2, 00448 FLOATING_USER_ON = 3 00449 } floating; 00450 00456 uint8_t ignore_unmap; 00457 00458 TAILQ_ENTRY(Con) nodes; 00459 TAILQ_ENTRY(Con) focused; 00460 TAILQ_ENTRY(Con) all_cons; 00461 TAILQ_ENTRY(Con) floating_windows; 00462 00464 void(*on_remove_child)(Con *); 00465 }; 00466 00467 #endif