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 #include "libi3.h"
13 
14 #define SN_API_NOT_YET_FROZEN 1
15 #include <libsn/sn-launcher.h>
16 
17 #include <xcb/randr.h>
18 #include <stdbool.h>
19 #include <pcre.h>
20 #include <sys/time.h>
21 
22 #include "queue.h"
23 
24 /*
25  * To get the big concept: There are helper structures like struct
26  * Workspace_Assignment. Every struct which is also defined as type (see
27  * forward definitions) is considered to be a major structure, thus important.
28  *
29  * The following things are all stored in a 'Con', from very high level (the
30  * biggest Cons) to very small (a single window):
31  *
32  * 1) X11 root window (as big as all your outputs combined)
33  * 2) output (like LVDS1)
34  * 3) content container, dockarea containers
35  * 4) workspaces
36  * 5) split containers
37  * ... (you can arbitrarily nest split containers)
38  * 6) X11 window containers
39  *
40  */
41 
42 /* Forward definitions */
43 typedef struct Binding Binding;
44 typedef struct Rect Rect;
45 typedef struct xoutput Output;
46 typedef struct Con Con;
47 typedef struct Match Match;
48 typedef struct Assignment Assignment;
49 typedef struct Window i3Window;
50 typedef struct mark_t mark_t;
51 
52 /******************************************************************************
53  * Helper types
54  *****************************************************************************/
55 typedef enum { D_LEFT,
59 typedef enum { NO_ORIENTATION = 0,
62 typedef enum { BS_NORMAL = 0,
63  BS_NONE = 1,
65 
68 typedef enum { DONT_KILL_WINDOW = 0,
71 
73 typedef enum { ADJ_NONE = 0,
78 
79 typedef enum { HEBM_NONE = ADJ_NONE,
84 
85 typedef enum { MM_REPLACE,
87 
91 typedef enum {
92  L_DEFAULT = 0,
93  L_STACKED = 1,
94  L_TABBED = 2,
96  L_OUTPUT = 4,
97  L_SPLITV = 5,
99 } layout_t;
100 
104 typedef enum {
107 } input_type_t;
108 
112 typedef enum {
119 
126 typedef uint32_t i3_event_state_mask_t;
131 typedef enum {
134 } warping_t;
135 
148 struct Rect {
149  uint32_t x;
150  uint32_t y;
151  uint32_t width;
152  uint32_t height;
153 } __attribute__((packed));
154 
160 struct reservedpx {
161  uint32_t left;
162  uint32_t right;
163  uint32_t top;
164  uint32_t bottom;
165 };
166 
172 struct width_height {
173  uint32_t w;
174  uint32_t h;
175 };
176 
186  struct width_height con_rect;
187  struct width_height con_window_rect;
192 };
193 
199  char *name;
200  char *output;
201 
204 };
205 
206 struct Ignore_Event {
207  int sequence;
209  time_t added;
210 
211  SLIST_ENTRY(Ignore_Event)
212  ignore_events;
213 };
214 
222  char *id;
224  char *workspace;
226  SnLauncherContext *context;
229  time_t delete_at;
230 
231  TAILQ_ENTRY(Startup_Sequence)
232  sequences;
233 };
234 
244 struct regex {
245  char *pattern;
246  pcre *regex;
247  pcre_extra *extra;
248 };
249 
256  xcb_keycode_t keycode;
257  i3_event_state_mask_t modifiers;
258 
260  keycodes;
261 };
262 
263 /******************************************************************************
264  * Major types
265  *****************************************************************************/
266 
273 struct Binding {
274  /* The type of input this binding is for. (Mouse bindings are not yet
275  * implemented. All bindings are currently assumed to be keyboard bindings.) */
277 
280  enum {
281  /* This binding will only be executed upon KeyPress events */
282  B_UPON_KEYPRESS = 0,
283  /* This binding will be executed either upon a KeyRelease event, or… */
284  B_UPON_KEYRELEASE = 1,
285  /* …upon a KeyRelease event, even if the modifiers don’t match. This
286  * state is triggered from get_binding() when the corresponding
287  * KeyPress (!) happens, so that users can release the modifier keys
288  * before releasing the actual key. */
289  B_UPON_KEYRELEASE_IGNORE_MODS = 2,
290  } release;
291 
294  bool border;
295 
300 
304 
306  uint32_t keycode;
307 
311  i3_event_state_mask_t event_state_mask;
312 
316  char *symbol;
317 
321  TAILQ_HEAD(keycodes_head, Binding_Keycode)
322  keycodes_head;
323 
325  char *command;
326 
327  TAILQ_ENTRY(Binding)
329 };
330 
338 struct Autostart {
340  char *command;
344 
345  TAILQ_ENTRY(Autostart)
347 
348  TAILQ_ENTRY(Autostart)
350 };
351 
352 struct output_name {
353  char *name;
354 
355  SLIST_ENTRY(output_name)
356  names;
357 };
358 
366 struct xoutput {
368  xcb_randr_output_t id;
369 
372  bool active;
373 
376  bool changed;
378  bool primary;
379 
383  SLIST_HEAD(names_head, output_name)
384  names_head;
385 
387  Con *con;
388 
390  Rect rect;
391 
392  TAILQ_ENTRY(xoutput)
394 };
395 
401 struct Window {
402  xcb_window_t id;
403 
406  xcb_window_t leader;
407  xcb_window_t transient_for;
408 
411  uint32_t nr_assignments;
413 
414  char *class_class;
416 
419 
423  char *role;
424 
427 
430 
433 
437 
439  xcb_atom_t window_type;
440 
442  uint32_t wm_desktop;
443 
445  enum { W_NODOCK = 0,
446  W_DOCK_TOP = 1,
447  W_DOCK_BOTTOM = 2 } dock;
448 
450  struct timeval urgent;
451 
453  struct reservedpx reserved;
454 
456  uint16_t depth;
457 
458  /* the wanted size of the window, used in combination with size
459  * increments (see below). */
462 
463  /* minimum increment size specified for the window (in pixels) */
466 
467  /* Minimum size specified for the window. */
470 
471  /* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
472  double aspect_ratio;
473 };
474 
483 struct Match {
484  /* Set if a criterion was specified incorrectly. */
485  char *error;
486 
487  struct regex *title;
489  struct regex *class;
490  struct regex *instance;
491  struct regex *mark;
493  struct regex *workspace;
494  xcb_atom_t window_type;
495  enum {
496  U_DONTCHECK = -1,
497  U_LATEST = 0,
498  U_OLDEST = 1
499  } urgent;
500  enum {
501  M_DONTCHECK = -1,
502  M_NODOCK = 0,
503  M_DOCK_ANY = 1,
504  M_DOCK_TOP = 2,
505  M_DOCK_BOTTOM = 3
506  } dock;
507  xcb_window_t id;
508  enum { WM_ANY = 0,
510  WM_FLOATING } window_mode;
512 
513  /* Where the window looking for a match should be inserted:
514  *
515  * M_HERE = the matched container will be replaced by the window
516  * (layout saving)
517  * M_ASSIGN_WS = the matched container will be inserted in the target_ws.
518  * M_BELOW = the window will be inserted as a child of the matched container
519  * (dockareas)
520  *
521  */
522  enum { M_HERE = 0,
524  M_BELOW } insert_where;
525 
527  matches;
528 
529  /* Whether this match was generated when restarting i3 inplace.
530  * Leads to not setting focus when managing a new window, because the old
531  * focus stack should be restored. */
532  bool restart_mode;
533 };
534 
543 struct Assignment {
555  enum {
556  A_ANY = 0,
557  A_COMMAND = (1 << 0),
558  A_TO_WORKSPACE = (1 << 1),
559  A_NO_FOCUS = (1 << 2)
560  } type;
561 
564 
566  union {
567  char *command;
568  char *workspace;
569  } dest;
570 
571  TAILQ_ENTRY(Assignment)
573 };
574 
576 typedef enum { CF_NONE = 0,
579 
580 struct mark_t {
581  char *name;
582 
585 };
586 
591 struct Con {
592  bool mapped;
593 
594  /* Should this container be marked urgent? This gets set when the window
595  * inside this container (if any) sets the urgency hint, for example. */
596  bool urgent;
597 
603  uint8_t ignore_unmap;
604 
605  /* The surface used for the frame window. */
609 
610  enum {
611  CT_ROOT = 0,
612  CT_OUTPUT = 1,
613  CT_CON = 2,
614  CT_FLOATING_CON = 3,
615  CT_WORKSPACE = 4,
616  CT_DOCKAREA = 5
617  } type;
618 
621  int num;
622 
623  struct Con *parent;
624 
625  /* The position and size for this con. These coordinates are absolute. Note
626  * that the rect of a container does not include the decoration. */
627  struct Rect rect;
628  /* The position and size of the actual client window. These coordinates are
629  * relative to the container's rect. */
630  struct Rect window_rect;
631  /* The position and size of the container's decoration. These coordinates
632  * are relative to the container's parent's rect. */
633  struct Rect deco_rect;
635  struct Rect geometry;
636 
637  char *name;
638 
641 
642  /* a sticky-group is an identifier which bundles several containers to a
643  * group. The contents are shared between all of them, that is they are
644  * displayed on whichever of the containers is currently visible */
646 
647  /* user-definable marks to jump to this container later */
648  TAILQ_HEAD(marks_head, mark_t)
649  marks_head;
650  /* cached to decide whether a redraw is needed */
651  bool mark_changed;
652 
653  double percent;
654 
655  /* the x11 border pixel attribute */
656  int border_width;
657  int current_border_width;
658 
659  struct Window *window;
660 
661  /* timer used for disabling urgency */
662  struct ev_timer *urgency_timer;
663 
666 
667  /* Only workspace-containers can have floating clients */
668  TAILQ_HEAD(floating_head, Con)
669  floating_head;
670 
671  TAILQ_HEAD(nodes_head, Con)
672  nodes_head;
673 
674  TAILQ_HEAD(focus_head, Con)
675  focus_head;
676 
677  TAILQ_HEAD(swallow_head, Match)
678  swallow_head;
679 
680  fullscreen_mode_t fullscreen_mode;
681 
682  /* Whether this window should stick to the glass. This corresponds to
683  * the _NET_WM_STATE_STICKY atom and will only be respected if the
684  * window is floating. */
685  bool sticky;
686 
687  /* layout is the layout of this container: one of split[v|h], stacked or
688  * tabbed. Special containers in the tree (above workspaces) have special
689  * layouts like dockarea or output.
690  *
691  * last_split_layout is one of splitv or splith to support the old "layout
692  * default" command which by now should be "layout splitv" or "layout
693  * splith" explicitly.
694  *
695  * workspace_layout is only for type == CT_WORKSPACE cons. When you change
696  * the layout of a workspace without any children, i3 cannot just set the
697  * layout (because workspaces need to be splitv/splith to allow focus
698  * parent and opening new containers). Instead, it stores the requested
699  * layout in workspace_layout and creates a new split container with that
700  * layout whenever a new container is attached to the workspace. */
701  layout_t layout, last_split_layout, workspace_layout;
702  border_style_t border_style;
709  enum {
710  FLOATING_AUTO_OFF = 0,
711  FLOATING_USER_OFF = 1,
712  FLOATING_AUTO_ON = 2,
713  FLOATING_USER_ON = 3
714  } floating;
715 
716  TAILQ_ENTRY(Con)
717  nodes;
718 
719  TAILQ_ENTRY(Con)
721 
722  TAILQ_ENTRY(Con)
724 
725  TAILQ_ENTRY(Con)
726  floating_windows;
727 
729  void (*on_remove_child)(Con *);
730 
731  enum {
732  /* Not a scratchpad window. */
733  SCRATCHPAD_NONE = 0,
734 
735  /* Just moved to scratchpad, not resized by the user yet.
736  * Window will be auto-centered and sized appropriately. */
737  SCRATCHPAD_FRESH = 1,
738 
739  /* The user changed position/size of the scratchpad window. */
740  SCRATCHPAD_CHANGED = 2
741  } scratchpad_state;
742 
743  /* The ID of this container before restarting. Necessary to correctly
744  * interpret back-references in the JSON (such as the focus stack). */
745  int old_id;
746 
747  /* Depth of the container window */
748  uint16_t depth;
749 
750  /* The colormap for this con if a custom one is used. */
751  xcb_colormap_t colormap;
752 };
static char ** marks
Definition: load_layout.c:34
double aspect_ratio
Definition: data.h:472
input_type_t input_type
Definition: data.h:276
border_style_t
Definition: data.h:62
struct _i3String i3String
Opaque data structure for storing strings.
Definition: libi3.h:48
uint32_t wm_desktop
The _NET_WM_DESKTOP for this window.
Definition: data.h:442
warping_t
Mouse pointer warping modes.
Definition: data.h:131
Con * focused
Definition: tree.c:13
struct outputs_head outputs
Definition: randr.c:21
uint32_t bottom
Definition: data.h:164
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
Definition: data.h:423
uint32_t nr_assignments
Pointers to the Assignments which were already ran for this Window (assignments run only once) ...
Definition: data.h:411
char * title_format
The format with which the window&#39;s name should be displayed.
Definition: data.h:640
char * id
startup ID for this sequence, generated by libstartup-notification
Definition: data.h:222
A &#39;Window&#39; is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition: data.h:401
input_type_t
Binding input types.
Definition: data.h:104
char * sticky_group
Definition: data.h:645
int min_height
Definition: data.h:469
int sequence
Definition: data.h:207
time_t added
Definition: data.h:209
int height_increment
Definition: data.h:465
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
Definition: data.h:426
Holds a command specified by either an:
Definition: data.h:338
#define TAILQ_HEAD(name, type)
Definition: queue.h:318
Definition: data.h:73
direction_t
Definition: data.h:55
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely...
Definition: data.h:603
int border_style
Definition: data.h:185
char * workspace
Definition: data.h:568
A &#39;Con&#39; represents everything from the X11 root window down to a single X11 window.
Definition: data.h:591
int base_height
Definition: data.h:461
An Assignment makes specific windows go to a specific workspace/output or run a command for that wind...
Definition: data.h:543
Part of the struct Config.
Definition: configuration.h:54
Definition: data.h:93
xcb_randr_output_t id
Output id, so that we can requery the output directly later.
Definition: data.h:368
xcb_window_t transient_for
Definition: data.h:407
i3_xkb_group_mask_t
Bitmask for matching XCB_XKB_GROUP_1 to XCB_XKB_GROUP_4.
Definition: data.h:112
bool urgent
Definition: data.h:596
uint16_t depth
Definition: data.h:748
Definition: libi3.h:402
#define SLIST_HEAD(name, type)
Definition: queue.h:93
struct bindings_head * bindings
Definition: main.c:76
struct autostarts_always_head autostarts_always
Definition: main.c:82
color_t background
Definition: data.h:189
uint32_t top
Definition: data.h:163
char * error
Definition: data.h:485
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:406
SnLauncherContext * context
libstartup-notification context for this launch
Definition: data.h:226
struct assignments_head assignments
Definition: main.c:85
Definition: data.h:62
Definition: data.h:57
uint32_t h
Definition: data.h:174
xcb_keycode_t keycode
Definition: data.h:256
uint32_t keycode
Keycode to bind.
Definition: data.h:306
hide_edge_borders_mode_t
Definition: data.h:79
surface_t frame
Definition: data.h:606
mark_mode_t
Definition: data.h:85
int response_type
Definition: data.h:208
char * pattern
Definition: data.h:245
xcb_atom_t window_type
Definition: data.h:494
Definition: data.h:60
Definition: data.h:63
Definition: data.h:96
bool needs_take_focus
Whether the application needs to receive WM_TAKE_FOCUS.
Definition: data.h:432
layout_t
Container layouts.
Definition: data.h:91
Assignment ** ran_assignments
Definition: data.h:412
uint32_t x
Definition: data.h:149
i3_event_state_mask_t modifiers
Definition: data.h:257
bool exclude_titlebar
If this is true for a mouse binding, the binding should only be executed if the button press was not ...
Definition: data.h:303
struct reservedpx __attribute__
int width_increment
Definition: data.h:464
uint32_t w
Definition: data.h:173
bool pixmap_recreated
Definition: data.h:608
Stores a width/height pair, used as part of deco_render_params to check whether the rects width/heigh...
Definition: data.h:172
struct regex * instance
Definition: data.h:490
int old_id
Definition: data.h:745
time_t delete_at
time at which this sequence should be deleted (after it was marked as completed)
Definition: data.h:229
char * command
Definition: data.h:567
char * name
Definition: data.h:637
xcb_window_t id
Definition: data.h:402
Con * con_id
Definition: data.h:511
bool mapped
Definition: data.h:592
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
Definition: data.h:429
Definition: data.h:61
Definition: data.h:55
Rect con_deco_rect
Definition: data.h:188
Regular expression wrapper.
Definition: data.h:244
struct regex * title
Definition: data.h:487
struct all_cons_head all_cons
Definition: tree.c:15
Stores which workspace (by name or number) goes to which output.
Definition: data.h:198
Definition: data.h:92
i3String * name
The name of the window.
Definition: data.h:418
char * name
Definition: data.h:353
kill_window_t
parameter to specify whether tree_close_internal() and x_window_kill() should kill only this specific...
Definition: data.h:68
struct regex * window_role
Definition: data.h:492
uint32_t y
Definition: data.h:150
pcre_extra * extra
Definition: data.h:247
uint16_t depth
Depth of the window.
Definition: data.h:456
char * name
Definition: data.h:581
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:299
Definition: data.h:97
An Output is a physical output on your graphics driver.
Definition: data.h:366
bool to_be_disabled
Definition: data.h:377
struct autostarts_head autostarts
Definition: main.c:79
int min_width
Definition: data.h:468
uint32_t height
Definition: data.h:152
adjacent_t
describes if the window is adjacent to the output (physical screen) edges.
Definition: data.h:73
uint32_t width
Definition: data.h:151
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
Definition: data.h:273
Definition: data.h:576
bool primary
Definition: data.h:378
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:311
fullscreen_mode_t
Fullscreen modes.
Definition: data.h:576
Definition: data.h:79
char * class_instance
Definition: data.h:415
struct regex * workspace
Definition: data.h:493
Definition: data.h:580
bool no_startup_id
no_startup_id flag for start_application().
Definition: data.h:343
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
Definition: data.h:160
Definition: data.h:94
Definition: data.h:56
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
Definition: data.h:483
struct regex * mark
Definition: data.h:491
struct ws_assignments_head ws_assignments
Definition: main.c:89
Definition: data.h:106
char * symbol
Symbol the user specified in configfile, if any.
Definition: data.h:316
orientation_t
Definition: data.h:59
uint32_t left
Definition: data.h:161
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
Definition: data.h:621
Definition: data.h:98
Definition: data.h:86
#define TAILQ_ENTRY(type)
Definition: queue.h:327
bool con_is_leaf
Definition: data.h:191
xcb_window_t id
Definition: data.h:507
Stores internal information about a startup sequence, like the workspace it was initiated on...
Definition: data.h:220
xcb_colormap_t colormap
Definition: data.h:751
struct regex * application
Definition: data.h:488
Definition: data.h:64
Stores the parameters for rendering a window decoration.
Definition: data.h:183
layout_t parent_layout
Definition: data.h:190
Definition: data.h:58
Stores a rectangle, for example the size of a window, the child window etc.
Definition: data.h:148
pcre * regex
Definition: data.h:246
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
Definition: data.h:439
bool changed
Internal flags, necessary for querying RandR screens (happens in two stages)
Definition: data.h:376
bool doesnt_accept_focus
Whether this window accepts focus.
Definition: data.h:436
surface_t frame_buffer
Definition: data.h:607
int base_width
Definition: data.h:460
struct Con * parent
Definition: data.h:623
bool active
Whether the output is currently active (has a CRTC attached with a valid mode)
Definition: data.h:372
struct Colortriple * color
Definition: data.h:184
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:126
Match match
the criteria to check if a window matches
Definition: data.h:563
char * workspace
workspace on which this startup was initiated
Definition: data.h:224
char * class_class
Definition: data.h:414
uint32_t right
Definition: data.h:162
Definition: data.h:82
#define SLIST_ENTRY(type)
Definition: queue.h:101
char * command
Command, like in command mode.
Definition: data.h:340
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:294
Stores a resolved keycode (from a keysym), including the modifier mask.
Definition: data.h:255