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 gaps_t gaps_t;
51 typedef struct mark_t mark_t;
52 
53 /******************************************************************************
54  * Helper types
55  *****************************************************************************/
56 typedef enum { D_LEFT,
60 typedef enum { NO_ORIENTATION = 0,
63 typedef enum { BS_NORMAL = 0,
64  BS_NONE = 1,
66 
69 typedef enum { DONT_KILL_WINDOW = 0,
72 
74 typedef enum { ADJ_NONE = 0,
79 
80 typedef enum { SMART_BORDERS_OFF,
83 
84 typedef enum { SMART_GAPS_OFF,
87 
88 typedef enum { HEBM_NONE = ADJ_NONE,
92  HEBM_SMART = (1 << 5),
94 
95 typedef enum { MM_REPLACE,
97 
101 typedef enum {
104  L_TABBED = 2,
106  L_OUTPUT = 4,
107  L_SPLITV = 5,
109 } layout_t;
110 
114 typedef enum {
117 } input_type_t;
118 
122 typedef enum {
129 
136 typedef uint32_t i3_event_state_mask_t;
141 typedef enum {
144 } warping_t;
145 
146 struct gaps_t {
147  int inner;
148  int top;
149  int right;
150  int bottom;
151  int left;
152 };
153 
157 typedef enum {
162 
175 struct Rect {
176  uint32_t x;
177  uint32_t y;
178  uint32_t width;
179  uint32_t height;
180 } __attribute__((packed));
181 
187 struct reservedpx {
188  uint32_t left;
189  uint32_t right;
190  uint32_t top;
191  uint32_t bottom;
192 };
193 
199 struct width_height {
200  uint32_t w;
201  uint32_t h;
202 };
203 
219 };
220 
226  char *name;
227  char *output;
229 
232 };
233 
234 struct Ignore_Event {
235  int sequence;
237  time_t added;
238 
240  ignore_events;
241 };
242 
250  char *id;
252  char *workspace;
254  SnLauncherContext *context;
257  time_t delete_at;
258 
260  sequences;
261 };
262 
272 struct regex {
273  char *pattern;
274  pcre *regex;
275  pcre_extra *extra;
276 };
277 
284  xcb_keycode_t keycode;
286 
288  keycodes;
289 };
290 
291 /******************************************************************************
292  * Major types
293  *****************************************************************************/
294 
301 struct Binding {
302  /* The type of input this binding is for. (Mouse bindings are not yet
303  * implemented. All bindings are currently assumed to be keyboard bindings.) */
305 
308  enum {
309  /* This binding will only be executed upon KeyPress events */
310  B_UPON_KEYPRESS = 0,
311  /* This binding will be executed either upon a KeyRelease event, or… */
312  B_UPON_KEYRELEASE = 1,
313  /* …upon a KeyRelease event, even if the modifiers don’t match. This
314  * state is triggered from get_binding() when the corresponding
315  * KeyPress (!) happens, so that users can release the modifier keys
316  * before releasing the actual key. */
317  B_UPON_KEYRELEASE_IGNORE_MODS = 2,
318  } release;
319 
322  bool border;
323 
328 
332 
334  uint32_t keycode;
335 
340 
344  char *symbol;
345 
349  TAILQ_HEAD(keycodes_head, Binding_Keycode)
350  keycodes_head;
351 
353  char *command;
354 
357 };
358 
366 struct Autostart {
368  char *command;
372 
375 
378 };
379 
380 struct output_name {
381  char *name;
382 
384  names;
385 };
386 
394 struct xoutput {
396  xcb_randr_output_t id;
397 
400  bool active;
401 
404  bool changed;
406  bool primary;
407 
411  SLIST_HEAD(names_head, output_name)
412  names_head;
413 
415  Con *con;
416 
418  Rect rect;
419 
422 };
423 
429 struct Window {
430  xcb_window_t id;
431 
434  xcb_window_t leader;
435  xcb_window_t transient_for;
436 
439  uint32_t nr_assignments;
441 
442  char *class_class;
444 
447 
451  char *role;
452 
455 
458 
461 
465 
467  xcb_atom_t window_type;
468 
470  uint32_t wm_desktop;
471 
473  enum { W_NODOCK = 0,
474  W_DOCK_TOP = 1,
475  W_DOCK_BOTTOM = 2 } dock;
476 
478  struct timeval urgent;
479 
481  struct reservedpx reserved;
482 
484  uint16_t depth;
485 
486  /* the wanted size of the window, used in combination with size
487  * increments (see below). */
490 
491  /* minimum increment size specified for the window (in pixels) */
494 
495  /* Minimum size specified for the window. */
498 
499  /* Maximum size specified for the window. */
502 
503  /* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
506 
508  bool shaped;
511 };
512 
521 struct Match {
522  /* Set if a criterion was specified incorrectly. */
523  char *error;
524 
525  struct regex *title;
527  struct regex *class;
528  struct regex *instance;
529  struct regex *mark;
531  struct regex *workspace;
532  struct regex *hexid;
533  xcb_atom_t window_type;
534  enum {
535  U_DONTCHECK = -1,
536  U_LATEST = 0,
537  U_OLDEST = 1
538  } urgent;
539  enum {
540  M_DONTCHECK = -1,
541  M_NODOCK = 0,
542  M_DOCK_ANY = 1,
543  M_DOCK_TOP = 2,
544  M_DOCK_BOTTOM = 3
545  } dock;
546  xcb_window_t id;
547  enum { WM_ANY = 0,
549  WM_FLOATING } window_mode;
551 
552  /* Where the window looking for a match should be inserted:
553  *
554  * M_HERE = the matched container will be replaced by the window
555  * (layout saving)
556  * M_ASSIGN_WS = the matched container will be inserted in the target_ws.
557  * M_BELOW = the window will be inserted as a child of the matched container
558  * (dockareas)
559  *
560  */
561  enum { M_HERE = 0,
563  M_BELOW } insert_where;
564 
566  matches;
567 
568  /* Whether this match was generated when restarting i3 inplace.
569  * Leads to not setting focus when managing a new window, because the old
570  * focus stack should be restored. */
571  bool restart_mode;
572 };
573 
582 struct Assignment {
594  enum {
595  A_ANY = 0,
596  A_COMMAND = (1 << 0),
597  A_TO_WORKSPACE = (1 << 1),
598  A_NO_FOCUS = (1 << 2),
599  A_TO_WORKSPACE_NUMBER = (1 << 3),
600  A_TO_OUTPUT = (1 << 4)
601  } type;
602 
605 
607  union {
608  char *command;
609  char *workspace;
610  char *output;
611  } dest;
612 
615 };
616 
618 typedef enum { CF_NONE = 0,
621 
622 struct mark_t {
623  char *name;
624 
627 };
628 
633 struct Con {
634  bool mapped;
635 
636  /* Should this container be marked urgent? This gets set when the window
637  * inside this container (if any) sets the urgency hint, for example. */
638  bool urgent;
639 
645  uint8_t ignore_unmap;
646 
647  /* The surface used for the frame window. */
651 
652  enum {
653  CT_ROOT = 0,
654  CT_OUTPUT = 1,
655  CT_CON = 2,
656  CT_FLOATING_CON = 3,
657  CT_WORKSPACE = 4,
658  CT_DOCKAREA = 5
659  } type;
660 
663  int num;
664 
667 
668  struct Con *parent;
669 
670  /* The position and size for this con. These coordinates are absolute. Note
671  * that the rect of a container does not include the decoration. */
672  struct Rect rect;
673  /* The position and size of the actual client window. These coordinates are
674  * relative to the container's rect. */
675  struct Rect window_rect;
676  /* The position and size of the container's decoration. These coordinates
677  * are relative to the container's parent's rect. */
678  struct Rect deco_rect;
680  struct Rect geometry;
681 
682  char *name;
683 
686 
687  /* a sticky-group is an identifier which bundles several containers to a
688  * group. The contents are shared between all of them, that is they are
689  * displayed on whichever of the containers is currently visible */
691 
692  /* user-definable marks to jump to this container later */
693  TAILQ_HEAD(marks_head, mark_t)
694  marks_head;
695  /* cached to decide whether a redraw is needed */
696  bool mark_changed;
697 
698  double percent;
699 
700  /* the x11 border pixel attribute */
701  int border_width;
702  int current_border_width;
703 
704  struct Window *window;
705 
706  /* timer used for disabling urgency */
707  struct ev_timer *urgency_timer;
708 
711 
712  /* Only workspace-containers can have floating clients */
713  TAILQ_HEAD(floating_head, Con)
714  floating_head;
715 
716  TAILQ_HEAD(nodes_head, Con)
717  nodes_head;
718 
719  TAILQ_HEAD(focus_head, Con)
720  focus_head;
721 
722  TAILQ_HEAD(swallow_head, Match)
723  swallow_head;
724 
725  fullscreen_mode_t fullscreen_mode;
726 
727  /* Whether this window should stick to the glass. This corresponds to
728  * the _NET_WM_STATE_STICKY atom and will only be respected if the
729  * window is floating. */
730  bool sticky;
731 
732  /* layout is the layout of this container: one of split[v|h], stacked or
733  * tabbed. Special containers in the tree (above workspaces) have special
734  * layouts like dockarea or output.
735  *
736  * last_split_layout is one of splitv or splith to support the old "layout
737  * default" command which by now should be "layout splitv" or "layout
738  * splith" explicitly.
739  *
740  * workspace_layout is only for type == CT_WORKSPACE cons. When you change
741  * the layout of a workspace without any children, i3 cannot just set the
742  * layout (because workspaces need to be splitv/splith to allow focus
743  * parent and opening new containers). Instead, it stores the requested
744  * layout in workspace_layout and creates a new split container with that
745  * layout whenever a new container is attached to the workspace. */
746  layout_t layout, last_split_layout, workspace_layout;
747  border_style_t border_style;
754  enum {
755  FLOATING_AUTO_OFF = 0,
756  FLOATING_USER_OFF = 1,
757  FLOATING_AUTO_ON = 2,
758  FLOATING_USER_ON = 3
759  } floating;
760 
762  nodes;
763 
766 
769 
771  floating_windows;
772 
774  void (*on_remove_child)(Con *);
775 
776  enum {
777  /* Not a scratchpad window. */
778  SCRATCHPAD_NONE = 0,
779 
780  /* Just moved to scratchpad, not resized by the user yet.
781  * Window will be auto-centered and sized appropriately. */
782  SCRATCHPAD_FRESH = 1,
783 
784  /* The user changed position/size of the scratchpad window. */
785  SCRATCHPAD_CHANGED = 2
786  } scratchpad_state;
787 
788  /* The ID of this container before restarting. Necessary to correctly
789  * interpret back-references in the JSON (such as the focus stack). */
790  int old_id;
791 
792  /* Depth of the container window */
793  uint16_t depth;
794 
795  /* The colormap for this con if a custom one is used. */
796  xcb_colormap_t colormap;
797 };
char * id
startup ID for this sequence, generated by libstartup-notification
Definition: data.h:250
struct regex * instance
Definition: data.h:528
int left
Definition: data.h:151
Stores a rectangle, for example the size of a window, the child window etc.
Definition: data.h:175
struct outputs_head outputs
Definition: randr.c:21
int right
Definition: data.h:149
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:322
char * name
Definition: data.h:623
uint32_t y
Definition: data.h:177
uint16_t depth
Depth of the window.
Definition: data.h:484
Definition: data.h:96
int width_increment
Definition: data.h:492
char * name
Definition: data.h:381
struct regex * workspace
Definition: data.h:531
time_t added
Definition: data.h:237
double max_aspect_ratio
Definition: data.h:505
Stores a width/height pair, used as part of deco_render_params to check whether the rects width/heigh...
Definition: data.h:199
uint32_t w
Definition: data.h:200
Definition: data.h:57
Definition: data.h:74
bool to_be_disabled
Definition: data.h:405
uint32_t width
Definition: data.h:178
border_style_t
Definition: data.h:63
warping_t
Mouse pointer warping modes.
Definition: data.h:141
#define TAILQ_HEAD(name, type)
Definition: queue.h:318
pcre_extra * extra
Definition: data.h:275
int inner
Definition: data.h:147
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
Definition: data.h:457
bool con_is_leaf
Definition: data.h:218
int response_type
Definition: data.h:236
fullscreen_mode_t
Fullscreen modes.
Definition: data.h:618
SnLauncherContext * context
libstartup-notification context for this launch
Definition: data.h:254
Holds a command specified by either an:
Definition: data.h:366
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:331
time_t delete_at
time at which this sequence should be deleted (after it was marked as completed)
Definition: data.h:257
Regular expression wrapper.
Definition: data.h:272
char * command
Command, like in command mode.
Definition: data.h:368
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:339
Definition: data.h:61
layout_t
Container layouts.
Definition: data.h:101
struct width_height con_rect
Definition: data.h:213
uint16_t depth
Definition: data.h:793
struct bindings_head * bindings
Definition: main.c:74
char * pattern
Definition: data.h:273
struct width_height con_window_rect
Definition: data.h:214
struct autostarts_always_head autostarts_always
Definition: main.c:80
Rect con_deco_rect
Definition: data.h:215
struct assignments_head assignments
Definition: main.c:83
Definition: data.h:62
An Assignment makes specific windows go to a specific workspace/output or run a command for that wind...
Definition: data.h:582
Definition: data.h:146
int min_width
Definition: data.h:496
input_type_t input_type
Definition: data.h:304
uint32_t bottom
Definition: data.h:191
An Output is a physical output on your graphics driver.
Definition: data.h:394
xcb_window_t id
Definition: data.h:546
uint32_t keycode
Keycode to bind.
Definition: data.h:334
bool input_shaped
The window has a nonrectangular input shape.
Definition: data.h:510
int min_height
Definition: data.h:497
char * error
Definition: data.h:523
int height_increment
Definition: data.h:493
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
Definition: data.h:454
gaps_t gaps
Only applicable for containers of type CT_WORKSPACE.
Definition: data.h:666
xcb_randr_output_t id
Output id, so that we can requery the output directly later.
Definition: data.h:396
Stores which workspace (by name or number) goes to which output and its gaps config.
Definition: data.h:225
char * name
Definition: data.h:682
Definition: data.h:622
layout_t parent_layout
Definition: data.h:217
uint32_t right
Definition: data.h:189
Definition: data.h:58
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL.
Definition: data.h:187
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
Definition: data.h:467
bool pixmap_recreated
Definition: data.h:650
Definition: libi3.h:415
kill_window_t
parameter to specify whether tree_close_internal() and x_window_kill() should kill only this specific...
Definition: data.h:69
surface_t frame_buffer
Definition: data.h:649
Definition: data.h:88
uint32_t wm_desktop
The _NET_WM_DESKTOP for this window.
Definition: data.h:470
struct Con * parent
Definition: data.h:668
orientation_t
Definition: data.h:60
char * class_class
Definition: data.h:442
int max_width
Definition: data.h:500
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
Definition: data.h:301
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list").
Definition: data.h:451
Match match
the criteria to check if a window matches
Definition: data.h:604
Stores internal information about a startup sequence, like the workspace it was initiated on.
Definition: data.h:248
xcb_window_t id
Definition: data.h:430
uint32_t left
Definition: data.h:188
smart_borders_t
Definition: data.h:80
#define TAILQ_ENTRY(type)
Definition: queue.h:327
struct pending_marks * marks
Stores the parameters for rendering a window decoration.
Definition: data.h:210
pcre * regex
Definition: data.h:274
Definition: data.h:63
int top
Definition: data.h:148
bool changed
Internal flags, necessary for querying RandR screens (happens in two stages)
Definition: data.h:404
Definition: data.h:108
int base_width
Definition: data.h:488
i3_xkb_group_mask_t
Bitmask for matching XCB_XKB_GROUP_1 to XCB_XKB_GROUP_4.
Definition: data.h:122
bool primary
Definition: data.h:406
struct regex * title
Definition: data.h:525
char * command
Definition: data.h:608
xcb_colormap_t colormap
Definition: data.h:796
double min_aspect_ratio
Definition: data.h:504
xcb_keycode_t keycode
Definition: data.h:284
A "match" is a data structure which acts like a mask or expression to match certain windows or not.
Definition: data.h:521
Part of the struct Config.
Definition: configuration.h:54
struct _i3String i3String
Opaque data structure for storing strings.
Definition: libi3.h:48
struct reservedpx __attribute__
char * title_format
The format with which the window's name should be displayed.
Definition: data.h:685
int sequence
Definition: data.h:235
uint32_t h
Definition: data.h:201
bool urgent
Definition: data.h:638
Definition: data.h:107
#define SLIST_ENTRY(type)
Definition: queue.h:101
Definition: data.h:64
struct regex * window_role
Definition: data.h:530
Stores a resolved keycode (from a keysym), including the modifier mask.
Definition: data.h:283
struct Con * focused
Definition: tree.c:13
bool needs_take_focus
Whether the application needs to receive WM_TAKE_FOCUS.
Definition: data.h:460
struct all_cons_head all_cons
Definition: tree.c:15
char * workspace
workspace on which this startup was initiated
Definition: data.h:252
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely,...
Definition: data.h:645
struct autostarts_head autostarts
Definition: main.c:77
struct Colortriple * color
Definition: data.h:211
#define SLIST_HEAD(name, type)
Definition: queue.h:93
xcb_window_t transient_for
Definition: data.h:435
char * output
Definition: data.h:610
Definition: data.h:91
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:327
bool mapped
Definition: data.h:634
bool shaped
The window has a nonrectangular shape.
Definition: data.h:508
color_t background
Definition: data.h:216
Definition: data.h:106
char * class_instance
Definition: data.h:443
bool doesnt_accept_focus
Whether this window accepts focus.
Definition: data.h:464
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition: data.h:429
struct regex * hexid
Definition: data.h:532
hide_edge_borders_mode_t
Definition: data.h:88
uint32_t top
Definition: data.h:190
Definition: data.h:65
int max_height
Definition: data.h:501
smart_gaps_t
Definition: data.h:84
bool active
Whether the output is currently active (has a CRTC attached with a valid mode)
Definition: data.h:400
i3_event_state_mask_t modifiers
Definition: data.h:285
Definition: data.h:104
char * workspace
Definition: data.h:609
char * sticky_group
Definition: data.h:690
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:136
direction_t
Definition: data.h:56
Definition: data.h:618
struct regex * mark
Definition: data.h:529
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
Definition: data.h:663
int base_height
Definition: data.h:489
Definition: data.h:56
A 'Con' represents everything from the X11 root window down to a single X11 window.
Definition: data.h:633
int old_id
Definition: data.h:790
int bottom
Definition: data.h:150
uint32_t height
Definition: data.h:179
Assignment ** ran_assignments
Definition: data.h:440
char * symbol
Symbol the user specified in configfile, if any.
Definition: data.h:344
xcb_atom_t window_type
Definition: data.h:533
struct regex * application
Definition: data.h:526
Con * con_id
Definition: data.h:550
Definition: data.h:59
Definition: data.h:116
bool no_startup_id
no_startup_id flag for start_application().
Definition: data.h:371
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:434
focus_wrapping_t
Focus wrapping modes.
Definition: data.h:157
mark_mode_t
Definition: data.h:95
input_type_t
Binding input types.
Definition: data.h:114
uint32_t x
Definition: data.h:176
int border_style
Definition: data.h:212
i3String * name
The name of the window.
Definition: data.h:446
uint32_t nr_assignments
Pointers to the Assignments which were already ran for this Window (assignments run only once)
Definition: data.h:439
surface_t frame
Definition: data.h:648
adjacent_t
describes if the window is adjacent to the output (physical screen) edges.
Definition: data.h:74