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 PCRE2_CODE_UNIT_WIDTH 8
13 
14 #define SN_API_NOT_YET_FROZEN 1
15 #include <libsn/sn-launcher.h>
16 
17 #include <xcb/randr.h>
18 #include <pcre2.h>
19 #include <sys/time.h>
20 #include <cairo/cairo.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 { BEFORE,
64 typedef enum { BS_NORMAL = 0,
65  BS_NONE = 1,
67 
70 typedef enum { DONT_KILL_WINDOW = 0,
73 
75 typedef enum { ADJ_NONE = 0,
80 
81 typedef enum { HEBM_NONE = ADJ_NONE,
86 
87 typedef enum { MM_REPLACE,
89 
93 typedef enum {
94  L_DEFAULT = 0,
95  L_STACKED = 1,
96  L_TABBED = 2,
98  L_OUTPUT = 4,
99  L_SPLITV = 5,
101 } layout_t;
102 
106 typedef enum {
109 } input_type_t;
110 
114 typedef enum {
121 
128 typedef uint32_t i3_event_state_mask_t;
129 
133 typedef enum {
136 } warping_t;
137 
141 typedef enum {
147 
151 typedef enum {
153  QUBE_RED = 1,
161 } qube_label_t;
162 
163 #define QUBE_NUM_LABELS 9
164 
165 
176 struct Rect {
177  uint32_t x;
178  uint32_t y;
179  uint32_t width;
180  uint32_t height;
181 };
182 
188 struct reservedpx {
189  uint32_t left;
190  uint32_t right;
191  uint32_t top;
192  uint32_t bottom;
193 };
194 
200 struct width_height {
201  uint32_t w;
202  uint32_t h;
203 };
204 
220 };
221 
227  char *name;
228  char *output;
229 
231 };
232 
233 struct Ignore_Event {
234  int sequence;
236  time_t added;
237 
238  SLIST_ENTRY(Ignore_Event) ignore_events;
239 };
240 
248  char *id;
250  char *workspace;
252  SnLauncherContext *context;
255  time_t delete_at;
256 
257  TAILQ_ENTRY(Startup_Sequence) sequences;
258 };
259 
269 struct regex {
270  char *pattern;
271  pcre2_code *regex;
272 };
273 
280  xcb_keycode_t keycode;
282  TAILQ_ENTRY(Binding_Keycode) keycodes;
283 };
284 
285 /******************************************************************************
286  * Major types
287  *****************************************************************************/
288 
295 struct Binding {
296  /* The type of input this binding is for. (Mouse bindings are not yet
297  * implemented. All bindings are currently assumed to be keyboard bindings.) */
299 
302  enum {
303  /* This binding will only be executed upon KeyPress events */
305  /* This binding will be executed either upon a KeyRelease event, or… */
307  /* …upon a KeyRelease event, even if the modifiers don’t match. This
308  * state is triggered from get_binding() when the corresponding
309  * KeyPress (!) happens, so that users can release the modifier keys
310  * before releasing the actual key. */
312  } release;
313 
316  bool border;
317 
322 
326 
328  uint32_t keycode;
329 
334 
338  char *symbol;
339 
343  TAILQ_HEAD(keycodes_head, Binding_Keycode) keycodes_head;
344 
346  char *command;
347 
349 };
350 
358 struct Autostart {
360  char *command;
366 };
367 
368 struct output_name {
369  char *name;
370  SLIST_ENTRY(output_name) names;
371 };
372 
380 struct xoutput {
382  xcb_randr_output_t id;
383 
386  bool active;
387 
390  bool changed;
392  bool primary;
393 
397  SLIST_HEAD(names_head, output_name) names_head;
398 
401 
404 
406 };
407 
413 struct Window {
414  xcb_window_t id;
415 
418  xcb_window_t leader;
419  xcb_window_t transient_for;
420 
423  uint32_t nr_assignments;
425 
426  char *class_class;
428 
431 
434 
437 
441  char *role;
442 
444  char *machine;
445 
448 
451 
454 
458 
460  xcb_atom_t window_type;
461 
463  uint32_t wm_desktop;
464 
466  enum { W_NODOCK = 0,
469 
471  struct timeval urgent;
472 
475 
477  uint16_t depth;
478 
479  /* the wanted size of the window, used in combination with size
480  * increments (see below). */
483 
484  /* minimum increment size specified for the window (in pixels) */
487 
488  /* Minimum size specified for the window. */
491 
492  /* Maximum size specified for the window. */
495 
496  /* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
499 
501  cairo_surface_t *icon;
502 
504  bool shaped;
507 
508  /* Time when the window became managed. Used to determine whether a window
509  * should be swallowed after initial management. */
511 
512  /* The window has been swallowed. */
513  bool swallowed;
514 };
515 
524 struct Match {
525  /* Set if a criterion was specified incorrectly. */
526  char *error;
527 
528  struct regex *title;
530  struct regex *class;
531  struct regex *instance;
532  struct regex *mark;
534  struct regex *workspace;
535  struct regex *machine;
536  xcb_atom_t window_type;
537  enum {
539  U_LATEST = 0,
541  } urgent;
542  enum {
544  M_NODOCK = 0,
548  } dock;
549  xcb_window_t id;
550  enum { WM_ANY = 0,
559 
560  /* Where the window looking for a match should be inserted:
561  *
562  * M_HERE = the matched container will be replaced by the window
563  * (layout saving)
564  * M_ASSIGN_WS = the matched container will be inserted in the target_ws.
565  * M_BELOW = the window will be inserted as a child of the matched container
566  * (dockareas)
567  *
568  */
569  enum { M_HERE = 0,
572 
573  TAILQ_ENTRY(Match) matches;
574 
575  /* Whether this match was generated when restarting i3 inplace.
576  * Leads to not setting focus when managing a new window, because the old
577  * focus stack should be restored. */
579 };
580 
589 struct Assignment {
601  enum {
602  A_ANY = 0,
603  A_COMMAND = (1 << 0),
604  A_TO_WORKSPACE = (1 << 1),
605  A_NO_FOCUS = (1 << 2),
607  A_TO_OUTPUT = (1 << 4)
608  } type;
609 
612 
614  union {
615  char *command;
616  char *workspace;
617  char *output;
618  } dest;
619 
621 };
622 
624 typedef enum { CF_NONE = 0,
627 
628 struct mark_t {
629  char *name;
630 
632 };
633 
638 struct Con {
639  bool mapped;
640 
641  /* Should this container be marked urgent? This gets set when the window
642  * inside this container (if any) sets the urgency hint, for example. */
643  bool urgent;
644 
650  uint8_t ignore_unmap;
651 
652  /* The surface used for the frame window. */
656 
657  enum {
658  CT_ROOT = 0,
660  CT_CON = 2,
664  } type;
665 
668  int num;
669 
670  struct Con *parent;
671 
672  /* The position and size for this con. These coordinates are absolute. Note
673  * that the rect of a container does not include the decoration. */
674  struct Rect rect;
675  /* The position and size of the actual client window. These coordinates are
676  * relative to the container's rect. */
678  /* The position and size of the container's decoration. These coordinates
679  * are relative to the container's parent's rect. */
680  struct Rect deco_rect;
682  struct Rect geometry;
683 
684  char *name;
685 
688 
693 
694  /* a sticky-group is an identifier which bundles several containers to a
695  * group. The contents are shared between all of them, that is they are
696  * displayed on whichever of the containers is currently visible */
698 
699  /* user-definable marks to jump to this container later */
700  TAILQ_HEAD(marks_head, mark_t) marks_head;
701  /* cached to decide whether a redraw is needed */
703 
704  double percent;
705 
706  /* the x11 border pixel attribute */
709 
710  struct Window *window;
711 
712  /* timer used for disabling urgency */
713  struct ev_timer *urgency_timer;
714 
717 
718  /* Only workspace-containers can have floating clients */
719  TAILQ_HEAD(floating_head, Con) floating_head;
720 
721  TAILQ_HEAD(nodes_head, Con) nodes_head;
722  TAILQ_HEAD(focus_head, Con) focus_head;
723 
724  TAILQ_HEAD(swallow_head, Match) swallow_head;
725 
727 
728  /* Whether this window should stick to the glass. This corresponds to
729  * the _NET_WM_STATE_STICKY atom and will only be respected if the
730  * window is floating. */
731  bool sticky;
732 
733  /* layout is the layout of this container: one of split[v|h], stacked or
734  * tabbed. Special containers in the tree (above workspaces) have special
735  * layouts like dockarea or output.
736  *
737  * last_split_layout is one of splitv or splith to support the old "layout
738  * default" command which by now should be "layout splitv" or "layout
739  * splith" explicitly.
740  *
741  * workspace_layout is only for type == CT_WORKSPACE cons. When you change
742  * the layout of a workspace without any children, i3 cannot just set the
743  * layout (because workspaces need to be splitv/splith to allow focus
744  * parent and opening new containers). Instead, it stores the requested
745  * layout in workspace_layout and creates a new split container with that
746  * layout whenever a new container is attached to the workspace. */
755  enum {
760  } floating;
761 
762  TAILQ_ENTRY(Con) nodes;
765  TAILQ_ENTRY(Con) floating_windows;
766 
768  void (*on_remove_child)(Con *);
769 
770  enum {
771  /* Not a scratchpad window. */
773 
774  /* Just moved to scratchpad, not resized by the user yet.
775  * Window will be auto-centered and sized appropriately. */
777 
778  /* The user changed position/size of the scratchpad window. */
781 
782  /* The ID of this container before restarting. Necessary to correctly
783  * interpret back-references in the JSON (such as the focus stack). */
784  int old_id;
785 
786  /* Depth of the container window */
787  uint16_t depth;
788 
789  /* The colormap for this con if a custom one is used. */
790  xcb_colormap_t colormap;
791 };
hide_edge_borders_mode_t
Definition: data.h:81
Rect con_deco_rect
Definition: data.h:216
uint32_t top
Definition: data.h:191
double max_aspect_ratio
Definition: data.h:498
char * class_instance
Definition: data.h:427
bool mapped
Definition: data.h:639
xcb_window_t id
Definition: data.h:414
Definition: data.h:100
char * workspace
workspace on which this startup was initiated
Definition: data.h:250
layout_t layout
Definition: data.h:747
uint32_t y
Definition: data.h:178
Con * con_id
Definition: data.h:557
enum Match::@12 urgent
struct regex * title
Definition: data.h:528
struct assignments_head assignments
Definition: main.c:97
Definition: data.h:99
struct outputs_head outputs
Definition: randr.c:22
struct autostarts_head autostarts
Definition: main.c:91
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:316
bool input_shaped
The window has a nonrectangular input shape.
Definition: data.h:506
i3_event_state_mask_t modifiers
Definition: data.h:281
enum Match::@14 window_mode
xcb_keycode_t keycode
Definition: data.h:280
time_t managed_since
Definition: data.h:510
Definition: data.h:64
xcb_colormap_t colormap
Definition: data.h:790
char * title_format
The format with which the window&#39;s name should be displayed.
Definition: data.h:687
layout_t parent_layout
Definition: data.h:218
struct regex * instance
Definition: data.h:531
A &#39;Window&#39; is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition: data.h:413
struct Window * window
Definition: data.h:710
Definition: data.h:84
layout_t workspace_layout
Definition: data.h:747
Definition: data.h:65
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:325
Definition: data.h:94
struct Con * parent
Definition: data.h:670
position_t
Definition: data.h:62
Definition: data.h:98
layout_t
Container layouts.
Definition: data.h:93
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:333
uint32_t keycode
Keycode to bind.
Definition: data.h:328
int response_type
Definition: data.h:235
uint32_t h
Definition: data.h:202
char * name
Definition: data.h:629
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
Definition: data.h:441
struct bindings_head * bindings
Definition: main.c:87
warping_t
Mouse pointer warping modes.
Definition: data.h:133
xcb_window_t transient_for
Definition: data.h:419
SLIST_ENTRY(output_name) names
uint16_t depth
Depth of the window.
Definition: data.h:477
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
Definition: data.h:450
struct autostarts_always_head autostarts_always
Definition: main.c:94
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
Definition: data.h:716
A &#39;Con&#39; represents everything from the X11 root window down to a single X11 window.
Definition: data.h:638
bool changed
Internal flags, necessary for querying RandR screens (happens in two stages)
Definition: data.h:390
cairo_surface_t * icon
Window icon, as Cairo surface.
Definition: data.h:501
TAILQ_ENTRY(Con) nodes
uint32_t height
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:423
Definition: data.h:624
double percent
Definition: data.h:704
bool active
Whether the output is currently active (has a CRTC attached with a valid mode)
Definition: data.h:386
TAILQ_ENTRY(Assignment) assignments
input_type_t
Binding input types.
Definition: data.h:106
struct Rect deco_rect
Definition: data.h:680
int min_height
Definition: data.h:490
int border_width
Definition: data.h:707
Definition: data.h:66
time_t added
Definition: data.h:236
TAILQ_HEAD(keycodes_head, Binding_Keycode) keycodes_head
Only in use if symbol != NULL.
Definition: data.h:96
Definition: libi3.h:426
bool no_startup_id
no_startup_id flag for start_application().
Definition: data.h:363
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
Definition: data.h:668
int width_increment
Definition: data.h:485
TAILQ_ENTRY(xoutput) outputs
char * workspace
Definition: data.h:616
Definition: data.h:153
Definition: data.h:55
char * command
Command, like in command mode.
Definition: data.h:360
Definition: data.h:95
Definition: data.h:108
TAILQ_HEAD(marks_head, mark_t) marks_head
bool pixmap_recreated
Definition: data.h:655
TAILQ_ENTRY(Autostart) autostarts
struct width_height con_window_rect
Definition: data.h:215
struct ws_assignments_head ws_assignments
Definition: main.c:101
struct pending_marks * marks
kill_window_t
parameter to specify whether tree_close_internal() and x_window_kill() should kill only this specific...
Definition: data.h:70
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
Definition: data.h:447
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely...
Definition: data.h:650
char * id
startup ID for this sequence, generated by libstartup-notification
Definition: data.h:248
An Assignment makes specific windows go to a specific workspace/output or run a command for that wind...
Definition: data.h:589
Stores the parameters for rendering a window decoration.
Definition: data.h:211
struct Rect window_rect
Definition: data.h:677
bool shaped
The window has a nonrectangular shape.
Definition: data.h:504
enum Con::@20 scratchpad_state
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:418
char * name
Definition: data.h:369
fullscreen_mode_t
Fullscreen modes.
Definition: data.h:624
int qubes_label
The qubes label.
Definition: data.h:436
char * class_class
Definition: data.h:426
input_type_t input_type
Definition: data.h:298
struct regex * window_role
Definition: data.h:533
int border_style
Definition: data.h:213
TAILQ_ENTRY(mark_t) marks
enum Window::@11 dock
Whether the window says it is a dock window.
Definition: data.h:58
SLIST_HEAD(names_head, output_name) names_head
List of names for the output.
struct regex * mark
Definition: data.h:532
int max_height
Definition: data.h:494
Match match
the criteria to check if a window matches
Definition: data.h:611
char * command
Definition: data.h:615
Stores a resolved keycode (from a keysym), including the modifier mask.
Definition: data.h:279
enum Match::@13 dock
Rect rect
x, y, width, height
Definition: data.h:403
Definition: data.h:628
SnLauncherContext * context
libstartup-notification context for this launch
Definition: data.h:252
Part of the struct Config.
Definition: configuration.h:53
bool mark_changed
Definition: data.h:702
uint32_t x
Definition: data.h:177
struct Con * focused
Definition: tree.c:13
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
Definition: data.h:524
int base_height
Definition: data.h:482
struct all_cons_head all_cons
Definition: tree.c:15
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:321
int current_border_width
Definition: data.h:708
struct Colortriple * color
Definition: data.h:212
void(* on_remove_child)(Con *)
callbacks
Definition: data.h:768
Definition: data.h:56
Stores a rectangle, for example the size of a window, the child window etc.
Definition: data.h:176
color_t background
Definition: data.h:217
enum Con::@18 type
Definition: data.h:88
i3String * qubes_vmname
The name of the qubes vm.
Definition: data.h:433
int height_increment
Definition: data.h:486
i3_xkb_group_mask_t
Bitmask for matching XCB_XKB_GROUP_1 to XCB_XKB_GROUP_4.
Definition: data.h:114
int max_width
Definition: data.h:493
bool primary
Definition: data.h:392
fullscreen_mode_t fullscreen_mode
Definition: data.h:726
struct regex * workspace
Definition: data.h:534
int window_icon_padding
Whether the window icon should be displayed, and with what padding.
Definition: data.h:692
bool swallowed
Definition: data.h:513
uint32_t right
Definition: data.h:190
TAILQ_ENTRY(Workspace_Assignment) ws_assignments
char * output
Definition: data.h:617
pcre2_code * regex
Definition: data.h:271
struct reservedpx reserved
Pixels the window reserves.
Definition: data.h:474
int sequence
Definition: data.h:234
time_t delete_at
time at which this sequence should be deleted (after it was marked as completed)
Definition: data.h:255
i3String * name
The name of the window.
Definition: data.h:430
enum Match::@15 insert_where
uint32_t bottom
Definition: data.h:192
Definition: data.h:75
int old_id
Definition: data.h:784
TAILQ_ENTRY(Binding_Keycode) keycodes
xcb_randr_output_t id
Output id, so that we can requery the output directly later.
Definition: data.h:382
Stores a width/height pair, used as part of deco_render_params to check whether the rects width/heigh...
Definition: data.h:200
bool restart_mode
Definition: data.h:578
bool to_be_disabled
Definition: data.h:391
char * name
Definition: data.h:684
struct regex * application
Definition: data.h:529
struct _i3String i3String
Opaque data structure for storing strings.
Definition: libi3.h:49
char * symbol
Symbol the user specified in configfile, if any.
Definition: data.h:338
Definition: data.h:61
adjacent_t
describes if the window is adjacent to the output (physical screen) edges.
Definition: data.h:75
direction_t
Definition: data.h:55
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
Definition: data.h:460
TAILQ_ENTRY(Startup_Sequence) sequences
TAILQ_ENTRY(Binding) bindings
uint16_t depth
Definition: data.h:787
Definition: data.h:62
bool urgent
Definition: data.h:643
union Assignment::@17 dest
destination workspace/command/output, depending on the type
layout_t last_split_layout
Definition: data.h:747
struct regex * machine
Definition: data.h:535
focus_wrapping_t
Focus wrapping modes.
Definition: data.h:141
Definition: data.h:63
enum Con::@19 floating
floating? (= not in tiling layout) This cannot be simply a bool because we want to keep track of whet...
Holds a command specified by either an:
Definition: data.h:358
xcb_window_t id
Definition: data.h:549
Definition: data.h:60
char * error
Definition: data.h:526
int min_width
Definition: data.h:489
Regular expression wrapper.
Definition: data.h:269
qube_label_t
Qubes colors.
Definition: data.h:151
char * machine
WM_CLIENT_MACHINE of the window.
Definition: data.h:444
orientation_t
Definition: data.h:59
border_style_t
Definition: data.h:64
xcb_atom_t window_type
Definition: data.h:536
Stores which workspace (by name or number) goes to which output.
Definition: data.h:226
char * pattern
Definition: data.h:270
char * sticky_group
Definition: data.h:697
Con * con
Pointer to the Con which represents this output.
Definition: data.h:400
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
Definition: data.h:188
Definition: data.h:57
bool doesnt_accept_focus
Whether this window accepts focus.
Definition: data.h:457
int base_width
Definition: data.h:481
uint32_t left
Definition: data.h:189
mark_mode_t
Definition: data.h:87
struct Rect rect
Definition: data.h:674
double min_aspect_ratio
Definition: data.h:497
enum Assignment::@16 type
type of this assignment:
An Output is a physical output on your graphics driver.
Definition: data.h:380
SLIST_ENTRY(Ignore_Event) ignore_events
uint32_t width
Definition: data.h:179
TAILQ_ENTRY(Match) matches
uint32_t w
Definition: data.h:201
bool sticky
Definition: data.h:731
Definition: data.h:81
char * command
Command, like in command mode.
Definition: data.h:346
bool con_is_leaf
Definition: data.h:219
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
Definition: data.h:295
Assignment ** ran_assignments
Definition: data.h:424
bool match_all_windows
Definition: data.h:558
surface_t frame
Definition: data.h:653
border_style_t border_style
Definition: data.h:748
enum Binding::@10 release
If true, the binding should be executed upon a KeyRelease event, not a KeyPress (the default)...
Stores internal information about a startup sequence, like the workspace it was initiated on...
Definition: data.h:246
struct ev_timer * urgency_timer
Definition: data.h:713
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:128
struct timeval urgent
When this window was marked urgent.
Definition: data.h:471
bool needs_take_focus
Whether the application needs to receive WM_TAKE_FOCUS.
Definition: data.h:453
surface_t frame_buffer
Definition: data.h:654
uint32_t wm_desktop
The _NET_WM_DESKTOP for this window.
Definition: data.h:463
struct Rect geometry
the geometry this window requested when getting mapped
Definition: data.h:682
struct width_height con_rect
Definition: data.h:214