i3
data.h
Go to the documentation of this file.
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * include/data.h: This file defines all data structures used by i3
8  *
9  */
10 #pragma once
11 
12 #define SN_API_NOT_YET_FROZEN 1
13 #include <libsn/sn-launcher.h>
14 
15 #include <xcb/randr.h>
16 #include <stdbool.h>
17 #include <pcre.h>
18 #include <sys/time.h>
19 
20 #include "libi3.h"
21 #include "queue.h"
22 
23 /*
24  * To get the big concept: There are helper structures like struct
25  * Workspace_Assignment. Every struct which is also defined as type (see
26  * forward definitions) is considered to be a major structure, thus important.
27  *
28  * The following things are all stored in a 'Con', from very high level (the
29  * biggest Cons) to very small (a single window):
30  *
31  * 1) X11 root window (as big as all your outputs combined)
32  * 2) output (like LVDS1)
33  * 3) content container, dockarea containers
34  * 4) workspaces
35  * 5) split containers
36  * ... (you can arbitrarily nest split containers)
37  * 6) X11 window containers
38  *
39  */
40 
41 /* Forward definitions */
42 typedef struct Binding Binding;
43 typedef struct Rect Rect;
44 typedef struct xoutput Output;
45 typedef struct Con Con;
46 typedef struct Match Match;
47 typedef struct Assignment Assignment;
48 typedef struct Window i3Window;
49 
50 
51 /******************************************************************************
52  * Helper types
53  *****************************************************************************/
54 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
55 typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t;
56 typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_PIXEL = 2 } border_style_t;
57 
60 typedef enum { DONT_KILL_WINDOW = 0, KILL_WINDOW = 1, KILL_CLIENT = 2 } kill_window_t;
61 
63 typedef enum { ADJ_NONE = 0,
68 
69 enum {
70  BIND_NONE = 0,
71  BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
72  BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
73  BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
74  BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
75  BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
76  BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
77  BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
78  BIND_MODE_SWITCH = (1 << 8)
79 };
80 
84 typedef enum {
85  L_DEFAULT = 0,
86  L_STACKED = 1,
87  L_TABBED = 2,
89  L_OUTPUT = 4,
90  L_SPLITV = 5,
92 } layout_t;
93 
97 typedef enum {
99  B_MOUSE = 1
100 } input_type_t;
101 
105 typedef enum {
108 } warping_t;
109 
122 struct Rect {
123  uint32_t x;
124  uint32_t y;
125  uint32_t width;
126  uint32_t height;
127 } __attribute__((packed));
128 
134 struct reservedpx {
135  uint32_t left;
136  uint32_t right;
137  uint32_t top;
138  uint32_t bottom;
139 };
140 
146 struct width_height {
147  uint32_t w;
148  uint32_t h;
149 };
150 
163  uint32_t background;
166 };
167 
173  char *name;
174  char *output;
175 
177 };
178 
179 struct Ignore_Event {
180  int sequence;
182  time_t added;
183 
184  SLIST_ENTRY(Ignore_Event) ignore_events;
185 };
186 
194  char *id;
196  char *workspace;
198  SnLauncherContext *context;
201  time_t delete_at;
202 
203  TAILQ_ENTRY(Startup_Sequence) sequences;
204 };
205 
215 struct regex {
216  char *pattern;
217  pcre *regex;
218  pcre_extra *extra;
219 };
220 
221 /******************************************************************************
222  * Major types
223  *****************************************************************************/
224 
231 struct Binding {
232  /* The type of input this binding is for. (Mouse bindings are not yet
233  * implemented. All bindings are currently assumed to be keyboard bindings.) */
235 
238  enum {
239  /* This binding will only be executed upon KeyPress events */
240  B_UPON_KEYPRESS = 0,
241  /* This binding will be executed either upon a KeyRelease event, or… */
242  B_UPON_KEYRELEASE = 1,
243  /* …upon a KeyRelease event, even if the modifiers don’t match. This
244  * state is triggered from get_binding() when the corresponding
245  * KeyPress (!) happens, so that users can release the modifier keys
246  * before releasing the actual key. */
247  B_UPON_KEYRELEASE_IGNORE_MODS = 2,
248  } release;
249 
250  uint32_t number_keycodes;
251 
253  uint32_t keycode;
254 
256  uint32_t mods;
257 
261  char *symbol;
262 
268  xcb_keycode_t *translated_to;
269 
270 
272  char *command;
273 
275 };
276 
284 struct Autostart {
286  char *command;
290  TAILQ_ENTRY(Autostart) autostarts;
291  TAILQ_ENTRY(Autostart) autostarts_always;
292 };
293 
301 struct xoutput {
303  xcb_randr_output_t id;
304 
307  bool active;
308 
311  bool changed;
313  bool primary;
314 
316  char *name;
317 
320 
323 
324  TAILQ_ENTRY(xoutput) outputs;
325 };
326 
332 struct Window {
333  xcb_window_t id;
334 
337  xcb_window_t leader;
338  xcb_window_t transient_for;
339 
342  uint32_t nr_assignments;
344 
345  char *class_class;
347 
350 
354  char *role;
355 
358 
361 
364 
368 
370  enum { W_NODOCK = 0, W_DOCK_TOP = 1, W_DOCK_BOTTOM = 2 } dock;
371 
373  struct timeval urgent;
374 
376  struct reservedpx reserved;
377 
379  uint16_t depth;
380 };
381 
390 struct Match {
391  struct regex *title;
393  struct regex *class;
394  struct regex *instance;
395  struct regex *mark;
397  enum {
398  U_DONTCHECK = -1,
399  U_LATEST = 0,
400  U_OLDEST = 1
401  } urgent;
402  enum {
403  M_DONTCHECK = -1,
404  M_NODOCK = 0,
405  M_DOCK_ANY = 1,
406  M_DOCK_TOP = 2,
407  M_DOCK_BOTTOM = 3
408  } dock;
409  xcb_window_t id;
410  enum { M_ANY = 0, M_TILING, M_FLOATING } floating;
412 
413  /* Where the window looking for a match should be inserted:
414  *
415  * M_HERE = the matched container will be replaced by the window
416  * (layout saving)
417  * M_ASSIGN_WS = the matched container will be inserted in the target_ws.
418  * M_BELOW = the window will be inserted as a child of the matched container
419  * (dockareas)
420  *
421  */
422  enum { M_HERE = 0, M_ASSIGN_WS, M_BELOW } insert_where;
423 
424  TAILQ_ENTRY(Match) matches;
425 
426  /* Whether this match was generated when restarting i3 inplace.
427  * Leads to not setting focus when managing a new window, because the old
428  * focus stack should be restored. */
429  bool restart_mode;
430 };
431 
440 struct Assignment {
452  enum {
453  A_ANY = 0,
454  A_COMMAND = (1 << 0),
455  A_TO_WORKSPACE = (1 << 1),
456  A_TO_OUTPUT = (1 << 2)
457  } type;
458 
461 
463  union {
464  char *command;
465  char *workspace;
466  char *output;
467  } dest;
468 
469  TAILQ_ENTRY(Assignment) assignments;
470 };
471 
473 typedef enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode_t;
474 
479 struct Con {
480  bool mapped;
481 
482  /* Should this container be marked urgent? This gets set when the window
483  * inside this container (if any) sets the urgency hint, for example. */
484  bool urgent;
485 
491  uint8_t ignore_unmap;
492 
493  /* ids/pixmap/graphics context for the frame window */
495  xcb_window_t frame;
496  xcb_pixmap_t pixmap;
497  xcb_gcontext_t pm_gc;
498 
499  enum {
500  CT_ROOT = 0,
501  CT_OUTPUT = 1,
502  CT_CON = 2,
503  CT_FLOATING_CON = 3,
504  CT_WORKSPACE = 4,
505  CT_DOCKAREA = 5
506  } type;
507 
510  int num;
511 
512  struct Con *parent;
513 
514  struct Rect rect;
515  struct Rect window_rect;
516  struct Rect deco_rect;
518  struct Rect geometry;
519 
520  char *name;
521 
522  /* a sticky-group is an identifier which bundles several containers to a
523  * group. The contents are shared between all of them, that is they are
524  * displayed on whichever of the containers is currently visible */
526 
527  /* user-definable mark to jump to this container later */
528  char *mark;
529 
530  double percent;
531 
532  /* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
533  double aspect_ratio;
534  /* the wanted size of the window, used in combination with size
535  * increments (see below). */
538 
539  /* the x11 border pixel attribute */
542 
543  /* minimum increment size specified for the window (in pixels) */
546 
547  struct Window *window;
548 
549  /* timer used for disabling urgency */
550  struct ev_timer *urgency_timer;
551 
554 
555  /* Only workspace-containers can have floating clients */
556  TAILQ_HEAD(floating_head, Con) floating_head;
557 
558  TAILQ_HEAD(nodes_head, Con) nodes_head;
559  TAILQ_HEAD(focus_head, Con) focus_head;
560 
561  TAILQ_HEAD(swallow_head, Match) swallow_head;
562 
563  fullscreen_mode_t fullscreen_mode;
564  /* layout is the layout of this container: one of split[v|h], stacked or
565  * tabbed. Special containers in the tree (above workspaces) have special
566  * layouts like dockarea or output.
567  *
568  * last_split_layout is one of splitv or splith to support the old "layout
569  * default" command which by now should be "layout splitv" or "layout
570  * splith" explicitly.
571  *
572  * workspace_layout is only for type == CT_WORKSPACE cons. When you change
573  * the layout of a workspace without any children, i3 cannot just set the
574  * layout (because workspaces need to be splitv/splith to allow focus
575  * parent and opening new containers). Instead, it stores the requested
576  * layout in workspace_layout and creates a new split container with that
577  * layout whenever a new container is attached to the workspace. */
578  layout_t layout, last_split_layout, workspace_layout;
586  enum {
587  FLOATING_AUTO_OFF = 0,
588  FLOATING_USER_OFF = 1,
589  FLOATING_AUTO_ON = 2,
590  FLOATING_USER_ON = 3
591  } floating;
592 
593  TAILQ_ENTRY(Con) nodes;
596  TAILQ_ENTRY(Con) floating_windows;
597 
599  void(*on_remove_child)(Con *);
600 
601  enum {
602  /* Not a scratchpad window. */
603  SCRATCHPAD_NONE = 0,
604 
605  /* Just moved to scratchpad, not resized by the user yet.
606  * Window will be auto-centered and sized appropriately. */
607  SCRATCHPAD_FRESH = 1,
608 
609  /* The user changed position/size of the scratchpad window. */
610  SCRATCHPAD_CHANGED = 2
611  } scratchpad_state;
612 
613  /* The ID of this container before restarting. Necessary to correctly
614  * interpret back-references in the JSON (such as the focus stack). */
615  int old_id;
616 
617  /* Depth of the container window */
618  uint16_t depth;
619 };
struct reservedpx __attribute__
Definition: data.h:87
uint32_t top
Definition: data.h:137
struct Con * parent
Definition: data.h:512
bool mapped
Definition: data.h:480
bool pixmap_recreated
Definition: data.h:494
bool urgent
Definition: data.h:484
char * output
Definition: data.h:466
char * name
Name of the output.
Definition: data.h:316
char * symbol
Symbol the user specified in configfile, if any.
Definition: data.h:261
direction_t
Definition: data.h:54
Definition: data.h:56
int height_increment
Definition: data.h:545
fullscreen_mode_t
Fullscreen modes.
Definition: data.h:473
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely...
Definition: data.h:491
uint32_t y
Definition: data.h:124
border_style_t
Definition: data.h:56
double percent
Definition: data.h:530
xcb_gcontext_t pm_gc
Definition: data.h:497
char * sticky_group
Definition: data.h:525
Stores which workspace (by name or number) goes to which output.
Definition: data.h:172
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
Definition: data.h:360
Definition: data.h:54
bool to_be_disabled
Definition: data.h:312
warping_t
Mouse pointer warping modes.
Definition: data.h:105
bool needs_take_focus
Whether the application needs to receive WM_TAKE_FOCUS.
Definition: data.h:363
Stores a rectangle, for example the size of a window, the child window etc.
Definition: data.h:122
An Assignment makes specific windows go to a specific workspace/output or run a command for that wind...
Definition: data.h:440
Definition: data.h:56
xcb_randr_output_t id
Output id, so that we can requery the output directly later.
Definition: data.h:303
input_type_t input_type
Definition: data.h:234
#define SLIST_ENTRY(type)
Definition: queue.h:101
struct all_cons_head all_cons
Definition: tree.c:17
char * mark
Definition: data.h:528
Rect rect
x, y, width, height
Definition: data.h:322
int current_border_width
Definition: data.h:541
time_t delete_at
time at which this sequence should be deleted (after it was marked as completed)
Definition: data.h:201
struct regex * window_role
Definition: data.h:396
struct regex * mark
Definition: data.h:395
struct width_height con_rect
Definition: data.h:160
uint16_t depth
Depth of the window.
Definition: data.h:379
Definition: data.h:54
Definition: data.h:75
struct Window * window
Definition: data.h:547
char * class_instance
Definition: data.h:346
Definition: data.h:73
int border_width
Definition: data.h:540
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
Definition: data.h:357
An Output is a physical output on your graphics driver.
Definition: data.h:301
layout_t
Container layouts.
Definition: data.h:84
Stores the parameters for rendering a window decoration.
Definition: data.h:157
A &#39;Window&#39; is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition: data.h:332
TAILQ_ENTRY(Workspace_Assignment) ws_assignments
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
Definition: data.h:231
uint32_t w
Definition: data.h:147
uint32_t background
Definition: data.h:163
int base_width
Definition: data.h:536
Definition: data.h:85
xcb_window_t transient_for
Definition: data.h:338
int response_type
Definition: data.h:181
uint32_t right
Definition: data.h:136
struct regex * instance
Definition: data.h:394
struct regex * application
Definition: data.h:392
uint32_t bottom
Definition: data.h:138
char * command
Command, like in command mode.
Definition: data.h:272
double aspect_ratio
Definition: data.h:533
Definition: data.h:86
Definition: data.h:76
int old_id
Definition: data.h:615
int sequence
Definition: data.h:180
uint32_t nr_assignments
Pointers to the Assignments which were already ran for this Window (assignments run only once) ...
Definition: data.h:342
xcb_window_t id
Definition: data.h:409
struct _i3String i3String
Opaque data structure for storing strings.
Definition: libi3.h:28
Definition: data.h:473
uint16_t depth
Definition: data.h:618
int border_style
Definition: data.h:159
uint32_t number_keycodes
Definition: data.h:250
struct outputs_head outputs
Definition: randr.c:28
uint32_t height
Definition: data.h:126
Definition: data.h:74
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
Definition: data.h:553
Definition: data.h:77
Definition: data.h:54
Con * focused
Definition: tree.c:15
Con * con
Pointer to the Con which represents this output.
Definition: data.h:319
Con * con_id
Definition: data.h:411
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
Definition: data.h:510
Definition: data.h:99
bool con_is_leaf
Definition: data.h:165
char * name
Definition: data.h:520
pcre * regex
Definition: data.h:217
Definition: data.h:91
input_type_t
Binding input types.
Definition: data.h:97
struct autostarts_head autostarts
Definition: main.c:83
bool no_startup_id
no_startup_id flag for start_application().
Definition: data.h:289
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
Definition: data.h:134
struct width_height con_window_rect
Definition: data.h:161
struct assignments_head assignments
Definition: main.c:89
int base_height
Definition: data.h:537
bool active
Whether the output is currently active (has a CRTC attached with a valid mode)
Definition: data.h:307
Definition: data.h:54
bool changed
Internal flags, necessary for querying RandR screens (happens in two stages)
Definition: data.h:311
Definition: data.h:55
A &quot;match&quot; is a data structure which acts like a mask or expression to match certain windows or not...
Definition: data.h:390
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets &quot;buddy list&quot;)...
Definition: data.h:354
Stores a width/height pair, used as part of deco_render_params to check whether the rects width/heigh...
Definition: data.h:146
A &#39;Con&#39; represents everything from the X11 root window down to a single X11 window.
Definition: data.h:479
uint32_t x
Definition: data.h:123
time_t added
Definition: data.h:182
struct bindings_head * bindings
Definition: main.c:80
Definition: data.h:89
struct regex * title
Definition: data.h:391
orientation_t
Definition: data.h:55
uint32_t keycode
Keycode to bind.
Definition: data.h:253
uint32_t h
Definition: data.h:148
Definition: data.h:70
char * workspace
Definition: data.h:465
xcb_window_t frame
Definition: data.h:495
Part of the struct Config.
Definition: config.h:52
uint32_t mods
Bitmask consisting of BIND_MOD_1, BIND_MODE_SWITCH, …
Definition: data.h:256
Regular expression wrapper.
Definition: data.h:215
adjacent_t
describes if the window is adjacent to the output (physical screen) edges.
Definition: data.h:63
Definition: data.h:63
uint32_t left
Definition: data.h:135
char * command
Command, like in command mode.
Definition: data.h:286
char * pattern
Definition: data.h:216
i3String * name
The name of the window.
Definition: data.h:349
xcb_window_t id
Definition: data.h:333
char * class_class
Definition: data.h:345
Match match
the criteria to check if a window matches
Definition: data.h:460
xcb_keycode_t * translated_to
Only in use if symbol != NULL.
Definition: data.h:268
bool doesnt_accept_focus
Whether this window accepts focus.
Definition: data.h:367
Definition: data.h:55
Rect con_deco_rect
Definition: data.h:162
char * command
Definition: data.h:464
xcb_pixmap_t pixmap
Definition: data.h:496
char * id
startup ID for this sequence, generated by libstartup-notification
Definition: data.h:194
xcb_window_t leader
Holds the xcb_window_t (just an ID) for the leader window (logical parent for toolwindows and similar...
Definition: data.h:337
SnLauncherContext * context
libstartup-notification context for this launch
Definition: data.h:198
struct Colortriple * color
Definition: data.h:158
struct autostarts_always_head autostarts_always
Definition: main.c:86
Holds a command specified by either an:
Definition: data.h:284
bool primary
Definition: data.h:313
struct ws_assignments_head ws_assignments
Definition: main.c:93
layout_t parent_layout
Definition: data.h:164
Definition: data.h:56
#define TAILQ_HEAD(name, type)
Definition: queue.h:305
Assignment ** ran_assignments
Definition: data.h:343
char * workspace
workspace on which this startup was initiated
Definition: data.h:196
int width_increment
Definition: data.h:544
kill_window_t
parameter to specify whether tree_close() and x_window_kill() should kill only this specific window o...
Definition: data.h:60
uint32_t width
Definition: data.h:125
Definition: data.h:90
Stores internal information about a startup sequence, like the workspace it was initiated on...
Definition: data.h:192
struct ev_timer * urgency_timer
Definition: data.h:550
pcre_extra * extra
Definition: data.h:218