summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/sway/input/seat.h2
-rw-r--r--include/sway/tree/container.h66
-rw-r--r--include/sway/tree/layout.h12
3 files changed, 64 insertions, 16 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 5c3c2c4f..c780a52b 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -72,7 +72,7 @@ struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
72 struct sway_container *container); 72 struct sway_container *container);
73 73
74struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, 74struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
75 enum sway_container_type type); 75 struct sway_container *container, enum sway_container_type type);
76 76
77void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); 77void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
78 78
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index bd02197c..464f80c4 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -91,37 +91,61 @@ struct sway_container {
91 } events; 91 } events;
92}; 92};
93 93
94// TODO make private and use the container-specific create functions
95struct sway_container *container_create(enum sway_container_type type);
96
94const char *container_type_to_str(enum sway_container_type type); 97const char *container_type_to_str(enum sway_container_type type);
95 98
96// TODO only one container create function and pass the type? 99// TODO only one container create function and pass the type?
97struct sway_container *container_output_create( 100struct sway_container *container_output_create(
98 struct sway_output *sway_output); 101 struct sway_output *sway_output);
99 102
100struct sway_container *container_workspace_create( 103/**
101 struct sway_container *output, const char *name); 104 * Create a new container container. A container container can be a a child of
105 * a workspace container or another container container.
106 */
107struct sway_container *container_container_create();
102 108
103struct sway_container *container_view_create( 109/**
104 struct sway_container *sibling, struct sway_view *sway_view); 110 * Create a new output. Outputs are children of the root container and have no
111 * order in the tree structure.
112 */
113struct sway_container *container_output_create(struct sway_output *sway_output);
105 114
106struct sway_container *container_output_destroy(struct sway_container *output); 115/**
116 * Create a new workspace container. Workspaces are children of an output
117 * container and are ordered alphabetically by name.
118 */
119struct sway_container *container_workspace_create(struct sway_container *output, const char *name);
107 120
108struct sway_container *container_workspace_destroy( 121/*
109 struct sway_container *workspace); 122 * Create a new view container. A view can be a child of a workspace container
123 * or a container container and are rendered in the order and structure of
124 * how they are attached to the tree.
125 */
126// TODO view containers should be created in a detached state.
127struct sway_container *container_view_create(
128 struct sway_container *sibling, struct sway_view *sway_view);
110 129
111struct sway_container *container_view_destroy(struct sway_container *view); 130// TODO don't return the parent on destroy
131struct sway_container *container_destroy(struct sway_container *container);
112 132
113struct sway_container *container_destroy(struct sway_container *cont); 133struct sway_container *container_workspace_destroy(struct sway_container *container);
134struct sway_container *container_output_destroy(struct sway_container *container);
135struct sway_container *container_view_destroy(struct sway_container *container);
114 136
137// TODO move to layout.c
115struct sway_container *container_set_layout(struct sway_container *container, 138struct sway_container *container_set_layout(struct sway_container *container,
116 enum sway_container_layout layout); 139 enum sway_container_layout layout);
117 140
141// TODO rename to container_descendants_for_each()
118void container_descendants(struct sway_container *root, 142void container_descendants(struct sway_container *root,
119 enum sway_container_type type, 143 enum sway_container_type type,
120 void (*func)(struct sway_container *item, void *data), void *data); 144 void (*func)(struct sway_container *item, void *data), void *data);
121 145
122/** 146/**
123 * Finds a container based on test criteria. Returns the first container that 147 * Search a container's descendants a container based on test criteria. Returns
124 * passes the test. 148 * the first container that passes the test.
125 */ 149 */
126struct sway_container *container_find(struct sway_container *container, 150struct sway_container *container_find(struct sway_container *container,
127 bool (*test)(struct sway_container *view, void *data), void *data); 151 bool (*test)(struct sway_container *view, void *data), void *data);
@@ -129,18 +153,21 @@ struct sway_container *container_find(struct sway_container *container,
129/** 153/**
130 * Finds a parent container with the given struct sway_containerype. 154 * Finds a parent container with the given struct sway_containerype.
131 */ 155 */
156// TODO rename to container_parent_of_type()
132struct sway_container *container_parent(struct sway_container *container, 157struct sway_container *container_parent(struct sway_container *container,
133 enum sway_container_type type); 158 enum sway_container_type type);
134 159
135/** 160/**
136 * Find a container at the given coordinates. 161 * Find a container at the given coordinates. Returns the the surface and
162 * surface-local coordinates of the given layout coordinates if the container
163 * is a view and the view contains a surface at those coordinates.
137 */ 164 */
138struct sway_container *container_at(struct sway_container *parent, 165struct sway_container *container_at(struct sway_container *container,
139 double lx, double ly, struct wlr_surface **surface, 166 double lx, double ly, struct wlr_surface **surface,
140 double *sx, double *sy); 167 double *sx, double *sy);
141 168
142/** 169/**
143 * Apply the function for each child of the container breadth first. 170 * Apply the function for each descendant of the container breadth first.
144 */ 171 */
145void container_for_each_descendant_bfs(struct sway_container *container, 172void container_for_each_descendant_bfs(struct sway_container *container,
146 void (*f)(struct sway_container *container, void *data), void *data); 173 void (*f)(struct sway_container *container, void *data), void *data);
@@ -151,7 +178,16 @@ void container_for_each_descendant_bfs(struct sway_container *container,
151void container_for_each_descendant_dfs(struct sway_container *container, 178void container_for_each_descendant_dfs(struct sway_container *container,
152 void (*f)(struct sway_container *container, void *data), void *data); 179 void (*f)(struct sway_container *container, void *data), void *data);
153 180
154bool container_has_anscestor(struct sway_container *descendant, 181/**
182 * Returns true if the given container is an ancestor of this container.
183 */
184bool container_has_anscestor(struct sway_container *container,
155 struct sway_container *anscestor); 185 struct sway_container *anscestor);
156 186
187/**
188 * Returns true if the given container is a child descendant of this container.
189 */
190bool container_has_child(struct sway_container *con,
191 struct sway_container *child);
192
157#endif 193#endif
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
index a14152e8..8badb244 100644
--- a/include/sway/tree/layout.h
+++ b/include/sway/tree/layout.h
@@ -29,31 +29,43 @@ struct sway_root {
29 29
30void layout_init(void); 30void layout_init(void);
31 31
32// TODO move to tree.h
32void container_add_child(struct sway_container *parent, 33void container_add_child(struct sway_container *parent,
33 struct sway_container *child); 34 struct sway_container *child);
34 35
36// TODO move to tree.h
35struct sway_container *container_add_sibling(struct sway_container *parent, 37struct sway_container *container_add_sibling(struct sway_container *parent,
36 struct sway_container *child); 38 struct sway_container *child);
37 39
40// TODO move to tree.h
38struct sway_container *container_remove_child(struct sway_container *child); 41struct sway_container *container_remove_child(struct sway_container *child);
39 42
43// TODO PRIVATE in tree.h
40struct sway_container *container_reap_empty(struct sway_container *container); 44struct sway_container *container_reap_empty(struct sway_container *container);
41 45
46// TODO move to tree.h
42void container_move_to(struct sway_container* container, 47void container_move_to(struct sway_container* container,
43 struct sway_container* destination); 48 struct sway_container* destination);
44 49
45void container_move(struct sway_container *container, 50void container_move(struct sway_container *container,
46 enum movement_direction dir, int move_amt); 51 enum movement_direction dir, int move_amt);
47 52
53// TODO move to output.c
48enum sway_container_layout container_get_default_layout( 54enum sway_container_layout container_get_default_layout(
49 struct sway_container *output); 55 struct sway_container *output);
50 56
57// TODO move to output.c
51void container_sort_workspaces(struct sway_container *output); 58void container_sort_workspaces(struct sway_container *output);
52 59
53void arrange_windows(struct sway_container *container, 60void arrange_windows(struct sway_container *container,
54 double width, double height); 61 double width, double height);
55 62
63// TODO move to container.h
56struct sway_container *container_get_in_direction(struct sway_container 64struct sway_container *container_get_in_direction(struct sway_container
57 *container, struct sway_seat *seat, enum movement_direction dir); 65 *container, struct sway_seat *seat, enum movement_direction dir);
58 66
67// TODO move to tree.h
68struct sway_container *container_split(struct sway_container *child,
69 enum sway_container_layout layout);
70
59#endif 71#endif