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 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 typedef struct mark_t mark_t;
50 
51 /******************************************************************************
52  * Helper types
53  *****************************************************************************/
54 typedef enum { D_LEFT,
58 typedef enum { NO_ORIENTATION = 0,
61 typedef enum { BS_NORMAL = 0,
62  BS_NONE = 1,
64 
67 typedef enum { DONT_KILL_WINDOW = 0,
70 
72 typedef enum { ADJ_NONE = 0,
77 
78 typedef enum { MM_REPLACE,
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 {
112 
119 typedef uint32_t i3_event_state_mask_t;
124 typedef enum {
127 } warping_t;
128 
132 typedef enum {
134  QUBE_RED = 1,
142 } qube_label_t;
143 
144 #define QUBE_NUM_LABELS 9
145 
158 struct Rect {
159  uint32_t x;
160  uint32_t y;
161  uint32_t width;
162  uint32_t height;
163 } __attribute__((packed));
164 
170 struct reservedpx {
171  uint32_t left;
172  uint32_t right;
173  uint32_t top;
174  uint32_t bottom;
175 };
176 
182 struct width_height {
183  uint32_t w;
184  uint32_t h;
185 };
186 
196  struct width_height con_rect;
197  struct width_height con_window_rect;
202 };
203 
209  char *name;
210  char *output;
211 
213 };
214 
215 struct Ignore_Event {
216  int sequence;
218  time_t added;
219 
220  SLIST_ENTRY(Ignore_Event) ignore_events;
221 };
222 
230  char *id;
232  char *workspace;
234  SnLauncherContext *context;
237  time_t delete_at;
238 
239  TAILQ_ENTRY(Startup_Sequence) sequences;
240 };
241 
251 struct regex {
252  char *pattern;
253  pcre *regex;
254  pcre_extra *extra;
255 };
256 
257 /******************************************************************************
258  * Major types
259  *****************************************************************************/
260 
267 struct Binding {
268  /* The type of input this binding is for. (Mouse bindings are not yet
269  * implemented. All bindings are currently assumed to be keyboard bindings.) */
271 
274  enum {
275  /* This binding will only be executed upon KeyPress events */
276  B_UPON_KEYPRESS = 0,
277  /* This binding will be executed either upon a KeyRelease event, or… */
278  B_UPON_KEYRELEASE = 1,
279  /* …upon a KeyRelease event, even if the modifiers don’t match. This
280  * state is triggered from get_binding() when the corresponding
281  * KeyPress (!) happens, so that users can release the modifier keys
282  * before releasing the actual key. */
283  B_UPON_KEYRELEASE_IGNORE_MODS = 2,
284  } release;
285 
288  bool border;
289 
294 
295  uint32_t number_keycodes;
296 
298  uint32_t keycode;
299 
303  i3_event_state_mask_t event_state_mask;
304 
308  char *symbol;
309 
315  xcb_keycode_t *translated_to;
316 
318  char *command;
319 
321 };
322 
330 struct Autostart {
332  char *command;
338 };
339 
347 struct xoutput {
349  xcb_randr_output_t id;
350 
353  bool active;
354 
357  bool changed;
359  bool primary;
360 
362  char *name;
363 
366 
369 
371 };
372 
378 struct Window {
379  xcb_window_t id;
380 
383  xcb_window_t leader;
384  xcb_window_t transient_for;
385 
388  uint32_t nr_assignments;
390 
391  char *class_class;
393 
396 
399 
402 
406  char *role;
407 
410 
413 
416 
420 
422  xcb_atom_t window_type;
423 
425  uint32_t wm_desktop;
426 
428  enum { W_NODOCK = 0,
429  W_DOCK_TOP = 1,
430  W_DOCK_BOTTOM = 2 } dock;
431 
433  struct timeval urgent;
434 
436  struct reservedpx reserved;
437 
439  uint16_t depth;
440 
441  /* the wanted size of the window, used in combination with size
442  * increments (see below). */
445 
446  /* minimum increment size specified for the window (in pixels) */
449 
450  /* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
451  double aspect_ratio;
452 };
453 
462 struct Match {
463  /* Set if a criterion was specified incorrectly. */
464  char *error;
465 
466  struct regex *title;
468  struct regex *class;
469  struct regex *instance;
470  struct regex *mark;
472  struct regex *workspace;
473  xcb_atom_t window_type;
474  enum {
475  U_DONTCHECK = -1,
476  U_LATEST = 0,
477  U_OLDEST = 1
478  } urgent;
479  enum {
480  M_DONTCHECK = -1,
481  M_NODOCK = 0,
482  M_DOCK_ANY = 1,
483  M_DOCK_TOP = 2,
484  M_DOCK_BOTTOM = 3
485  } dock;
486  xcb_window_t id;
487  enum { M_ANY = 0,
489  M_FLOATING } floating;
491 
492  /* Where the window looking for a match should be inserted:
493  *
494  * M_HERE = the matched container will be replaced by the window
495  * (layout saving)
496  * M_ASSIGN_WS = the matched container will be inserted in the target_ws.
497  * M_BELOW = the window will be inserted as a child of the matched container
498  * (dockareas)
499  *
500  */
501  enum { M_HERE = 0,
503  M_BELOW } insert_where;
504 
505  TAILQ_ENTRY(Match) matches;
506 
507  /* Whether this match was generated when restarting i3 inplace.
508  * Leads to not setting focus when managing a new window, because the old
509  * focus stack should be restored. */
511 };
512 
521 struct Assignment {
533  enum {
534  A_ANY = 0,
535  A_COMMAND = (1 << 0),
536  A_TO_WORKSPACE = (1 << 1),
537  A_NO_FOCUS = (1 << 2)
538  } type;
539 
542 
544  union {
545  char *command;
546  char *workspace;
547  } dest;
548 
550 };
551 
553 typedef enum { CF_NONE = 0,
556 
557 struct mark_t {
558  char *name;
559 
560  TAILQ_ENTRY(mark_t) marks;
561 };
562 
567 struct Con {
568  bool mapped;
569 
570  /* Should this container be marked urgent? This gets set when the window
571  * inside this container (if any) sets the urgency hint, for example. */
572  bool urgent;
573 
579  uint8_t ignore_unmap;
580 
581  /* The surface used for the frame window. */
585 
586  enum {
587  CT_ROOT = 0,
588  CT_OUTPUT = 1,
589  CT_CON = 2,
590  CT_FLOATING_CON = 3,
591  CT_WORKSPACE = 4,
592  CT_DOCKAREA = 5
593  } type;
594 
597  int num;
598 
599  struct Con *parent;
600 
601  /* The position and size for this con. These coordinates are absolute. Note
602  * that the rect of a container does not include the decoration. */
603  struct Rect rect;
604  /* The position and size of the actual client window. These coordinates are
605  * relative to the container's rect. */
606  struct Rect window_rect;
607  /* The position and size of the container's decoration. These coordinates
608  * are relative to the container's parent's rect. */
609  struct Rect deco_rect;
611  struct Rect geometry;
612 
613  char *name;
614 
617 
618  /* a sticky-group is an identifier which bundles several containers to a
619  * group. The contents are shared between all of them, that is they are
620  * displayed on whichever of the containers is currently visible */
622 
623  /* user-definable marks to jump to this container later */
624  TAILQ_HEAD(marks_head, mark_t) marks_head;
625  /* cached to decide whether a redraw is needed */
627 
628  double percent;
629 
630  /* the x11 border pixel attribute */
633 
634  struct Window *window;
635 
636  /* timer used for disabling urgency */
637  struct ev_timer *urgency_timer;
638 
641 
642  /* Only workspace-containers can have floating clients */
643  TAILQ_HEAD(floating_head, Con) floating_head;
644 
645  TAILQ_HEAD(nodes_head, Con) nodes_head;
646  TAILQ_HEAD(focus_head, Con) focus_head;
647 
648  TAILQ_HEAD(swallow_head, Match) swallow_head;
649 
651 
652  /* Whether this window should stick to the glass. This corresponds to
653  * the _NET_WM_STATE_STICKY atom and will only be respected if the
654  * window is floating. */
655  bool sticky;
656 
657  /* layout is the layout of this container: one of split[v|h], stacked or
658  * tabbed. Special containers in the tree (above workspaces) have special
659  * layouts like dockarea or output.
660  *
661  * last_split_layout is one of splitv or splith to support the old "layout
662  * default" command which by now should be "layout splitv" or "layout
663  * splith" explicitly.
664  *
665  * workspace_layout is only for type == CT_WORKSPACE cons. When you change
666  * the layout of a workspace without any children, i3 cannot just set the
667  * layout (because workspaces need to be splitv/splith to allow focus
668  * parent and opening new containers). Instead, it stores the requested
669  * layout in workspace_layout and creates a new split container with that
670  * layout whenever a new container is attached to the workspace. */
671  layout_t layout, last_split_layout, workspace_layout;
679  enum {
680  FLOATING_AUTO_OFF = 0,
681  FLOATING_USER_OFF = 1,
682  FLOATING_AUTO_ON = 2,
683  FLOATING_USER_ON = 3
684  } floating;
685 
686  TAILQ_ENTRY(Con) nodes;
689  TAILQ_ENTRY(Con) floating_windows;
690 
692  void (*on_remove_child)(Con *);
693 
694  enum {
695  /* Not a scratchpad window. */
696  SCRATCHPAD_NONE = 0,
697 
698  /* Just moved to scratchpad, not resized by the user yet.
699  * Window will be auto-centered and sized appropriately. */
700  SCRATCHPAD_FRESH = 1,
701 
702  /* The user changed position/size of the scratchpad window. */
703  SCRATCHPAD_CHANGED = 2
704  } scratchpad_state;
705 
706  /* The ID of this container before restarting. Necessary to correctly
707  * interpret back-references in the JSON (such as the focus stack). */
708  int old_id;
709 
710  /* Depth of the container window */
711  uint16_t depth;
712 };
char * id
startup ID for this sequence, generated by libstartup-notification
Definition: data.h:230
struct regex * title
Definition: data.h:466
bool restart_mode
Definition: data.h:510
bool border
If this is true for a mouse binding, the binding should be executed when the button is pressed over t...
Definition: data.h:288
uint32_t w
Definition: data.h:183
i3_event_state_mask_t event_state_mask
Bitmask which is applied against event->state for KeyPress and KeyRelease events to determine whether...
Definition: data.h:303
char * name
Definition: data.h:558
xcb_keycode_t * translated_to
Only in use if symbol != NULL.
Definition: data.h:315
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
Definition: data.h:640
char * workspace
Definition: data.h:546
uint16_t depth
Depth of the window.
Definition: data.h:439
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
Definition: data.h:412
int border_width
Definition: data.h:631
Stores the parameters for rendering a window decoration.
Definition: data.h:193
int qubes_label
The qubes label.
Definition: data.h:401
struct assignments_head assignments
Definition: main.c:82
A &#39;Con&#39; represents everything from the X11 root window down to a single X11 window.
Definition: data.h:567
Stores a rectangle, for example the size of a window, the child window etc.
Definition: data.h:158
struct outputs_head outputs
Definition: randr.c:28
Match match
the criteria to check if a window matches
Definition: data.h:541
struct autostarts_head autostarts
Definition: main.c:76
Definition: data.h:79
uint32_t keycode
Keycode to bind.
Definition: data.h:298
bool mark_changed
Definition: data.h:626
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
Definition: data.h:422
Definition: data.h:55
Definition: data.h:72
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
Definition: data.h:267
border_style_t
Definition: data.h:61
warping_t
Mouse pointer warping modes.
Definition: data.h:124
bool to_be_disabled
Definition: data.h:358
Rect rect
x, y, width, height
Definition: data.h:368
bool primary
Definition: data.h:359
int border_style
Definition: data.h:195
Stores a width/height pair, used as part of deco_render_params to check whether the rects width/heigh...
Definition: data.h:182
fullscreen_mode_t
Fullscreen modes.
Definition: data.h:553
uint16_t depth
Definition: data.h:711
struct bindings_head * bindings
Definition: main.c:73
bool needs_take_focus
Whether the application needs to receive WM_TAKE_FOCUS.
Definition: data.h:415
struct regex * window_role
Definition: data.h:471
struct regex * mark
Definition: data.h:470
struct autostarts_always_head autostarts_always
Definition: main.c:79
uint32_t wm_desktop
The _NET_WM_DESKTOP for this window.
Definition: data.h:425
uint32_t number_keycodes
Definition: data.h:295
Definition: data.h:59
An Assignment makes specific windows go to a specific workspace/output or run a command for that wind...
Definition: data.h:521
layout_t
Container layouts.
Definition: data.h:84
xcb_window_t transient_for
Definition: data.h:384
An Output is a physical output on your graphics driver.
Definition: data.h:347
uint32_t top
Definition: data.h:173
char * name
Definition: data.h:613
fullscreen_mode_t fullscreen_mode
Definition: data.h:650
Regular expression wrapper.
Definition: data.h:251
xcb_atom_t window_type
Definition: data.h:473
Definition: data.h:60
Con * con
Pointer to the Con which represents this output.
Definition: data.h:365
struct Colortriple * color
Definition: data.h:194
Stores which workspace (by name or number) goes to which output.
Definition: data.h:208
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
Definition: data.h:409
color_t background
Definition: data.h:199
xcb_randr_output_t id
Output id, so that we can requery the output directly later.
Definition: data.h:349
Definition: data.h:557
char * command
Definition: data.h:545
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
Definition: data.h:462
struct ws_assignments_head ws_assignments
Definition: main.c:86
Holds a command specified by either an:
Definition: data.h:330
layout_t parent_layout
Definition: data.h:200
pcre * regex
Definition: data.h:253
Definition: data.h:56
bool no_startup_id
no_startup_id flag for start_application().
Definition: data.h:335
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
Definition: data.h:406
int current_border_width
Definition: data.h:632
kill_window_t
parameter to specify whether tree_close_internal() and x_window_kill() should kill only this specific...
Definition: data.h:67
time_t delete_at
time at which this sequence should be deleted (after it was marked as completed)
Definition: data.h:237
struct regex * application
Definition: data.h:467
bool whole_window
If this is true for a mouse binding, the binding should be executed when the button is pressed over a...
Definition: data.h:293
orientation_t
Definition: data.h:58
Con * con_id
Definition: data.h:490
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:383
bool pixmap_recreated
Definition: data.h:584
bool changed
Internal flags, necessary for querying RandR screens (happens in two stages)
Definition: data.h:357
Part of the struct Config.
Definition: config.h:52
surface_t frame_buffer
Definition: data.h:583
int response_type
Definition: data.h:217
int width_increment
Definition: data.h:447
uint32_t left
Definition: data.h:171
struct Con * parent
Definition: data.h:599
i3String * qubes_vmname
The name of the qubes vm.
Definition: data.h:398
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely...
Definition: data.h:579
input_type_t input_type
Definition: data.h:270
char * class_class
Definition: data.h:391
Definition: data.h:61
Definition: data.h:91
bool urgent
Definition: data.h:572
i3_xkb_group_mask_t
Bitmask for matching XCB_XKB_GROUP_1 to XCB_XKB_GROUP_4.
Definition: data.h:105
int base_height
Definition: data.h:444
char * name
Name of the output.
Definition: data.h:362
struct regex * instance
Definition: data.h:469
struct reservedpx __attribute__
#define SLIST_ENTRY(type)
Definition: queue.h:101
Definition: data.h:90
bool active
Whether the output is currently active (has a CRTC attached with a valid mode)
Definition: data.h:353
int base_width
Definition: data.h:443
Definition: data.h:62
uint32_t x
Definition: data.h:159
struct all_cons_head all_cons
Definition: tree.c:17
uint32_t right
Definition: data.h:172
char * title_format
The format with which the window&#39;s name should be displayed.
Definition: data.h:616
bool doesnt_accept_focus
Whether this window accepts focus.
Definition: data.h:419
Definition: libi3.h:396
int height_increment
Definition: data.h:448
#define TAILQ_HEAD(name, type)
Definition: queue.h:318
SnLauncherContext * context
libstartup-notification context for this launch
Definition: data.h:234
Definition: data.h:85
struct ev_timer * urgency_timer
Definition: data.h:637
struct regex * workspace
Definition: data.h:472
struct Window * window
Definition: data.h:634
Definition: data.h:89
char * command
Command, like in command mode.
Definition: data.h:332
xcb_window_t id
Definition: data.h:486
Definition: data.h:63
bool con_is_leaf
Definition: data.h:201
int sequence
Definition: data.h:216
qube_label_t
Qubes colors.
Definition: data.h:132
bool mapped
Definition: data.h:568
uint32_t bottom
Definition: data.h:174
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
Definition: data.h:597
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
Definition: data.h:170
struct _i3String i3String
Opaque data structure for storing strings.
Definition: libi3.h:40
Definition: data.h:87
uint32_t i3_event_state_mask_t
The lower 16 bits contain a xcb_key_but_mask_t, the higher 16 bits contain an i3_xkb_group_mask_t.
Definition: data.h:119
direction_t
Definition: data.h:54
Definition: data.h:553
Rect con_deco_rect
Definition: data.h:198
i3String * name
The name of the window.
Definition: data.h:395
time_t added
Definition: data.h:218
Assignment ** ran_assignments
Definition: data.h:389
#define TAILQ_ENTRY(type)
Definition: queue.h:327
Definition: data.h:54
Definition: data.h:134
bool sticky
Definition: data.h:655
uint32_t width
Definition: data.h:161
uint32_t nr_assignments
Pointers to the Assignments which were already ran for this Window (assignments run only once) ...
Definition: data.h:388
Definition: data.h:86
double percent
Definition: data.h:628
char * sticky_group
Definition: data.h:621
char * command
Command, like in command mode.
Definition: data.h:318
border_style_t border_style
Definition: data.h:672
pcre_extra * extra
Definition: data.h:254
xcb_window_t id
Definition: data.h:379
char * class_instance
Definition: data.h:392
Stores internal information about a startup sequence, like the workspace it was initiated on...
Definition: data.h:228
int old_id
Definition: data.h:708
Definition: data.h:57
Definition: data.h:99
char * symbol
Symbol the user specified in configfile, if any.
Definition: data.h:308
char * workspace
workspace on which this startup was initiated
Definition: data.h:232
uint32_t h
Definition: data.h:184
surface_t frame
Definition: data.h:582
mark_mode_t
Definition: data.h:78
uint32_t y
Definition: data.h:160
input_type_t
Binding input types.
Definition: data.h:97
char * pattern
Definition: data.h:252
double aspect_ratio
Definition: data.h:451
char * error
Definition: data.h:464
layout_t workspace_layout
Definition: data.h:671
A &#39;Window&#39; is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition: data.h:378
Con * focused
Definition: tree.c:15
uint32_t height
Definition: data.h:162
adjacent_t
describes if the window is adjacent to the output (physical screen) edges.
Definition: data.h:72