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 aff2e58e..fa22ea75 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -90,37 +90,61 @@ struct sway_container {
90 } events; 90 } events;
91}; 91};
92 92
93// TODO make private and use the container-specific create functions
94struct sway_container *container_create(enum sway_container_type type);
95
93const char *container_type_to_str(enum sway_container_type type); 96const char *container_type_to_str(enum sway_container_type type);
94 97
95// TODO only one container create function and pass the type? 98// TODO only one container create function and pass the type?
96struct sway_container *container_output_create( 99struct sway_container *container_output_create(
97 struct sway_output *sway_output); 100 struct sway_output *sway_output);
98 101
99struct sway_container *container_workspace_create( 102/**
100 struct sway_container *output, const char *name); 103 * Create a new container container. A container container can be a a child of
104 * a workspace container or another container container.
105 */
106struct sway_container *container_container_create();
101 107
102struct sway_container *container_view_create( 108/**
103 struct sway_container *sibling, struct sway_view *sway_view); 109 * Create a new output. Outputs are children of the root container and have no
110 * order in the tree structure.
111 */
112struct sway_container *container_output_create(struct sway_output *sway_output);
104 113
105struct sway_container *container_output_destroy(struct sway_container *output); 114/**
115 * Create a new workspace container. Workspaces are children of an output
116 * container and are ordered alphabetically by name.
117 */
118struct sway_container *container_workspace_create(struct sway_container *output, const char *name);
106 119
107struct sway_container *container_workspace_destroy( 120/*
108 struct sway_container *workspace); 121 * Create a new view container. A view can be a child of a workspace container
122 * or a container container and are rendered in the order and structure of
123 * how they are attached to the tree.
124 */
125// TODO view containers should be created in a detached state.
126struct sway_container *container_view_create(
127 struct sway_container *sibling, struct sway_view *sway_view);
109 128
110struct sway_container *container_view_destroy(struct sway_container *view); 129// TODO don't return the parent on destroy
130struct sway_container *container_destroy(struct sway_container *container);
111 131
112struct sway_container *container_destroy(struct sway_container *cont); 132struct sway_container *container_workspace_destroy(struct sway_container *container);
133struct sway_container *container_output_destroy(struct sway_container *container);
134struct sway_container *container_view_destroy(struct sway_container *container);
113 135
136// TODO move to layout.c
114struct sway_container *container_set_layout(struct sway_container *container, 137struct sway_container *container_set_layout(struct sway_container *container,
115 enum sway_container_layout layout); 138 enum sway_container_layout layout);
116 139
140// TODO rename to container_descendants_for_each()
117void container_descendants(struct sway_container *root, 141void container_descendants(struct sway_container *root,
118 enum sway_container_type type, 142 enum sway_container_type type,
119 void (*func)(struct sway_container *item, void *data), void *data); 143 void (*func)(struct sway_container *item, void *data), void *data);
120 144
121/** 145/**
122 * Finds a container based on test criteria. Returns the first container that 146 * Search a container's descendants a container based on test criteria. Returns
123 * passes the test. 147 * the first container that passes the test.
124 */ 148 */
125struct sway_container *container_find(struct sway_container *container, 149struct sway_container *container_find(struct sway_container *container,
126 bool (*test)(struct sway_container *view, void *data), void *data); 150 bool (*test)(struct sway_container *view, void *data), void *data);
@@ -128,18 +152,21 @@ struct sway_container *container_find(struct sway_container *container,
128/** 152/**
129 * Finds a parent container with the given struct sway_containerype. 153 * Finds a parent container with the given struct sway_containerype.
130 */ 154 */
155// TODO rename to container_parent_of_type()
131struct sway_container *container_parent(struct sway_container *container, 156struct sway_container *container_parent(struct sway_container *container,
132 enum sway_container_type type); 157 enum sway_container_type type);
133 158
134/** 159/**
135 * Find a container at the given coordinates. 160 * Find a container at the given coordinates. Returns the the surface and
161 * surface-local coordinates of the given layout coordinates if the container
162 * is a view and the view contains a surface at those coordinates.
136 */ 163 */
137struct sway_container *container_at(struct sway_container *parent, 164struct sway_container *container_at(struct sway_container *container,
138 double lx, double ly, struct wlr_surface **surface, 165 double lx, double ly, struct wlr_surface **surface,
139 double *sx, double *sy); 166 double *sx, double *sy);
140 167
141/** 168/**
142 * Apply the function for each child of the container breadth first. 169 * Apply the function for each descendant of the container breadth first.
143 */ 170 */
144void container_for_each_descendant_bfs(struct sway_container *container, 171void container_for_each_descendant_bfs(struct sway_container *container,
145 void (*f)(struct sway_container *container, void *data), void *data); 172 void (*f)(struct sway_container *container, void *data), void *data);
@@ -150,7 +177,16 @@ void container_for_each_descendant_bfs(struct sway_container *container,
150void container_for_each_descendant_dfs(struct sway_container *container, 177void container_for_each_descendant_dfs(struct sway_container *container,
151 void (*f)(struct sway_container *container, void *data), void *data); 178 void (*f)(struct sway_container *container, void *data), void *data);
152 179
153bool container_has_anscestor(struct sway_container *descendant, 180/**
181 * Returns true if the given container is an ancestor of this container.
182 */
183bool container_has_anscestor(struct sway_container *container,
154 struct sway_container *anscestor); 184 struct sway_container *anscestor);
155 185
186/**
187 * Returns true if the given container is a child descendant of this container.
188 */
189bool container_has_child(struct sway_container *con,
190 struct sway_container *child);
191
156#endif 192#endif
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
index e1034657..fbc3d6af 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