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 #ifndef _DATA_H
11 #define _DATA_H
12 
13 #define SN_API_NOT_YET_FROZEN 1
14 #include <libsn/sn-launcher.h>
15 
16 #include <xcb/randr.h>
17 #include <xcb/xcb_atom.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 
51 
52 /******************************************************************************
53  * Helper types
54  *****************************************************************************/
55 typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
56 typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t;
57 typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_1PIXEL = 2 } border_style_t;
58 
61 typedef enum { DONT_KILL_WINDOW = 0, KILL_WINDOW = 1, KILL_CLIENT = 2 } kill_window_t;
62 
63 enum {
64  BIND_NONE = 0,
65  BIND_SHIFT = XCB_MOD_MASK_SHIFT, /* (1 << 0) */
66  BIND_CONTROL = XCB_MOD_MASK_CONTROL, /* (1 << 2) */
67  BIND_MOD1 = XCB_MOD_MASK_1, /* (1 << 3) */
68  BIND_MOD2 = XCB_MOD_MASK_2, /* (1 << 4) */
69  BIND_MOD3 = XCB_MOD_MASK_3, /* (1 << 5) */
70  BIND_MOD4 = XCB_MOD_MASK_4, /* (1 << 6) */
71  BIND_MOD5 = XCB_MOD_MASK_5, /* (1 << 7) */
72  BIND_MODE_SWITCH = (1 << 8)
73 };
74 
87 struct Rect {
88  uint32_t x;
89  uint32_t y;
90  uint32_t width;
91  uint32_t height;
92 } __attribute__((packed));
93 
99 struct reservedpx {
100  uint32_t left;
101  uint32_t right;
102  uint32_t top;
103  uint32_t bottom;
104 };
105 
111 struct width_height {
112  uint32_t w;
113  uint32_t h;
114 };
115 
128  uint32_t background;
130 };
131 
137  char *name;
138  char *output;
139 
141 };
142 
143 struct Ignore_Event {
144  int sequence;
146  time_t added;
147 
148  SLIST_ENTRY(Ignore_Event) ignore_events;
149 };
150 
158  char *id;
160  char *workspace;
162  SnLauncherContext *context;
163 
164  TAILQ_ENTRY(Startup_Sequence) sequences;
165 };
166 
176 struct regex {
177  char *pattern;
178  pcre *regex;
179  pcre_extra *extra;
180 };
181 
182 /******************************************************************************
183  * Major types
184  *****************************************************************************/
185 
191 struct Binding {
195  char *symbol;
196 
202  xcb_keycode_t *translated_to;
203 
204  uint32_t number_keycodes;
205 
207  uint32_t keycode;
208 
210  uint32_t mods;
211 
213  char *command;
214 
216 };
217 
225 struct Autostart {
227  char *command;
231  TAILQ_ENTRY(Autostart) autostarts;
232  TAILQ_ENTRY(Autostart) autostarts_always;
233 };
234 
242 struct xoutput {
244  xcb_randr_output_t id;
246  char *name;
247 
250 
253  bool active;
254 
257  bool changed;
259  bool primary;
260 
263 
264  TAILQ_ENTRY(xoutput) outputs;
265 };
266 
272 struct Window {
273  xcb_window_t id;
274 
277  xcb_window_t leader;
278  xcb_window_t transient_for;
279 
280  char *class_class;
282 
285  char *name_x;
286 
290  char *role;
291 
294 
297  char *name_json;
298 
300  size_t name_len;
301 
304 
307 
309  struct timeval urgent;
310 
314 
316  enum { W_NODOCK = 0, W_DOCK_TOP = 1, W_DOCK_BOTTOM = 2 } dock;
317 
319  struct reservedpx reserved;
320 
323  uint32_t nr_assignments;
325 
327  uint16_t depth;
328 };
329 
338 struct Match {
339  struct regex *title;
341  struct regex *class;
342  struct regex *instance;
343  struct regex *mark;
344  struct regex *role;
345  enum {
346  U_DONTCHECK = -1,
347  U_LATEST = 0,
348  U_OLDEST = 1
349  } urgent;
350  enum {
351  M_DONTCHECK = -1,
352  M_NODOCK = 0,
353  M_DOCK_ANY = 1,
354  M_DOCK_TOP = 2,
355  M_DOCK_BOTTOM = 3
356  } dock;
357  xcb_window_t id;
359  enum { M_ANY = 0, M_TILING, M_FLOATING } floating;
360 
361  /* Where the window looking for a match should be inserted:
362  *
363  * M_HERE = the matched container will be replaced by the window
364  * (layout saving)
365  * M_ASSIGN_WS = the matched container will be inserted in the target_ws.
366  * M_BELOW = the window will be inserted as a child of the matched container
367  * (dockareas)
368  *
369  */
370  enum { M_HERE = 0, M_ASSIGN_WS, M_BELOW } insert_where;
371 
372  /* Whether this match was generated when restarting i3 inplace.
373  * Leads to not setting focus when managing a new window, because the old
374  * focus stack should be restored. */
376 
377  TAILQ_ENTRY(Match) matches;
378 };
379 
388 struct Assignment {
400  enum {
401  A_ANY = 0,
402  A_COMMAND = (1 << 0),
403  A_TO_WORKSPACE = (1 << 1),
404  A_TO_OUTPUT = (1 << 2)
405  } type;
406 
409 
411  union {
412  char *command;
413  char *workspace;
414  char *output;
415  } dest;
416 
417  TAILQ_ENTRY(Assignment) assignments;
418 };
419 
424 struct Con {
425  bool mapped;
426  enum {
427  CT_ROOT = 0,
428  CT_OUTPUT = 1,
429  CT_CON = 2,
430  CT_FLOATING_CON = 3,
431  CT_WORKSPACE = 4,
432  CT_DOCKAREA = 5
433  } type;
435  struct Con *parent;
436 
437  struct Rect rect;
438  struct Rect window_rect;
439  struct Rect deco_rect;
441  struct Rect geometry;
442 
443  char *name;
444 
447  int num;
448 
449  /* a sticky-group is an identifier which bundles several containers to a
450  * group. The contents are shared between all of them, that is they are
451  * displayed on whichever of the containers is currently visible */
453 
454  /* user-definable mark to jump to this container later */
455  char *mark;
456 
457  double percent;
458 
459  /* proportional width/height, calculated from WM_NORMAL_HINTS, used to
460  * apply an aspect ratio to windows (think of MPlayer) */
463  /* the wanted size of the window, used in combination with size
464  * increments (see below). */
467 
468  /* the x11 border pixel attribute */
470 
471  /* minimum increment size specified for the window (in pixels) */
474 
475  struct Window *window;
476 
477  /* Should this container be marked urgent? This gets set when the window
478  * inside this container (if any) sets the urgency hint, for example. */
479  bool urgent;
480 
481  /* ids/pixmap/graphics context for the frame window */
482  xcb_window_t frame;
483  xcb_pixmap_t pixmap;
484  xcb_gcontext_t pm_gc;
486 
489 
490  /* Only workspace-containers can have floating clients */
491  TAILQ_HEAD(floating_head, Con) floating_head;
492 
493  TAILQ_HEAD(nodes_head, Con) nodes_head;
494  TAILQ_HEAD(focus_head, Con) focus_head;
495 
496  TAILQ_HEAD(swallow_head, Match) swallow_head;
497 
498  enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode;
499  enum { L_DEFAULT = 0, L_STACKED = 1, L_TABBED = 2, L_DOCKAREA = 3, L_OUTPUT = 4 } layout;
507  enum {
508  FLOATING_AUTO_OFF = 0,
509  FLOATING_USER_OFF = 1,
510  FLOATING_AUTO_ON = 2,
511  FLOATING_USER_ON = 3
512  } floating;
513 
519  uint8_t ignore_unmap;
520 
521  TAILQ_ENTRY(Con) nodes;
522  TAILQ_ENTRY(Con) focused;
523  TAILQ_ENTRY(Con) all_cons;
524  TAILQ_ENTRY(Con) floating_windows;
525 
527  void(*on_remove_child)(Con *);
528 
529  enum {
530  SCRATCHPAD_NONE = 0,
531  SCRATCHPAD_FRESH = 1,
532  SCRATCHPAD_CHANGED = 2
533  } scratchpad_state;
534 
535  /* The ID of this container before restarting. Necessary to correctly
536  * interpret back-references in the JSON (such as the focus stack). */
537  int old_id;
538 };
539 
540 #endif