4 * i3 - an improved dynamic tiling window manager
6 * © 2009-2010 Michael Stapelberg and contributors
8 * See file LICENSE for license information.
10 * include/data.h: This file defines all data structures used by i3
14 #include <xcb/randr.h>
15 #include <xcb/xcb_atom.h>
23 * To get the big concept: There are helper structures like struct Colorpixel
24 * or struct Stack_Window. Everything which is also defined as type (see
25 * forward definitions) is considered to be a major structure, thus important.
27 * Let’s start from the biggest to the smallest:
33 /* Forward definitions */
34 typedef struct Font i3Font;
35 typedef struct Binding Binding;
36 typedef struct Rect Rect;
37 typedef struct xoutput Output;
38 typedef struct Con Con;
39 typedef struct Match Match;
40 typedef struct Window i3Window;
43 /******************************************************************************
45 *****************************************************************************/
46 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
47 typedef enum { HORIZ, VERT, NO_ORIENTATION } orientation_t;
51 BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
52 BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
53 BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
54 BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
55 BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
56 BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
57 BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
58 BIND_MODE_SWITCH = (1 << 8)
62 * Stores a rectangle, for example the size of a window, the child window etc.
63 * It needs to be packed so that the compiler will not add any padding bytes.
64 * (it is used in src/ewmh.c for example)
66 * Note that x and y can contain signed values in some cases (for example when
67 * used for the coordinates of a window, which can be set outside of the
68 * visible area, but not when specifying the position of a workspace for the
69 * _NET_WM_WORKAREA hint). Not declaring x/y as int32_t saves us a lot of
78 } __attribute__((packed));
81 * Used for the cache of colorpixels.
87 SLIST_ENTRY(Colorpixel) colorpixels;
90 struct Cached_Pixmap {
93 /* We’re going to paint on it, so a graphics context will be needed */
96 /* The rect with which the pixmap was created */
99 /* The rect of the object to which this pixmap belongs. Necessary to
100 * find out when we need to re-create the pixmap. */
103 xcb_drawable_t referred_drawable;
106 struct Ignore_Event {
110 SLIST_ENTRY(Ignore_Event) ignore_events;
114 * Emulates the behaviour of tables of libxcb-wm, which in libxcb 0.3.4
118 struct keyvalue_element {
121 TAILQ_ENTRY(keyvalue_element) elements;
124 /******************************************************************************
126 *****************************************************************************/
129 * Holds a keybinding, consisting of a keycode combined with modifiers and the
130 * command which is executed as soon as the key is pressed (see src/command.c)
134 /** Symbol the user specified in configfile, if any. This needs to be
135 * stored with the binding to be able to re-convert it into a keycode
136 * if the keyboard mapping changes (using Xmodmap for example) */
139 /** Only in use if symbol != NULL. Gets set to the value to which the
140 * symbol got translated when binding. Useful for unbinding and
141 * checking which binding was used when a key press event comes in.
143 * This is an array of number_keycodes size. */
144 xcb_keycode_t *translated_to;
146 uint32_t number_keycodes;
148 /** Keycode to bind */
151 /** Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
154 /** Command, like in command mode */
157 TAILQ_ENTRY(Binding) bindings;
161 * Holds a command specified by an exec-line in the config (see src/config.c)
165 /** Command, like in command mode */
167 TAILQ_ENTRY(Autostart) autostarts;
171 * Holds an assignment for a given window class/title to a specific workspace
176 char *windowclass_title;
177 /** floating is true if this was an assignment to the special
178 * workspace "~". Matching clients will be put into floating mode
181 ASSIGN_FLOATING_NO, /* don’t float, but put on a workspace */
182 ASSIGN_FLOATING_ONLY, /* float, but don’t assign on a workspace */
183 ASSIGN_FLOATING /* float and put on a workspace */
186 /** The number of the workspace to assign to. */
188 TAILQ_ENTRY(Assignment) assignments;
192 * Data structure for cached font information:
193 * - font id in X11 (load it once)
194 * - font height (multiple calls needed to get it)
198 /** The name of the font, that is what the pattern resolves to */
200 /** A copy of the pattern to build a cache */
202 /** The height of the font, built from font_ascent + font_descent */
204 /** The xcb-id for the font */
207 TAILQ_ENTRY(Font) fonts;
212 * An Output is a physical output on your graphics driver. Outputs which
213 * are currently in use have (output->active == true). Each output has a
214 * position and a mode. An output usually corresponds to one connected
215 * screen (except if you are running multiple screens in clone mode).
219 /** Output id, so that we can requery the output directly later */
220 xcb_randr_output_t id;
221 /** Name of the output */
224 /** Whether the output is currently active (has a CRTC attached with a
228 /** Internal flags, necessary for querying RandR screens (happens in
233 /** x, y, width, height */
236 /** The bar window */
238 xcb_gcontext_t bargc;
240 /** Contains all clients with _NET_WM_WINDOW_TYPE ==
241 * _NET_WM_WINDOW_TYPE_DOCK */
242 SLIST_HEAD(dock_clients_head, Client) dock_clients;
244 TAILQ_ENTRY(xoutput) outputs;
250 const char *class_class;
251 const char *class_instance;
252 const char *name_ucs2;
253 const char *name_utf8;
255 bool uses_net_wm_name;
259 enum { M_WINDOW, M_CON } what;
269 enum { M_GLOBAL, M_OUTPUT, M_WORKSPACE } levels;
271 enum { M_USER, M_RESTART } source;
273 /* wo das fenster eingefügt werden soll. bei here wird es direkt
274 * diesem Con zugewiesen, also layout saving. bei active ist es
275 * ein assignment, welches an der momentan fokussierten stelle einfügt */
276 enum { M_HERE, M_ACTIVE } insert_where;
278 TAILQ_ENTRY(Match) matches;
283 enum { CT_ROOT = 0, CT_OUTPUT = 1, CT_CON = 2, CT_FLOATING_CON = 3 } type;
284 orientation_t orientation;
286 /* parent before setting it to floating */
287 struct Con *old_parent;
290 struct Rect window_rect;
291 struct Rect deco_rect;
297 struct Window *window;
299 /* ids/gc for the frame window */
303 /* Only workspace-containers can have floating clients */
304 TAILQ_HEAD(floating_head, Con) floating_head;
306 TAILQ_HEAD(nodes_head, Con) nodes_head;
307 TAILQ_HEAD(focus_head, Con) focus_head;
309 TAILQ_HEAD(swallow_head, Match) swallow_head;
311 enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode;
312 enum { L_DEFAULT = 0, L_STACKED = 1, L_TABBED = 2 } layout;
313 /** floating? (= not in tiling layout) This cannot be simply a bool
314 * because we want to keep track of whether the status was set by the
315 * application (by setting _NET_WM_WINDOW_TYPE appropriately) or by the
316 * user. The user’s choice overwrites automatic mode, of course. The
317 * order of the values is important because we check with >=
318 * FLOATING_AUTO_ON if a client is floating. */
320 FLOATING_AUTO_OFF = 0,
321 FLOATING_USER_OFF = 1,
322 FLOATING_AUTO_ON = 2,
327 TAILQ_ENTRY(Con) nodes;
328 TAILQ_ENTRY(Con) focused;
329 TAILQ_ENTRY(Con) all_cons;
330 TAILQ_ENTRY(Con) floating_windows;