]> git.sur5r.net Git - i3/i3/blob - include/tree.h
Validate matched containers for "kill" command correctly.
[i3/i3] / include / tree.h
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  * tree.c: Everything that primarily modifies the layout tree data structure.
8  *
9  */
10 #pragma once
11
12 extern Con *croot;
13 /* TODO: i am not sure yet how much access to the focused container should
14  * be permitted to source files */
15 extern Con *focused;
16 TAILQ_HEAD(all_cons_head, Con);
17 extern struct all_cons_head all_cons;
18
19 /**
20  * Initializes the tree by creating the root node, adding all RandR outputs
21  * to the tree (that means randr_init() has to be called before) and
22  * assigning a workspace to each RandR output.
23  *
24  */
25 void tree_init(xcb_get_geometry_reply_t *geometry);
26
27 /**
28  * Opens an empty container in the current container
29  *
30  */
31 Con *tree_open_con(Con *con, i3Window *window);
32
33 /**
34  * Splits (horizontally or vertically) the given container by creating a new
35  * container which contains the old one and the future ones.
36  *
37  */
38 void tree_split(Con *con, orientation_t orientation);
39
40 /**
41  * Moves focus one level up. Returns true if focus changed.
42  *
43  */
44 bool level_up(void);
45
46 /**
47  * Moves focus one level down. Returns true if focus changed.
48  *
49  */
50 bool level_down(void);
51
52 /**
53  * Renders the tree, that is rendering all outputs using render_con() and
54  * pushing the changes to X11 using x_push_changes().
55  *
56  */
57 void tree_render(void);
58
59 /**
60  * Changes focus in the given way (next/previous) and given orientation
61  * (horizontal/vertical).
62  *
63  */
64 void tree_next(char way, orientation_t orientation);
65
66 /**
67  * Closes the given container including all children.
68  * Returns true if the container was killed or false if just WM_DELETE was sent
69  * and the window is expected to kill itself.
70  *
71  * The dont_kill_parent flag is specified when the function calls itself
72  * recursively while deleting a containers children.
73  *
74  * The force_set_focus flag is specified in the case of killing a floating
75  * window: tree_close_internal() will be invoked for the CT_FLOATINGCON (the parent
76  * container) and focus should be set there.
77  *
78  */
79 bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus);
80
81 /**
82  * Loads tree from ~/.i3/_restart.json (used for in-place restarts).
83  *
84  */
85 bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry);
86
87 /**
88  * tree_flatten() removes pairs of redundant split containers, e.g.:
89  *       [workspace, horizontal]
90  *   [v-split]           [child3]
91  *   [h-split]
92  * [child1] [child2]
93  * In this example, the v-split and h-split container are redundant.
94  * Such a situation can be created by moving containers in a direction which is
95  * not the orientation of their parent container. i3 needs to create a new
96  * split container then and if you move containers this way multiple times,
97  * redundant chains of split-containers can be the result.
98  *
99  */
100 void tree_flatten(Con *child);