diff options
Diffstat (limited to 'include/sway/tree')
-rw-r--r-- | include/sway/tree/arrange.h | 9 | ||||
-rw-r--r-- | include/sway/tree/container.h | 148 | ||||
-rw-r--r-- | include/sway/tree/node.h | 74 | ||||
-rw-r--r-- | include/sway/tree/root.h | 28 | ||||
-rw-r--r-- | include/sway/tree/view.h | 4 | ||||
-rw-r--r-- | include/sway/tree/workspace.h | 105 |
6 files changed, 211 insertions, 157 deletions
diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h index f47e8db5..06a2279c 100644 --- a/include/sway/tree/arrange.h +++ b/include/sway/tree/arrange.h | |||
@@ -1,16 +1,19 @@ | |||
1 | #ifndef _SWAY_ARRANGE_H | 1 | #ifndef _SWAY_ARRANGE_H |
2 | #define _SWAY_ARRANGE_H | 2 | #define _SWAY_ARRANGE_H |
3 | 3 | ||
4 | struct sway_output; | ||
5 | struct sway_workspace; | ||
4 | struct sway_container; | 6 | struct sway_container; |
7 | struct sway_node; | ||
5 | 8 | ||
6 | void arrange_container(struct sway_container *container); | 9 | void arrange_container(struct sway_container *container); |
7 | 10 | ||
8 | void arrange_workspace(struct sway_container *workspace); | 11 | void arrange_workspace(struct sway_workspace *workspace); |
9 | 12 | ||
10 | void arrange_output(struct sway_container *output); | 13 | void arrange_output(struct sway_output *output); |
11 | 14 | ||
12 | void arrange_root(void); | 15 | void arrange_root(void); |
13 | 16 | ||
14 | void arrange_windows(struct sway_container *container); | 17 | void arrange_node(struct sway_node *node); |
15 | 18 | ||
16 | #endif | 19 | #endif |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e4071cfe..c51425c9 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -5,8 +5,7 @@ | |||
5 | #include <wlr/types/wlr_box.h> | 5 | #include <wlr/types/wlr_box.h> |
6 | #include <wlr/types/wlr_surface.h> | 6 | #include <wlr/types/wlr_surface.h> |
7 | #include "list.h" | 7 | #include "list.h" |
8 | 8 | #include "sway/tree/node.h" | |
9 | extern struct sway_container root_container; | ||
10 | 9 | ||
11 | struct sway_view; | 10 | struct sway_view; |
12 | struct sway_seat; | 11 | struct sway_seat; |
@@ -17,23 +16,6 @@ struct sway_seat; | |||
17 | #define TITLEBAR_H_PADDING 3 | 16 | #define TITLEBAR_H_PADDING 3 |
18 | #define TITLEBAR_V_PADDING 4 | 17 | #define TITLEBAR_V_PADDING 4 |
19 | 18 | ||
20 | /** | ||
21 | * Different kinds of containers. | ||
22 | * | ||
23 | * This enum is in order. A container will never be inside of a container below | ||
24 | * it on this list. | ||
25 | */ | ||
26 | enum sway_container_type { | ||
27 | C_ROOT, | ||
28 | C_OUTPUT, | ||
29 | C_WORKSPACE, | ||
30 | C_CONTAINER, | ||
31 | C_VIEW, | ||
32 | |||
33 | // Keep last | ||
34 | C_TYPES, | ||
35 | }; | ||
36 | |||
37 | enum sway_container_layout { | 19 | enum sway_container_layout { |
38 | L_NONE, | 20 | L_NONE, |
39 | L_HORIZ, | 21 | L_HORIZ, |
@@ -57,18 +39,14 @@ enum movement_direction; | |||
57 | enum wlr_direction; | 39 | enum wlr_direction; |
58 | 40 | ||
59 | struct sway_container_state { | 41 | struct sway_container_state { |
60 | // Container/swayc properties | 42 | // Container properties |
61 | enum sway_container_layout layout; | 43 | enum sway_container_layout layout; |
62 | double swayc_x, swayc_y; | 44 | double con_x, con_y; |
63 | double swayc_width, swayc_height; | 45 | double con_width, con_height; |
64 | 46 | ||
65 | bool is_fullscreen; | 47 | bool is_fullscreen; |
66 | 48 | ||
67 | bool has_gaps; | 49 | struct sway_workspace *workspace; |
68 | double current_gaps; | ||
69 | double gaps_inner; | ||
70 | double gaps_outer; | ||
71 | |||
72 | struct sway_container *parent; | 50 | struct sway_container *parent; |
73 | list_t *children; | 51 | list_t *children; |
74 | 52 | ||
@@ -86,35 +64,19 @@ struct sway_container_state { | |||
86 | bool border_left; | 64 | bool border_left; |
87 | bool border_right; | 65 | bool border_right; |
88 | bool using_csd; | 66 | bool using_csd; |
89 | |||
90 | // Workspace properties | ||
91 | struct sway_container *ws_fullscreen; | ||
92 | list_t *ws_floating; | ||
93 | }; | 67 | }; |
94 | 68 | ||
95 | struct sway_container { | 69 | struct sway_container { |
96 | union { | 70 | struct sway_node node; |
97 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | 71 | struct sway_view *view; |
98 | struct sway_root *sway_root; | ||
99 | struct sway_output *sway_output; | ||
100 | struct sway_workspace *sway_workspace; | ||
101 | struct sway_view *sway_view; | ||
102 | }; | ||
103 | |||
104 | /** | ||
105 | * A unique ID to identify this container. Primarily used in the | ||
106 | * get_tree JSON output. | ||
107 | */ | ||
108 | size_t id; | ||
109 | 72 | ||
110 | // The pending state is the main container properties, and the current state is in the below struct. | 73 | // The pending state is the main container properties, and the current state is in the below struct. |
111 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | 74 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. |
112 | struct sway_container_state current; | 75 | struct sway_container_state current; |
113 | 76 | ||
114 | char *name; // The view's title (unformatted) | 77 | char *title; // The view's title (unformatted) |
115 | char *formatted_title; // The title displayed in the title bar | 78 | char *formatted_title; // The title displayed in the title bar |
116 | 79 | ||
117 | enum sway_container_type type; | ||
118 | enum sway_container_layout layout; | 80 | enum sway_container_layout layout; |
119 | enum sway_container_layout prev_split_layout; | 81 | enum sway_container_layout prev_split_layout; |
120 | 82 | ||
@@ -132,14 +94,13 @@ struct sway_container { | |||
132 | 94 | ||
133 | // The gaps currently applied to the container. | 95 | // The gaps currently applied to the container. |
134 | double current_gaps; | 96 | double current_gaps; |
135 | |||
136 | bool has_gaps; | 97 | bool has_gaps; |
137 | double gaps_inner; | 98 | double gaps_inner; |
138 | double gaps_outer; | 99 | double gaps_outer; |
139 | 100 | ||
140 | list_t *children; | 101 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad |
141 | 102 | struct sway_container *parent; // NULL if container in root of workspace | |
142 | struct sway_container *parent; | 103 | list_t *children; // struct sway_container |
143 | 104 | ||
144 | // Outputs currently being intersected | 105 | // Outputs currently being intersected |
145 | list_t *outputs; // struct sway_output | 106 | list_t *outputs; // struct sway_output |
@@ -157,42 +118,17 @@ struct sway_container { | |||
157 | struct wlr_texture *title_urgent; | 118 | struct wlr_texture *title_urgent; |
158 | size_t title_height; | 119 | size_t title_height; |
159 | 120 | ||
160 | // The number of transactions which reference this container. | ||
161 | size_t ntxnrefs; | ||
162 | |||
163 | // If this container is a view and is waiting for the client to respond to a | ||
164 | // configure then this will be populated, otherwise NULL. | ||
165 | struct sway_transaction_instruction *instruction; | ||
166 | |||
167 | bool destroying; | ||
168 | |||
169 | // If true, indicates that the container has pending state that differs from | ||
170 | // the current. | ||
171 | bool dirty; | ||
172 | |||
173 | struct { | 121 | struct { |
174 | struct wl_signal destroy; | 122 | struct wl_signal destroy; |
175 | } events; | 123 | } events; |
176 | }; | 124 | }; |
177 | 125 | ||
178 | struct sway_container *container_create(enum sway_container_type type); | 126 | struct sway_container *container_create(struct sway_view *view); |
179 | |||
180 | const char *container_type_to_str(enum sway_container_type type); | ||
181 | |||
182 | /* | ||
183 | * Create a new view container. A view can be a child of a workspace container | ||
184 | * or a container container and are rendered in the order and structure of | ||
185 | * how they are attached to the tree. | ||
186 | */ | ||
187 | struct sway_container *container_view_create( | ||
188 | struct sway_container *sibling, struct sway_view *sway_view); | ||
189 | 127 | ||
190 | void container_destroy(struct sway_container *con); | 128 | void container_destroy(struct sway_container *con); |
191 | 129 | ||
192 | void container_begin_destroy(struct sway_container *con); | 130 | void container_begin_destroy(struct sway_container *con); |
193 | 131 | ||
194 | struct sway_container *container_close(struct sway_container *container); | ||
195 | |||
196 | /** | 132 | /** |
197 | * Search a container's descendants a container based on test criteria. Returns | 133 | * Search a container's descendants a container based on test criteria. Returns |
198 | * the first container that passes the test. | 134 | * the first container that passes the test. |
@@ -201,22 +137,16 @@ struct sway_container *container_find_child(struct sway_container *container, | |||
201 | bool (*test)(struct sway_container *view, void *data), void *data); | 137 | bool (*test)(struct sway_container *view, void *data), void *data); |
202 | 138 | ||
203 | /** | 139 | /** |
204 | * Finds a parent container with the given struct sway_containerype. | ||
205 | */ | ||
206 | struct sway_container *container_parent(struct sway_container *container, | ||
207 | enum sway_container_type type); | ||
208 | |||
209 | /** | ||
210 | * Find a container at the given coordinates. Returns the the surface and | 140 | * Find a container at the given coordinates. Returns the the surface and |
211 | * surface-local coordinates of the given layout coordinates if the container | 141 | * surface-local coordinates of the given layout coordinates if the container |
212 | * is a view and the view contains a surface at those coordinates. | 142 | * is a view and the view contains a surface at those coordinates. |
213 | */ | 143 | */ |
214 | struct sway_container *container_at(struct sway_container *workspace, | 144 | struct sway_container *container_at(struct sway_workspace *workspace, |
215 | double lx, double ly, struct wlr_surface **surface, | 145 | double lx, double ly, struct wlr_surface **surface, |
216 | double *sx, double *sy); | 146 | double *sx, double *sy); |
217 | 147 | ||
218 | struct sway_container *tiling_container_at( | 148 | struct sway_container *tiling_container_at( |
219 | struct sway_container *con, double lx, double ly, | 149 | struct sway_node *parent, double lx, double ly, |
220 | struct wlr_surface **surface, double *sx, double *sy); | 150 | struct wlr_surface **surface, double *sx, double *sy); |
221 | 151 | ||
222 | void container_for_each_child(struct sway_container *container, | 152 | void container_for_each_child(struct sway_container *container, |
@@ -228,16 +158,11 @@ void container_for_each_child(struct sway_container *container, | |||
228 | bool container_has_ancestor(struct sway_container *container, | 158 | bool container_has_ancestor(struct sway_container *container, |
229 | struct sway_container *ancestor); | 159 | struct sway_container *ancestor); |
230 | 160 | ||
231 | int container_count_descendants_of_type(struct sway_container *con, | ||
232 | enum sway_container_type type); | ||
233 | |||
234 | void container_create_notify(struct sway_container *container); | ||
235 | |||
236 | void container_update_textures_recursive(struct sway_container *con); | 161 | void container_update_textures_recursive(struct sway_container *con); |
237 | 162 | ||
238 | void container_damage_whole(struct sway_container *container); | 163 | void container_damage_whole(struct sway_container *container); |
239 | 164 | ||
240 | struct sway_container *container_reap_empty(struct sway_container *con); | 165 | void container_reap_empty(struct sway_container *con); |
241 | 166 | ||
242 | struct sway_container *container_flatten(struct sway_container *container); | 167 | struct sway_container *container_flatten(struct sway_container *container); |
243 | 168 | ||
@@ -248,11 +173,10 @@ void container_update_title_textures(struct sway_container *container); | |||
248 | */ | 173 | */ |
249 | void container_calculate_title_height(struct sway_container *container); | 174 | void container_calculate_title_height(struct sway_container *container); |
250 | 175 | ||
251 | /** | 176 | size_t container_build_representation(enum sway_container_layout layout, |
252 | * Notify a container that a tree modification has changed in its children, | 177 | list_t *children, char *buffer); |
253 | * so the container can update its tree representation. | 178 | |
254 | */ | 179 | void container_update_representation(struct sway_container *container); |
255 | void container_notify_subtree_changed(struct sway_container *container); | ||
256 | 180 | ||
257 | /** | 181 | /** |
258 | * Return the height of a regular title bar. | 182 | * Return the height of a regular title bar. |
@@ -288,8 +212,7 @@ void container_floating_translate(struct sway_container *con, | |||
288 | /** | 212 | /** |
289 | * Choose an output for the floating container's new position. | 213 | * Choose an output for the floating container's new position. |
290 | */ | 214 | */ |
291 | struct sway_container *container_floating_find_output( | 215 | struct sway_output *container_floating_find_output(struct sway_container *con); |
292 | struct sway_container *con); | ||
293 | 216 | ||
294 | /** | 217 | /** |
295 | * Move a floating container to a new layout-local position. | 218 | * Move a floating container to a new layout-local position. |
@@ -302,12 +225,6 @@ void container_floating_move_to(struct sway_container *con, | |||
302 | */ | 225 | */ |
303 | void container_floating_move_to_center(struct sway_container *con); | 226 | void container_floating_move_to_center(struct sway_container *con); |
304 | 227 | ||
305 | /** | ||
306 | * Mark a container as dirty if it isn't already. Dirty containers will be | ||
307 | * included in the next transaction then unmarked as dirty. | ||
308 | */ | ||
309 | void container_set_dirty(struct sway_container *container); | ||
310 | |||
311 | bool container_has_urgent_child(struct sway_container *container); | 228 | bool container_has_urgent_child(struct sway_container *container); |
312 | 229 | ||
313 | /** | 230 | /** |
@@ -342,10 +259,18 @@ void container_remove_gaps(struct sway_container *container); | |||
342 | 259 | ||
343 | void container_add_gaps(struct sway_container *container); | 260 | void container_add_gaps(struct sway_container *container); |
344 | 261 | ||
262 | enum sway_container_layout container_parent_layout(struct sway_container *con); | ||
263 | |||
264 | enum sway_container_layout container_current_parent_layout( | ||
265 | struct sway_container *con); | ||
266 | |||
267 | list_t *container_get_siblings(const struct sway_container *container); | ||
268 | |||
345 | int container_sibling_index(const struct sway_container *child); | 269 | int container_sibling_index(const struct sway_container *child); |
346 | 270 | ||
347 | void container_handle_fullscreen_reparent(struct sway_container *con, | 271 | list_t *container_get_current_siblings(struct sway_container *container); |
348 | struct sway_container *old_parent); | 272 | |
273 | void container_handle_fullscreen_reparent(struct sway_container *con); | ||
349 | 274 | ||
350 | void container_add_child(struct sway_container *parent, | 275 | void container_add_child(struct sway_container *parent, |
351 | struct sway_container *child); | 276 | struct sway_container *child); |
@@ -353,19 +278,16 @@ void container_add_child(struct sway_container *parent, | |||
353 | void container_insert_child(struct sway_container *parent, | 278 | void container_insert_child(struct sway_container *parent, |
354 | struct sway_container *child, int i); | 279 | struct sway_container *child, int i); |
355 | 280 | ||
356 | struct sway_container *container_add_sibling(struct sway_container *parent, | 281 | void container_add_sibling(struct sway_container *parent, |
357 | struct sway_container *child); | 282 | struct sway_container *child, int offset); |
358 | 283 | ||
359 | struct sway_container *container_remove_child(struct sway_container *child); | 284 | void container_detach(struct sway_container *child); |
360 | 285 | ||
361 | struct sway_container *container_replace_child(struct sway_container *child, | 286 | void container_replace(struct sway_container *container, |
362 | struct sway_container *new_child); | 287 | struct sway_container *replacement); |
363 | 288 | ||
364 | bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out); | 289 | bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out); |
365 | 290 | ||
366 | enum sway_container_layout container_get_default_layout( | ||
367 | struct sway_container *con); | ||
368 | |||
369 | struct sway_container *container_split(struct sway_container *child, | 291 | struct sway_container *container_split(struct sway_container *child, |
370 | enum sway_container_layout layout); | 292 | enum sway_container_layout layout); |
371 | 293 | ||
diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h new file mode 100644 index 00000000..5b8c1909 --- /dev/null +++ b/include/sway/tree/node.h | |||
@@ -0,0 +1,74 @@ | |||
1 | #ifndef _SWAY_NODE_H | ||
2 | #define _SWAY_NODE_H | ||
3 | #include <stdbool.h> | ||
4 | #include "list.h" | ||
5 | |||
6 | struct sway_root; | ||
7 | struct sway_output; | ||
8 | struct sway_workspace; | ||
9 | struct sway_container; | ||
10 | struct sway_transaction_instruction; | ||
11 | struct wlr_box; | ||
12 | |||
13 | enum sway_node_type { | ||
14 | N_ROOT, | ||
15 | N_OUTPUT, | ||
16 | N_WORKSPACE, | ||
17 | N_CONTAINER, | ||
18 | }; | ||
19 | |||
20 | struct sway_node { | ||
21 | enum sway_node_type type; | ||
22 | union { | ||
23 | struct sway_root *sway_root; | ||
24 | struct sway_output *sway_output; | ||
25 | struct sway_workspace *sway_workspace; | ||
26 | struct sway_container *sway_container; | ||
27 | }; | ||
28 | |||
29 | /** | ||
30 | * A unique ID to identify this node. | ||
31 | * Primarily used in the get_tree JSON output. | ||
32 | */ | ||
33 | size_t id; | ||
34 | |||
35 | struct sway_transaction_instruction *instruction; | ||
36 | size_t ntxnrefs; | ||
37 | bool destroying; | ||
38 | |||
39 | // If true, indicates that the container has pending state that differs from | ||
40 | // the current. | ||
41 | bool dirty; | ||
42 | |||
43 | struct { | ||
44 | struct wl_signal destroy; | ||
45 | } events; | ||
46 | }; | ||
47 | |||
48 | void node_init(struct sway_node *node, enum sway_node_type type, void *thing); | ||
49 | |||
50 | const char *node_type_to_str(enum sway_node_type type); | ||
51 | |||
52 | /** | ||
53 | * Mark a node as dirty if it isn't already. Dirty nodes will be included in the | ||
54 | * next transaction then unmarked as dirty. | ||
55 | */ | ||
56 | void node_set_dirty(struct sway_node *node); | ||
57 | |||
58 | bool node_is_view(struct sway_node *node); | ||
59 | |||
60 | char *node_get_name(struct sway_node *node); | ||
61 | |||
62 | void node_get_box(struct sway_node *node, struct wlr_box *box); | ||
63 | |||
64 | struct sway_output *node_get_output(struct sway_node *node); | ||
65 | |||
66 | enum sway_container_layout node_get_layout(struct sway_node *node); | ||
67 | |||
68 | struct sway_node *node_get_parent(struct sway_node *node); | ||
69 | |||
70 | list_t *node_get_children(struct sway_node *node); | ||
71 | |||
72 | bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor); | ||
73 | |||
74 | #endif | ||
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index ec6516c9..a2d464f9 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h | |||
@@ -5,12 +5,14 @@ | |||
5 | #include <wlr/types/wlr_output_layout.h> | 5 | #include <wlr/types/wlr_output_layout.h> |
6 | #include <wlr/render/wlr_texture.h> | 6 | #include <wlr/render/wlr_texture.h> |
7 | #include "sway/tree/container.h" | 7 | #include "sway/tree/container.h" |
8 | #include "sway/tree/node.h" | ||
8 | #include "config.h" | 9 | #include "config.h" |
9 | #include "list.h" | 10 | #include "list.h" |
10 | 11 | ||
11 | extern struct sway_container root_container; | 12 | extern struct sway_root *root; |
12 | 13 | ||
13 | struct sway_root { | 14 | struct sway_root { |
15 | struct sway_node node; | ||
14 | struct wlr_output_layout *output_layout; | 16 | struct wlr_output_layout *output_layout; |
15 | 17 | ||
16 | struct wl_listener output_layout_change; | 18 | struct wl_listener output_layout_change; |
@@ -24,17 +26,21 @@ struct sway_root { | |||
24 | // Includes disabled outputs | 26 | // Includes disabled outputs |
25 | struct wl_list all_outputs; // sway_output::link | 27 | struct wl_list all_outputs; // sway_output::link |
26 | 28 | ||
29 | double x, y; | ||
30 | double width, height; | ||
31 | |||
32 | list_t *outputs; // struct sway_output | ||
27 | list_t *scratchpad; // struct sway_container | 33 | list_t *scratchpad; // struct sway_container |
28 | list_t *saved_workspaces; // For when there's no connected outputs | 34 | list_t *saved_workspaces; // For when there's no connected outputs |
29 | 35 | ||
30 | struct { | 36 | struct { |
31 | struct wl_signal new_container; | 37 | struct wl_signal new_node; |
32 | } events; | 38 | } events; |
33 | }; | 39 | }; |
34 | 40 | ||
35 | void root_create(void); | 41 | struct sway_root *root_create(void); |
36 | 42 | ||
37 | void root_destroy(void); | 43 | void root_destroy(struct sway_root *root); |
38 | 44 | ||
39 | /** | 45 | /** |
40 | * Move a container to the scratchpad. | 46 | * Move a container to the scratchpad. |
@@ -56,23 +62,25 @@ void root_scratchpad_show(struct sway_container *con); | |||
56 | */ | 62 | */ |
57 | void root_scratchpad_hide(struct sway_container *con); | 63 | void root_scratchpad_hide(struct sway_container *con); |
58 | 64 | ||
59 | struct sway_container *root_workspace_for_pid(pid_t pid); | 65 | struct sway_workspace *root_workspace_for_pid(pid_t pid); |
60 | 66 | ||
61 | void root_record_workspace_pid(pid_t pid); | 67 | void root_record_workspace_pid(pid_t pid); |
62 | 68 | ||
63 | void root_for_each_workspace(void (*f)(struct sway_container *con, void *data), | 69 | void root_for_each_workspace(void (*f)(struct sway_workspace *ws, void *data), |
64 | void *data); | 70 | void *data); |
65 | 71 | ||
66 | void root_for_each_container(void (*f)(struct sway_container *con, void *data), | 72 | void root_for_each_container(void (*f)(struct sway_container *con, void *data), |
67 | void *data); | 73 | void *data); |
68 | 74 | ||
69 | struct sway_container *root_find_output( | 75 | struct sway_output *root_find_output( |
70 | bool (*test)(struct sway_container *con, void *data), void *data); | 76 | bool (*test)(struct sway_output *output, void *data), void *data); |
71 | 77 | ||
72 | struct sway_container *root_find_workspace( | 78 | struct sway_workspace *root_find_workspace( |
73 | bool (*test)(struct sway_container *con, void *data), void *data); | 79 | bool (*test)(struct sway_workspace *ws, void *data), void *data); |
74 | 80 | ||
75 | struct sway_container *root_find_container( | 81 | struct sway_container *root_find_container( |
76 | bool (*test)(struct sway_container *con, void *data), void *data); | 82 | bool (*test)(struct sway_container *con, void *data), void *data); |
77 | 83 | ||
84 | void root_get_box(struct sway_root *root, struct wlr_box *box); | ||
85 | |||
78 | #endif | 86 | #endif |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 30d3e742..439dc1bf 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -58,7 +58,7 @@ struct sway_view { | |||
58 | enum sway_view_type type; | 58 | enum sway_view_type type; |
59 | const struct sway_view_impl *impl; | 59 | const struct sway_view_impl *impl; |
60 | 60 | ||
61 | struct sway_container *swayc; // NULL for unmapped views | 61 | struct sway_container *container; // NULL if unmapped and transactions finished |
62 | struct wlr_surface *surface; // NULL for unmapped views | 62 | struct wlr_surface *surface; // NULL for unmapped views |
63 | 63 | ||
64 | // Geometry of the view itself (excludes borders) in layout coordinates | 64 | // Geometry of the view itself (excludes borders) in layout coordinates |
@@ -254,7 +254,7 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, | |||
254 | int height); | 254 | int height); |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * Configure the view's position and size based on the swayc's position and | 257 | * Configure the view's position and size based on the container's position and |
258 | * size, taking borders into consideration. | 258 | * size, taking borders into consideration. |
259 | */ | 259 | */ |
260 | void view_autoconfigure(struct sway_view *view); | 260 | void view_autoconfigure(struct sway_view *view); |
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 04325919..af9a071a 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h | |||
@@ -3,66 +3,98 @@ | |||
3 | 3 | ||
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include "sway/tree/container.h" | 5 | #include "sway/tree/container.h" |
6 | #include "sway/tree/node.h" | ||
6 | 7 | ||
7 | struct sway_view; | 8 | struct sway_view; |
8 | 9 | ||
10 | struct sway_workspace_state { | ||
11 | struct sway_container *fullscreen; | ||
12 | double x, y; | ||
13 | int width, height; | ||
14 | enum sway_container_layout layout; | ||
15 | struct sway_output *output; | ||
16 | list_t *floating; | ||
17 | list_t *tiling; | ||
18 | |||
19 | struct sway_container *focused_inactive_child; | ||
20 | bool focused; | ||
21 | }; | ||
22 | |||
9 | struct sway_workspace { | 23 | struct sway_workspace { |
10 | struct sway_container *swayc; | 24 | struct sway_node node; |
11 | struct sway_container *fullscreen; | 25 | struct sway_container *fullscreen; |
12 | list_t *floating; // struct sway_container | 26 | |
27 | char *name; | ||
28 | char *representation; | ||
29 | |||
30 | double x, y; | ||
31 | int width, height; | ||
32 | enum sway_container_layout layout; | ||
33 | enum sway_container_layout prev_split_layout; | ||
34 | |||
35 | double current_gaps; | ||
36 | bool has_gaps; | ||
37 | double gaps_inner; | ||
38 | double gaps_outer; | ||
39 | |||
40 | struct sway_output *output; // NULL if no outputs are connected | ||
41 | list_t *floating; // struct sway_container | ||
42 | list_t *tiling; // struct sway_container | ||
13 | list_t *output_priority; | 43 | list_t *output_priority; |
14 | bool urgent; | 44 | bool urgent; |
45 | |||
46 | struct sway_workspace_state current; | ||
15 | }; | 47 | }; |
16 | 48 | ||
17 | extern char *prev_workspace_name; | 49 | extern char *prev_workspace_name; |
18 | 50 | ||
19 | struct sway_container *workspace_get_initial_output(const char *name); | 51 | struct sway_output *workspace_get_initial_output(const char *name); |
20 | 52 | ||
21 | struct sway_container *workspace_create(struct sway_container *output, | 53 | struct sway_workspace *workspace_create(struct sway_output *output, |
22 | const char *name); | 54 | const char *name); |
23 | 55 | ||
24 | void workspace_destroy(struct sway_container *workspace); | 56 | void workspace_destroy(struct sway_workspace *workspace); |
25 | 57 | ||
26 | void workspace_begin_destroy(struct sway_container *workspace); | 58 | void workspace_begin_destroy(struct sway_workspace *workspace); |
27 | 59 | ||
28 | void workspace_consider_destroy(struct sway_container *ws); | 60 | void workspace_consider_destroy(struct sway_workspace *ws); |
29 | 61 | ||
30 | char *workspace_next_name(const char *output_name); | 62 | char *workspace_next_name(const char *output_name); |
31 | 63 | ||
32 | bool workspace_switch(struct sway_container *workspace, | 64 | bool workspace_switch(struct sway_workspace *workspace, |
33 | bool no_auto_back_and_forth); | 65 | bool no_auto_back_and_forth); |
34 | 66 | ||
35 | struct sway_container *workspace_by_number(const char* name); | 67 | struct sway_workspace *workspace_by_number(const char* name); |
36 | 68 | ||
37 | struct sway_container *workspace_by_name(const char*); | 69 | struct sway_workspace *workspace_by_name(const char*); |
38 | 70 | ||
39 | struct sway_container *workspace_output_next(struct sway_container *current); | 71 | struct sway_workspace *workspace_output_next(struct sway_workspace *current); |
40 | 72 | ||
41 | struct sway_container *workspace_next(struct sway_container *current); | 73 | struct sway_workspace *workspace_next(struct sway_workspace *current); |
42 | 74 | ||
43 | struct sway_container *workspace_output_prev(struct sway_container *current); | 75 | struct sway_workspace *workspace_output_prev(struct sway_workspace *current); |
44 | 76 | ||
45 | struct sway_container *workspace_prev(struct sway_container *current); | 77 | struct sway_workspace *workspace_prev(struct sway_workspace *current); |
46 | 78 | ||
47 | bool workspace_is_visible(struct sway_container *ws); | 79 | bool workspace_is_visible(struct sway_workspace *ws); |
48 | 80 | ||
49 | bool workspace_is_empty(struct sway_container *ws); | 81 | bool workspace_is_empty(struct sway_workspace *ws); |
50 | 82 | ||
51 | void workspace_output_raise_priority(struct sway_container *workspace, | 83 | void workspace_output_raise_priority(struct sway_workspace *workspace, |
52 | struct sway_container *old_output, struct sway_container *new_output); | 84 | struct sway_output *old_output, struct sway_output *new_output); |
53 | 85 | ||
54 | void workspace_output_add_priority(struct sway_container *workspace, | 86 | void workspace_output_add_priority(struct sway_workspace *workspace, |
55 | struct sway_container *output); | 87 | struct sway_output *output); |
56 | 88 | ||
57 | struct sway_container *workspace_output_get_highest_available( | 89 | struct sway_output *workspace_output_get_highest_available( |
58 | struct sway_container *ws, struct sway_container *exclude); | 90 | struct sway_workspace *ws, struct sway_output *exclude); |
59 | 91 | ||
60 | void workspace_detect_urgent(struct sway_container *workspace); | 92 | void workspace_detect_urgent(struct sway_workspace *workspace); |
61 | 93 | ||
62 | void workspace_for_each_container(struct sway_container *ws, | 94 | void workspace_for_each_container(struct sway_workspace *ws, |
63 | void (*f)(struct sway_container *con, void *data), void *data); | 95 | void (*f)(struct sway_container *con, void *data), void *data); |
64 | 96 | ||
65 | struct sway_container *workspace_find_container(struct sway_container *ws, | 97 | struct sway_container *workspace_find_container(struct sway_workspace *ws, |
66 | bool (*test)(struct sway_container *con, void *data), void *data); | 98 | bool (*test)(struct sway_container *con, void *data), void *data); |
67 | 99 | ||
68 | /** | 100 | /** |
@@ -70,13 +102,28 @@ struct sway_container *workspace_find_container(struct sway_container *ws, | |||
70 | * The new container will be the only direct tiling child of the workspace. | 102 | * The new container will be the only direct tiling child of the workspace. |
71 | * The new container is returned. | 103 | * The new container is returned. |
72 | */ | 104 | */ |
73 | struct sway_container *workspace_wrap_children(struct sway_container *ws); | 105 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws); |
74 | 106 | ||
75 | void workspace_add_floating(struct sway_container *workspace, | 107 | void workspace_detach(struct sway_workspace *workspace); |
108 | |||
109 | void workspace_add_tiling(struct sway_workspace *workspace, | ||
110 | struct sway_container *con); | ||
111 | |||
112 | void workspace_add_floating(struct sway_workspace *workspace, | ||
76 | struct sway_container *con); | 113 | struct sway_container *con); |
77 | 114 | ||
78 | void workspace_remove_gaps(struct sway_container *ws); | 115 | void workspace_insert_tiling(struct sway_workspace *workspace, |
116 | struct sway_container *con, int index); | ||
117 | |||
118 | void workspace_remove_gaps(struct sway_workspace *ws); | ||
119 | |||
120 | void workspace_add_gaps(struct sway_workspace *ws); | ||
121 | |||
122 | struct sway_container *workspace_split(struct sway_workspace *workspace, | ||
123 | enum sway_container_layout layout); | ||
124 | |||
125 | void workspace_update_representation(struct sway_workspace *ws); | ||
79 | 126 | ||
80 | void workspace_add_gaps(struct sway_container *ws); | 127 | void workspace_get_box(struct sway_workspace *workspace, struct wlr_box *box); |
81 | 128 | ||
82 | #endif | 129 | #endif |