4 * i3 - an improved dynamic tiling window manager
6 * (c) 2009 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/xcb_atom.h>
22 * To get the big concept: There are helper structures like struct Colorpixel or
23 * struct Stack_Window. Everything which is also defined as type (see forward definitions)
24 * is considered to be a major structure, thus important.
26 * Let’s start from the biggest to the smallest:
27 * - An i3Screen is a virtual screen (Xinerama). This can be a single one, though two monitors
28 * might be connected, if you’re running clone mode. There can also be multiple of them.
30 * - Each i3Screen contains Workspaces. The concept is known from various other window managers.
31 * Basically, a workspace is a specific set of windows, usually grouped thematically (irc,
32 * www, work, …). You can switch between these.
34 * - Each Workspace has a table, which is our layout abstraction. You manage your windows
35 * by moving them around in your table. It grows as necessary.
37 * - Each cell of the table has a container, which can be in default or stacking mode. In default
38 * mode, each client is given equally much space in the container. In stacking mode, only one
39 * client is shown at a time, but all the titlebars are rendered at the top.
41 * - Inside the container are clients, which is X11-speak for a window.
45 /* Forward definitions */
46 typedef struct Cell Cell;
47 typedef struct Font i3Font;
48 typedef struct Container Container;
49 typedef struct Client Client;
50 typedef struct Binding Binding;
51 typedef struct Autostart Autostart;
52 typedef struct Workspace Workspace;
53 typedef struct Rect Rect;
54 typedef struct Screen i3Screen;
56 /******************************************************************************
58 *****************************************************************************/
59 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
63 BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
64 BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
65 BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
66 BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
67 BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
68 BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
69 BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
70 BIND_MODE_SWITCH = (1 << 8)
75 uint32_t width, height;
79 * Defines a position in the table
88 * Used for the cache of colorpixels.
96 SLIST_ENTRY(Colorpixel) colorpixels;
100 * Contains data for the windows needed to draw the titlebars on in stacking mode
103 struct Stack_Window {
108 /* Backpointer to the container this stack window is in */
109 Container *container;
111 SLIST_ENTRY(Stack_Window) stack_windows;
114 struct Ignore_Event {
118 SLIST_ENTRY(Ignore_Event) ignore_events;
122 * Emulates the behaviour of tables of libxcb-wm, which in libxcb 0.3.4 suddenly vanished.
125 struct keyvalue_element {
129 TAILQ_ENTRY(keyvalue_element) elements;
133 enum xcb_atom_fast_tag_t tag;
135 xcb_get_window_attributes_cookie_t cookie;
136 uint8_t override_redirect;
138 } window_attributes_t;
140 /******************************************************************************
142 *****************************************************************************/
145 * The concept of Workspaces is known from various other window managers. Basically,
146 * a workspace is a specific set of windows, usually grouped thematically (irc,
147 * www, work, …). You can switch between these.
151 /* Number of this workspace, starting from 0 */
154 /* x, y, width, height */
157 /* table dimensions */
161 /* These are stored here only while this workspace is _not_ shown (see show_workspace()) */
165 Client *fullscreen_client;
167 /* The focus stack contains the clients in the correct order of focus so that
168 the focus can be reverted correctly when a client is closed */
169 SLIST_HEAD(focus_stack_head, Client) focus_stack;
171 /* Backpointer to the screen this workspace is on */
174 /* This is a two-dimensional dynamic array of Container-pointers. I’ve always wanted
175 * to be a three-star programmer :) */
178 /* width_factor and height_factor contain the amount of space (percentage) a column/row
179 has of all the space which is available for resized windows. This ensures that
180 non-resized windows (newly opened, for example) have the same size as always */
182 float *height_factor;
186 * Holds a keybinding, consisting of a keycode combined with modifiers and the command
187 * which is executed as soon as the key is pressed (see src/command.c)
191 /* Keycode to bind */
193 /* Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, … */
195 /* Command, like in command mode */
198 TAILQ_ENTRY(Binding) bindings;
202 * Holds a command specified by an exec-line in the config (see src/config.c)
206 /* Command, like in command mode */
208 TAILQ_ENTRY(Autostart) autostarts;
212 * Data structure for cached font information:
213 * - font id in X11 (load it once)
214 * - font height (multiple calls needed to get it)
218 /* The name of the font, that is what the pattern resolves to */
220 /* A copy of the pattern to build a cache */
222 /* The height of the font, built from font_ascent + font_descent */
224 /* The xcb-id for the font */
227 TAILQ_ENTRY(Font) fonts;
231 * A client is X11-speak for a window.
235 /* if you set a client to floating and set it back to managed, it does remember its old
236 position and *tries* to get back there */
239 /* Backpointer. A client is inside a container */
240 Container *container;
241 /* Because dock clients don’t have a container, we have this workspace-backpointer */
242 Workspace *workspace;
244 /* x, y, width, height of the frame */
246 /* x, y, width, height of the child (relative to its frame) */
249 /* contains the size calculated from the hints set by the window or 0 if the client
250 did not send any hints */
251 int proportional_height;
252 int proportional_width;
254 /* Height which was determined by reading the _NET_WM_STRUT_PARTIAL top/bottom of the screen
258 /* Name (= window title) */
260 /* name_len stores the real string length (glyphs) of the window title if the client uses
261 _NET_WM_NAME. Otherwise, it is set to -1 to indicate that name should be just passed
262 to X as 8-bit string and therefore will not be rendered correctly. This behaviour is
263 to support legacy applications which do not set _NET_WM_NAME */
265 /* This will be set to true as soon as the first _NET_WM_NAME comes in. If set to true,
266 legacy window names are ignored. */
267 bool uses_net_wm_name;
269 /* Holds the WM_CLASS, useful for matching the client in commands */
272 /* fullscreen is pretty obvious */
275 /* Ensure TITLEBAR_TOP maps to 0 because we use calloc for initialization later */
276 enum { TITLEBAR_TOP = 0, TITLEBAR_LEFT, TITLEBAR_RIGHT, TITLEBAR_BOTTOM, TITLEBAR_OFF } titlebar_position;
278 /* If a client is set as a dock, it is placed at the very bottom of the screen and its
279 requested size is used */
282 /* After leaving fullscreen mode, a client needs to be reconfigured (configuration =
283 setting X, Y, width and height). By setting the force_reconfigure flag, render_layout()
284 will reconfigure the client. */
285 bool force_reconfigure;
287 /* When reparenting a window, an unmap-notify is sent. As we delete windows when they’re
288 unmapped, we need to ignore that one. Therefore, this flag is set when reparenting. */
289 bool awaiting_useless_unmap;
292 xcb_window_t frame; /* Our window: The frame around the client */
293 xcb_gcontext_t titlegc; /* The titlebar’s graphic context inside the frame */
294 xcb_window_t child; /* The client’s window */
296 /* The following entry provides the necessary list pointers to use Client with LIST_* macros */
297 CIRCLEQ_ENTRY(Client) clients;
298 SLIST_ENTRY(Client) dock_clients;
299 SLIST_ENTRY(Client) focus_clients;
303 * A container is either in default or stacking mode. It sits inside each cell of the table.
307 /* Those are speaking for themselves: */
308 Client *currently_focused;
312 /* Position of the container inside our table */
315 /* Xinerama: X/Y of the container */
318 /* Width/Height of the container. Changeable by the user */
322 /* When in stacking mode, we draw the titlebars of each client onto a separate window */
323 struct Stack_Window stack_win;
325 /* Backpointer to the workspace this container is in */
326 Workspace *workspace;
328 /* Ensure MODE_DEFAULT maps to 0 because we use calloc for initialization later */
329 enum { MODE_DEFAULT = 0, MODE_STACK } mode;
330 CIRCLEQ_HEAD(client_head, Client) clients;
334 * This is a virtual screen (Xinerama). This can be a single one, though two monitors
335 * might be connected, if you’re running clone mode. There can also be multiple of them.
339 /* Virtual screen number */
342 /* Current workspace selected on this virtual screen */
343 int current_workspace;
345 /* x, y, width, height */
350 xcb_gcontext_t bargc;
352 /* Contains all clients with _NET_WM_WINDOW_TYPE == _NET_WM_WINDOW_TYPE_DOCK */
353 SLIST_HEAD(dock_clients_head, Client) dock_clients;
355 TAILQ_ENTRY(Screen) screens;