diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-03-29 16:17:55 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-03-29 16:40:40 -0400 |
commit | b90099b4b7df8068446c658ab99b58ff83648954 (patch) | |
tree | a822ef3605ce98f9d8633c24f6927bb11effbdcc /sway/tree | |
parent | remove swayc_t typedef (diff) | |
download | sway-b90099b4b7df8068446c658ab99b58ff83648954.tar.gz sway-b90099b4b7df8068446c658ab99b58ff83648954.tar.zst sway-b90099b4b7df8068446c658ab99b58ff83648954.zip |
rename container functions
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 182 | ||||
-rw-r--r-- | sway/tree/layout.c | 86 | ||||
-rw-r--r-- | sway/tree/workspace.c | 70 |
3 files changed, 169 insertions, 169 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 805d5644..d31966b3 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -33,48 +33,15 @@ static list_t *get_bfs_queue() { | |||
33 | return bfs_queue; | 33 | return bfs_queue; |
34 | } | 34 | } |
35 | 35 | ||
36 | static void notify_new_container(swayc_t *container) { | 36 | static void notify_new_container(struct sway_container *container) { |
37 | wl_signal_emit(&root_container.sway_root->events.new_container, container); | 37 | wl_signal_emit(&root_container.sway_root->events.new_container, container); |
38 | ipc_event_window(container, "new"); | 38 | ipc_event_window(container, "new"); |
39 | } | 39 | } |
40 | 40 | ||
41 | swayc_t *swayc_by_test(swayc_t *container, | 41 | static struct sway_container *new_swayc(enum sway_container_type type) { |
42 | bool (*test)(swayc_t *view, void *data), void *data) { | ||
43 | if (!container->children) { | ||
44 | return NULL; | ||
45 | } | ||
46 | // TODO: floating windows | ||
47 | for (int i = 0; i < container->children->length; ++i) { | ||
48 | swayc_t *child = container->children->items[i]; | ||
49 | if (test(child, data)) { | ||
50 | return child; | ||
51 | } else { | ||
52 | swayc_t *res = swayc_by_test(child, test, data); | ||
53 | if (res) { | ||
54 | return res; | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | return NULL; | ||
59 | } | ||
60 | |||
61 | void swayc_descendants_of_type(swayc_t *root, enum swayc_types type, | ||
62 | void (*func)(swayc_t *item, void *data), void *data) { | ||
63 | for (int i = 0; i < root->children->length; ++i) { | ||
64 | swayc_t *item = root->children->items[i]; | ||
65 | if (item->type == type) { | ||
66 | func(item, data); | ||
67 | } | ||
68 | if (item->children && item->children->length) { | ||
69 | swayc_descendants_of_type(item, type, func, data); | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | |||
74 | static swayc_t *new_swayc(enum swayc_types type) { | ||
75 | // next id starts at 1 because 0 is assigned to root_container in layout.c | 42 | // next id starts at 1 because 0 is assigned to root_container in layout.c |
76 | static size_t next_id = 1; | 43 | static size_t next_id = 1; |
77 | swayc_t *c = calloc(1, sizeof(swayc_t)); | 44 | struct sway_container *c = calloc(1, sizeof(struct sway_container)); |
78 | if (!c) { | 45 | if (!c) { |
79 | return NULL; | 46 | return NULL; |
80 | } | 47 | } |
@@ -91,7 +58,7 @@ static swayc_t *new_swayc(enum swayc_types type) { | |||
91 | return c; | 58 | return c; |
92 | } | 59 | } |
93 | 60 | ||
94 | static void free_swayc(swayc_t *cont) { | 61 | static void free_swayc(struct sway_container *cont) { |
95 | if (!sway_assert(cont, "free_swayc passed NULL")) { | 62 | if (!sway_assert(cont, "free_swayc passed NULL")) { |
96 | return; | 63 | return; |
97 | } | 64 | } |
@@ -119,7 +86,7 @@ static void free_swayc(swayc_t *cont) { | |||
119 | free(cont); | 86 | free(cont); |
120 | } | 87 | } |
121 | 88 | ||
122 | swayc_t *new_output(struct sway_output *sway_output) { | 89 | struct sway_container *sway_container_output_create(struct sway_output *sway_output) { |
123 | struct wlr_box size; | 90 | struct wlr_box size; |
124 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, | 91 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, |
125 | &size.height); | 92 | &size.height); |
@@ -154,7 +121,7 @@ swayc_t *new_output(struct sway_output *sway_output) { | |||
154 | return NULL; | 121 | return NULL; |
155 | } | 122 | } |
156 | 123 | ||
157 | swayc_t *output = new_swayc(C_OUTPUT); | 124 | struct sway_container *output = new_swayc(C_OUTPUT); |
158 | output->sway_output = sway_output; | 125 | output->sway_output = sway_output; |
159 | output->name = strdup(name); | 126 | output->name = strdup(name); |
160 | if (output->name == NULL) { | 127 | if (output->name == NULL) { |
@@ -169,7 +136,7 @@ swayc_t *new_output(struct sway_output *sway_output) { | |||
169 | // Create workspace | 136 | // Create workspace |
170 | char *ws_name = workspace_next_name(output->name); | 137 | char *ws_name = workspace_next_name(output->name); |
171 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); | 138 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); |
172 | swayc_t *ws = new_workspace(output, ws_name); | 139 | struct sway_container *ws = sway_container_workspace_create(output, ws_name); |
173 | // Set each seat's focus if not already set | 140 | // Set each seat's focus if not already set |
174 | struct sway_seat *seat = NULL; | 141 | struct sway_seat *seat = NULL; |
175 | wl_list_for_each(seat, &input_manager->seats, link) { | 142 | wl_list_for_each(seat, &input_manager->seats, link) { |
@@ -183,12 +150,12 @@ swayc_t *new_output(struct sway_output *sway_output) { | |||
183 | return output; | 150 | return output; |
184 | } | 151 | } |
185 | 152 | ||
186 | swayc_t *new_workspace(swayc_t *output, const char *name) { | 153 | struct sway_container *sway_container_workspace_create(struct sway_container *output, const char *name) { |
187 | if (!sway_assert(output, "new_workspace called with null output")) { | 154 | if (!sway_assert(output, "sway_container_workspace_create called with null output")) { |
188 | return NULL; | 155 | return NULL; |
189 | } | 156 | } |
190 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); | 157 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); |
191 | swayc_t *workspace = new_swayc(C_WORKSPACE); | 158 | struct sway_container *workspace = new_swayc(C_WORKSPACE); |
192 | 159 | ||
193 | workspace->x = output->x; | 160 | workspace->x = output->x; |
194 | workspace->y = output->y; | 161 | workspace->y = output->y; |
@@ -205,12 +172,12 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { | |||
205 | return workspace; | 172 | return workspace; |
206 | } | 173 | } |
207 | 174 | ||
208 | swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) { | 175 | struct sway_container *sway_container_view_create(struct sway_container *sibling, struct sway_view *sway_view) { |
209 | if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) { | 176 | if (!sway_assert(sibling, "sway_container_view_create called with NULL sibling/parent")) { |
210 | return NULL; | 177 | return NULL; |
211 | } | 178 | } |
212 | const char *title = view_get_title(sway_view); | 179 | const char *title = view_get_title(sway_view); |
213 | swayc_t *swayc = new_swayc(C_VIEW); | 180 | struct sway_container *swayc = new_swayc(C_VIEW); |
214 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s", | 181 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s", |
215 | swayc, title, sibling, sibling ? sibling->type : 0, sibling->name); | 182 | swayc, title, sibling, sibling ? sibling->type : 0, sibling->name); |
216 | // Setup values | 183 | // Setup values |
@@ -230,8 +197,8 @@ swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) { | |||
230 | return swayc; | 197 | return swayc; |
231 | } | 198 | } |
232 | 199 | ||
233 | swayc_t *destroy_output(swayc_t *output) { | 200 | struct sway_container *sway_container_output_destroy(struct sway_container *output) { |
234 | if (!sway_assert(output, "null output passed to destroy_output")) { | 201 | if (!sway_assert(output, "null output passed to sway_container_output_destroy")) { |
235 | return NULL; | 202 | return NULL; |
236 | } | 203 | } |
237 | 204 | ||
@@ -243,7 +210,7 @@ swayc_t *destroy_output(swayc_t *output) { | |||
243 | int p = root_container.children->items[0] == output; | 210 | int p = root_container.children->items[0] == output; |
244 | // Move workspace from this output to another output | 211 | // Move workspace from this output to another output |
245 | while (output->children->length) { | 212 | while (output->children->length) { |
246 | swayc_t *child = output->children->items[0]; | 213 | struct sway_container *child = output->children->items[0]; |
247 | remove_child(child); | 214 | remove_child(child); |
248 | add_child(root_container.children->items[p], child); | 215 | add_child(root_container.children->items[p], child); |
249 | } | 216 | } |
@@ -262,12 +229,12 @@ swayc_t *destroy_output(swayc_t *output) { | |||
262 | return &root_container; | 229 | return &root_container; |
263 | } | 230 | } |
264 | 231 | ||
265 | swayc_t *destroy_view(swayc_t *view) { | 232 | struct sway_container *sway_container_view_destroy(struct sway_container *view) { |
266 | if (!view) { | 233 | if (!view) { |
267 | return NULL; | 234 | return NULL; |
268 | } | 235 | } |
269 | wlr_log(L_DEBUG, "Destroying view '%s'", view->name); | 236 | wlr_log(L_DEBUG, "Destroying view '%s'", view->name); |
270 | swayc_t *parent = view->parent; | 237 | struct sway_container *parent = view->parent; |
271 | free_swayc(view); | 238 | free_swayc(view); |
272 | 239 | ||
273 | // TODO WLR: Destroy empty containers | 240 | // TODO WLR: Destroy empty containers |
@@ -279,7 +246,52 @@ swayc_t *destroy_view(swayc_t *view) { | |||
279 | return parent; | 246 | return parent; |
280 | } | 247 | } |
281 | 248 | ||
282 | swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) { | 249 | struct sway_container *swayc_change_layout(struct sway_container *container, enum sway_container_layout layout) { |
250 | if (container->type == C_WORKSPACE) { | ||
251 | container->workspace_layout = layout; | ||
252 | if (layout == L_HORIZ || layout == L_VERT) { | ||
253 | container->layout = layout; | ||
254 | } | ||
255 | } else { | ||
256 | container->layout = layout; | ||
257 | } | ||
258 | return container; | ||
259 | } | ||
260 | |||
261 | void sway_container_descendents(struct sway_container *root, enum sway_container_type type, | ||
262 | void (*func)(struct sway_container *item, void *data), void *data) { | ||
263 | for (int i = 0; i < root->children->length; ++i) { | ||
264 | struct sway_container *item = root->children->items[i]; | ||
265 | if (item->type == type) { | ||
266 | func(item, data); | ||
267 | } | ||
268 | if (item->children && item->children->length) { | ||
269 | sway_container_descendents(item, type, func, data); | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | struct sway_container *sway_container_find(struct sway_container *container, | ||
275 | bool (*test)(struct sway_container *view, void *data), void *data) { | ||
276 | if (!container->children) { | ||
277 | return NULL; | ||
278 | } | ||
279 | // TODO: floating windows | ||
280 | for (int i = 0; i < container->children->length; ++i) { | ||
281 | struct sway_container *child = container->children->items[i]; | ||
282 | if (test(child, data)) { | ||
283 | return child; | ||
284 | } else { | ||
285 | struct sway_container *res = sway_container_find(child, test, data); | ||
286 | if (res) { | ||
287 | return res; | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | return NULL; | ||
292 | } | ||
293 | |||
294 | struct sway_container *sway_container_parent(struct sway_container *container, enum sway_container_type type) { | ||
283 | if (!sway_assert(container, "container is NULL")) { | 295 | if (!sway_assert(container, "container is NULL")) { |
284 | return NULL; | 296 | return NULL; |
285 | } | 297 | } |
@@ -292,7 +304,29 @@ swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) { | |||
292 | return container; | 304 | return container; |
293 | } | 305 | } |
294 | 306 | ||
295 | swayc_t *swayc_at(swayc_t *parent, double lx, double ly, | 307 | void sway_container_for_each(struct sway_container *container, void (*f)(struct sway_container *view, void *data), void *data) { |
308 | if (container) { | ||
309 | int i; | ||
310 | if (container->children) { | ||
311 | for (i = 0; i < container->children->length; ++i) { | ||
312 | struct sway_container *child = container->children->items[i]; | ||
313 | sway_container_for_each(child, f, data); | ||
314 | } | ||
315 | } | ||
316 | // TODO | ||
317 | /* | ||
318 | if (container->floating) { | ||
319 | for (i = 0; i < container->floating->length; ++i) { | ||
320 | struct sway_container *child = container->floating->items[i]; | ||
321 | container_map(child, f, data); | ||
322 | } | ||
323 | } | ||
324 | */ | ||
325 | f(container, data); | ||
326 | } | ||
327 | } | ||
328 | |||
329 | struct sway_container *sway_container_at(struct sway_container *parent, double lx, double ly, | ||
296 | struct wlr_surface **surface, double *sx, double *sy) { | 330 | struct wlr_surface **surface, double *sx, double *sy) { |
297 | list_t *queue = get_bfs_queue(); | 331 | list_t *queue = get_bfs_queue(); |
298 | if (!queue) { | 332 | if (!queue) { |
@@ -301,13 +335,13 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly, | |||
301 | 335 | ||
302 | list_add(queue, parent); | 336 | list_add(queue, parent); |
303 | 337 | ||
304 | swayc_t *swayc = NULL; | 338 | struct sway_container *swayc = NULL; |
305 | while (queue->length) { | 339 | while (queue->length) { |
306 | swayc = queue->items[0]; | 340 | swayc = queue->items[0]; |
307 | list_del(queue, 0); | 341 | list_del(queue, 0); |
308 | if (swayc->type == C_VIEW) { | 342 | if (swayc->type == C_VIEW) { |
309 | struct sway_view *sview = swayc->sway_view; | 343 | struct sway_view *sview = swayc->sway_view; |
310 | swayc_t *soutput = swayc_parent_by_type(swayc, C_OUTPUT); | 344 | struct sway_container *soutput = sway_container_parent(swayc, C_OUTPUT); |
311 | struct wlr_box *output_box = | 345 | struct wlr_box *output_box = |
312 | wlr_output_layout_get_box( | 346 | wlr_output_layout_get_box( |
313 | root_container.sway_root->output_layout, | 347 | root_container.sway_root->output_layout, |
@@ -377,29 +411,7 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly, | |||
377 | return NULL; | 411 | return NULL; |
378 | } | 412 | } |
379 | 413 | ||
380 | void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) { | 414 | void sway_container_for_each_bfs(struct sway_container *con, void (*f)(struct sway_container *con, void *data), |
381 | if (container) { | ||
382 | int i; | ||
383 | if (container->children) { | ||
384 | for (i = 0; i < container->children->length; ++i) { | ||
385 | swayc_t *child = container->children->items[i]; | ||
386 | container_map(child, f, data); | ||
387 | } | ||
388 | } | ||
389 | // TODO | ||
390 | /* | ||
391 | if (container->floating) { | ||
392 | for (i = 0; i < container->floating->length; ++i) { | ||
393 | swayc_t *child = container->floating->items[i]; | ||
394 | container_map(child, f, data); | ||
395 | } | ||
396 | } | ||
397 | */ | ||
398 | f(container, data); | ||
399 | } | ||
400 | } | ||
401 | |||
402 | void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), | ||
403 | void *data) { | 415 | void *data) { |
404 | list_t *queue = get_bfs_queue(); | 416 | list_t *queue = get_bfs_queue(); |
405 | if (!queue) { | 417 | if (!queue) { |
@@ -413,7 +425,7 @@ void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), | |||
413 | 425 | ||
414 | list_add(queue, con); | 426 | list_add(queue, con); |
415 | 427 | ||
416 | swayc_t *current = NULL; | 428 | struct sway_container *current = NULL; |
417 | while (queue->length) { | 429 | while (queue->length) { |
418 | current = queue->items[0]; | 430 | current = queue->items[0]; |
419 | list_del(queue, 0); | 431 | list_del(queue, 0); |
@@ -422,15 +434,3 @@ void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), | |||
422 | list_cat(queue, current->children); | 434 | list_cat(queue, current->children); |
423 | } | 435 | } |
424 | } | 436 | } |
425 | |||
426 | swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) { | ||
427 | if (container->type == C_WORKSPACE) { | ||
428 | container->workspace_layout = layout; | ||
429 | if (layout == L_HORIZ || layout == L_VERT) { | ||
430 | container->layout = layout; | ||
431 | } | ||
432 | } else { | ||
433 | container->layout = layout; | ||
434 | } | ||
435 | return container; | ||
436 | } | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 5a15f3a2..068fb39c 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include "list.h" | 14 | #include "list.h" |
15 | #include "log.h" | 15 | #include "log.h" |
16 | 16 | ||
17 | swayc_t root_container; | 17 | struct sway_container root_container; |
18 | 18 | ||
19 | static void output_layout_change_notify(struct wl_listener *listener, void *data) { | 19 | static void output_layout_change_notify(struct wl_listener *listener, void *data) { |
20 | struct wlr_box *layout_box = wlr_output_layout_get_box( | 20 | struct wlr_box *layout_box = wlr_output_layout_get_box( |
@@ -23,7 +23,7 @@ static void output_layout_change_notify(struct wl_listener *listener, void *data | |||
23 | root_container.height = layout_box->height; | 23 | root_container.height = layout_box->height; |
24 | 24 | ||
25 | for (int i = 0 ; i < root_container.children->length; ++i) { | 25 | for (int i = 0 ; i < root_container.children->length; ++i) { |
26 | swayc_t *output_container = root_container.children->items[i]; | 26 | struct sway_container *output_container = root_container.children->items[i]; |
27 | if (output_container->type != C_OUTPUT) { | 27 | if (output_container->type != C_OUTPUT) { |
28 | continue; | 28 | continue; |
29 | } | 29 | } |
@@ -62,9 +62,9 @@ void init_layout(void) { | |||
62 | &root_container.sway_root->output_layout_change); | 62 | &root_container.sway_root->output_layout_change); |
63 | } | 63 | } |
64 | 64 | ||
65 | static int index_child(const swayc_t *child) { | 65 | static int index_child(const struct sway_container *child) { |
66 | // TODO handle floating | 66 | // TODO handle floating |
67 | swayc_t *parent = child->parent; | 67 | struct sway_container *parent = child->parent; |
68 | int i, len; | 68 | int i, len; |
69 | len = parent->children->length; | 69 | len = parent->children->length; |
70 | for (i = 0; i < len; ++i) { | 70 | for (i = 0; i < len; ++i) { |
@@ -79,16 +79,16 @@ static int index_child(const swayc_t *child) { | |||
79 | return i; | 79 | return i; |
80 | } | 80 | } |
81 | 81 | ||
82 | swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) { | 82 | struct sway_container *add_sibling(struct sway_container *fixed, struct sway_container *active) { |
83 | // TODO handle floating | 83 | // TODO handle floating |
84 | swayc_t *parent = fixed->parent; | 84 | struct sway_container *parent = fixed->parent; |
85 | int i = index_child(fixed); | 85 | int i = index_child(fixed); |
86 | list_insert(parent->children, i + 1, active); | 86 | list_insert(parent->children, i + 1, active); |
87 | active->parent = parent; | 87 | active->parent = parent; |
88 | return active->parent; | 88 | return active->parent; |
89 | } | 89 | } |
90 | 90 | ||
91 | void add_child(swayc_t *parent, swayc_t *child) { | 91 | void add_child(struct sway_container *parent, struct sway_container *child) { |
92 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", | 92 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", |
93 | child, child->type, child->width, child->height, | 93 | child, child->type, child->width, child->height, |
94 | parent, parent->type, parent->width, parent->height); | 94 | parent, parent->type, parent->width, parent->height); |
@@ -102,9 +102,9 @@ void add_child(swayc_t *parent, swayc_t *child) { | |||
102 | */ | 102 | */ |
103 | } | 103 | } |
104 | 104 | ||
105 | swayc_t *remove_child(swayc_t *child) { | 105 | struct sway_container *remove_child(struct sway_container *child) { |
106 | int i; | 106 | int i; |
107 | swayc_t *parent = child->parent; | 107 | struct sway_container *parent = child->parent; |
108 | for (i = 0; i < parent->children->length; ++i) { | 108 | for (i = 0; i < parent->children->length; ++i) { |
109 | if (parent->children->items[i] == child) { | 109 | if (parent->children->items[i] == child) { |
110 | list_del(parent->children, i); | 110 | list_del(parent->children, i); |
@@ -115,7 +115,7 @@ swayc_t *remove_child(swayc_t *child) { | |||
115 | return parent; | 115 | return parent; |
116 | } | 116 | } |
117 | 117 | ||
118 | enum swayc_layouts default_layout(swayc_t *output) { | 118 | enum sway_container_layout default_layout(struct sway_container *output) { |
119 | /* TODO WLR | 119 | /* TODO WLR |
120 | if (config->default_layout != L_NONE) { | 120 | if (config->default_layout != L_NONE) { |
121 | //return config->default_layout; | 121 | //return config->default_layout; |
@@ -129,8 +129,8 @@ enum swayc_layouts default_layout(swayc_t *output) { | |||
129 | } | 129 | } |
130 | 130 | ||
131 | static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { | 131 | static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { |
132 | swayc_t *a = *(void **)_a; | 132 | struct sway_container *a = *(void **)_a; |
133 | swayc_t *b = *(void **)_b; | 133 | struct sway_container *b = *(void **)_b; |
134 | int retval = 0; | 134 | int retval = 0; |
135 | 135 | ||
136 | if (isdigit(a->name[0]) && isdigit(b->name[0])) { | 136 | if (isdigit(a->name[0]) && isdigit(b->name[0])) { |
@@ -146,21 +146,21 @@ static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { | |||
146 | return retval; | 146 | return retval; |
147 | } | 147 | } |
148 | 148 | ||
149 | void sort_workspaces(swayc_t *output) { | 149 | void sort_workspaces(struct sway_container *output) { |
150 | list_stable_sort(output->children, sort_workspace_cmp_qsort); | 150 | list_stable_sort(output->children, sort_workspace_cmp_qsort); |
151 | } | 151 | } |
152 | 152 | ||
153 | static void apply_horiz_layout(swayc_t *container, const double x, | 153 | static void apply_horiz_layout(struct sway_container *container, const double x, |
154 | const double y, const double width, | 154 | const double y, const double width, |
155 | const double height, const int start, | 155 | const double height, const int start, |
156 | const int end); | 156 | const int end); |
157 | 157 | ||
158 | static void apply_vert_layout(swayc_t *container, const double x, | 158 | static void apply_vert_layout(struct sway_container *container, const double x, |
159 | const double y, const double width, | 159 | const double y, const double width, |
160 | const double height, const int start, | 160 | const double height, const int start, |
161 | const int end); | 161 | const int end); |
162 | 162 | ||
163 | void arrange_windows(swayc_t *container, double width, double height) { | 163 | void arrange_windows(struct sway_container *container, double width, double height) { |
164 | int i; | 164 | int i; |
165 | if (width == -1 || height == -1) { | 165 | if (width == -1 || height == -1) { |
166 | width = container->width; | 166 | width = container->width; |
@@ -181,7 +181,7 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
181 | case C_ROOT: | 181 | case C_ROOT: |
182 | // TODO: wlr_output_layout probably | 182 | // TODO: wlr_output_layout probably |
183 | for (i = 0; i < container->children->length; ++i) { | 183 | for (i = 0; i < container->children->length; ++i) { |
184 | swayc_t *output = container->children->items[i]; | 184 | struct sway_container *output = container->children->items[i]; |
185 | wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f", | 185 | wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f", |
186 | output->name, output->x, output->y); | 186 | output->name, output->x, output->y); |
187 | arrange_windows(output, -1, -1); | 187 | arrange_windows(output, -1, -1); |
@@ -197,13 +197,13 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
197 | } | 197 | } |
198 | // arrange all workspaces: | 198 | // arrange all workspaces: |
199 | for (i = 0; i < container->children->length; ++i) { | 199 | for (i = 0; i < container->children->length; ++i) { |
200 | swayc_t *child = container->children->items[i]; | 200 | struct sway_container *child = container->children->items[i]; |
201 | arrange_windows(child, -1, -1); | 201 | arrange_windows(child, -1, -1); |
202 | } | 202 | } |
203 | return; | 203 | return; |
204 | case C_WORKSPACE: | 204 | case C_WORKSPACE: |
205 | { | 205 | { |
206 | swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); | 206 | struct sway_container *output = sway_container_parent(container, C_OUTPUT); |
207 | struct wlr_box *area = &output->sway_output->usable_area; | 207 | struct wlr_box *area = &output->sway_output->usable_area; |
208 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", | 208 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", |
209 | area->width, area->height, area->x, area->y); | 209 | area->width, area->height, area->x, area->y); |
@@ -252,14 +252,14 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | static void apply_horiz_layout(swayc_t *container, | 255 | static void apply_horiz_layout(struct sway_container *container, |
256 | const double x, const double y, | 256 | const double x, const double y, |
257 | const double width, const double height, | 257 | const double width, const double height, |
258 | const int start, const int end) { | 258 | const int start, const int end) { |
259 | double scale = 0; | 259 | double scale = 0; |
260 | // Calculate total width | 260 | // Calculate total width |
261 | for (int i = start; i < end; ++i) { | 261 | for (int i = start; i < end; ++i) { |
262 | double *old_width = &((swayc_t *)container->children->items[i])->width; | 262 | double *old_width = &((struct sway_container *)container->children->items[i])->width; |
263 | if (*old_width <= 0) { | 263 | if (*old_width <= 0) { |
264 | if (end - start > 1) { | 264 | if (end - start > 1) { |
265 | *old_width = width / (end - start - 1); | 265 | *old_width = width / (end - start - 1); |
@@ -276,7 +276,7 @@ static void apply_horiz_layout(swayc_t *container, | |||
276 | if (scale > 0.1) { | 276 | if (scale > 0.1) { |
277 | wlr_log(L_DEBUG, "Arranging %p horizontally", container); | 277 | wlr_log(L_DEBUG, "Arranging %p horizontally", container); |
278 | for (int i = start; i < end; ++i) { | 278 | for (int i = start; i < end; ++i) { |
279 | swayc_t *child = container->children->items[i]; | 279 | struct sway_container *child = container->children->items[i]; |
280 | wlr_log(L_DEBUG, | 280 | wlr_log(L_DEBUG, |
281 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 281 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
282 | child, child->type, width, scale); | 282 | child, child->type, width, scale); |
@@ -301,7 +301,7 @@ static void apply_horiz_layout(swayc_t *container, | |||
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void apply_vert_layout(swayc_t *container, | 304 | void apply_vert_layout(struct sway_container *container, |
305 | const double x, const double y, | 305 | const double x, const double y, |
306 | const double width, const double height, const int start, | 306 | const double width, const double height, const int start, |
307 | const int end) { | 307 | const int end) { |
@@ -309,7 +309,7 @@ void apply_vert_layout(swayc_t *container, | |||
309 | double scale = 0; | 309 | double scale = 0; |
310 | // Calculate total height | 310 | // Calculate total height |
311 | for (i = start; i < end; ++i) { | 311 | for (i = start; i < end; ++i) { |
312 | double *old_height = &((swayc_t *)container->children->items[i])->height; | 312 | double *old_height = &((struct sway_container *)container->children->items[i])->height; |
313 | if (*old_height <= 0) { | 313 | if (*old_height <= 0) { |
314 | if (end - start > 1) { | 314 | if (end - start > 1) { |
315 | *old_height = height / (end - start - 1); | 315 | *old_height = height / (end - start - 1); |
@@ -326,7 +326,7 @@ void apply_vert_layout(swayc_t *container, | |||
326 | if (scale > 0.1) { | 326 | if (scale > 0.1) { |
327 | wlr_log(L_DEBUG, "Arranging %p vertically", container); | 327 | wlr_log(L_DEBUG, "Arranging %p vertically", container); |
328 | for (i = start; i < end; ++i) { | 328 | for (i = start; i < end; ++i) { |
329 | swayc_t *child = container->children->items[i]; | 329 | struct sway_container *child = container->children->items[i]; |
330 | wlr_log(L_DEBUG, | 330 | wlr_log(L_DEBUG, |
331 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 331 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
332 | child, child->type, height, scale); | 332 | child, child->type, height, scale); |
@@ -354,15 +354,15 @@ void apply_vert_layout(swayc_t *container, | |||
354 | /** | 354 | /** |
355 | * Get swayc in the direction of newly entered output. | 355 | * Get swayc in the direction of newly entered output. |
356 | */ | 356 | */ |
357 | static swayc_t *get_swayc_in_output_direction(swayc_t *output, | 357 | static struct sway_container *get_swayc_in_output_direction(struct sway_container *output, |
358 | enum movement_direction dir, struct sway_seat *seat) { | 358 | enum movement_direction dir, struct sway_seat *seat) { |
359 | if (!output) { | 359 | if (!output) { |
360 | return NULL; | 360 | return NULL; |
361 | } | 361 | } |
362 | 362 | ||
363 | swayc_t *ws = sway_seat_get_focus_inactive(seat, output); | 363 | struct sway_container *ws = sway_seat_get_focus_inactive(seat, output); |
364 | if (ws->type != C_WORKSPACE) { | 364 | if (ws->type != C_WORKSPACE) { |
365 | ws = swayc_parent_by_type(ws, C_WORKSPACE); | 365 | ws = sway_container_parent(ws, C_WORKSPACE); |
366 | } | 366 | } |
367 | 367 | ||
368 | if (ws == NULL) { | 368 | if (ws == NULL) { |
@@ -380,9 +380,9 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output, | |||
380 | return ws->children->items[0]; | 380 | return ws->children->items[0]; |
381 | case MOVE_UP: | 381 | case MOVE_UP: |
382 | case MOVE_DOWN: { | 382 | case MOVE_DOWN: { |
383 | swayc_t *focused = sway_seat_get_focus_inactive(seat, ws); | 383 | struct sway_container *focused = sway_seat_get_focus_inactive(seat, ws); |
384 | if (focused && focused->parent) { | 384 | if (focused && focused->parent) { |
385 | swayc_t *parent = focused->parent; | 385 | struct sway_container *parent = focused->parent; |
386 | if (parent->layout == L_VERT) { | 386 | if (parent->layout == L_VERT) { |
387 | if (dir == MOVE_UP) { | 387 | if (dir == MOVE_UP) { |
388 | // get child furthest down on new output | 388 | // get child furthest down on new output |
@@ -404,13 +404,13 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output, | |||
404 | return ws; | 404 | return ws; |
405 | } | 405 | } |
406 | 406 | ||
407 | static void get_layout_center_position(swayc_t *container, int *x, int *y) { | 407 | static void get_layout_center_position(struct sway_container *container, int *x, int *y) { |
408 | // FIXME view coords are inconsistently referred to in layout/output systems | 408 | // FIXME view coords are inconsistently referred to in layout/output systems |
409 | if (container->type == C_OUTPUT) { | 409 | if (container->type == C_OUTPUT) { |
410 | *x = container->x + container->width/2; | 410 | *x = container->x + container->width/2; |
411 | *y = container->y + container->height/2; | 411 | *y = container->y + container->height/2; |
412 | } else { | 412 | } else { |
413 | swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); | 413 | struct sway_container *output = sway_container_parent(container, C_OUTPUT); |
414 | if (container->type == C_WORKSPACE) { | 414 | if (container->type == C_WORKSPACE) { |
415 | // Workspace coordinates are actually wrong/arbitrary, but should | 415 | // Workspace coordinates are actually wrong/arbitrary, but should |
416 | // be same as output. | 416 | // be same as output. |
@@ -444,12 +444,12 @@ static bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out | |||
444 | return true; | 444 | return true; |
445 | } | 445 | } |
446 | 446 | ||
447 | static swayc_t *sway_output_from_wlr(struct wlr_output *output) { | 447 | static struct sway_container *sway_output_from_wlr(struct wlr_output *output) { |
448 | if (output == NULL) { | 448 | if (output == NULL) { |
449 | return NULL; | 449 | return NULL; |
450 | } | 450 | } |
451 | for (int i = 0; i < root_container.children->length; ++i) { | 451 | for (int i = 0; i < root_container.children->length; ++i) { |
452 | swayc_t *o = root_container.children->items[i]; | 452 | struct sway_container *o = root_container.children->items[i]; |
453 | if (o->type == C_OUTPUT && o->sway_output->wlr_output == output) { | 453 | if (o->type == C_OUTPUT && o->sway_output->wlr_output == output) { |
454 | return o; | 454 | return o; |
455 | } | 455 | } |
@@ -457,13 +457,13 @@ static swayc_t *sway_output_from_wlr(struct wlr_output *output) { | |||
457 | return NULL; | 457 | return NULL; |
458 | } | 458 | } |
459 | 459 | ||
460 | static swayc_t *get_swayc_in_direction_under(swayc_t *container, | 460 | static struct sway_container *get_swayc_in_direction_under(struct sway_container *container, |
461 | enum movement_direction dir, struct sway_seat *seat, swayc_t *limit) { | 461 | enum movement_direction dir, struct sway_seat *seat, struct sway_container *limit) { |
462 | if (dir == MOVE_CHILD) { | 462 | if (dir == MOVE_CHILD) { |
463 | return sway_seat_get_focus_inactive(seat, container); | 463 | return sway_seat_get_focus_inactive(seat, container); |
464 | } | 464 | } |
465 | 465 | ||
466 | swayc_t *parent = container->parent; | 466 | struct sway_container *parent = container->parent; |
467 | if (dir == MOVE_PARENT) { | 467 | if (dir == MOVE_PARENT) { |
468 | if (parent->type == C_OUTPUT) { | 468 | if (parent->type == C_OUTPUT) { |
469 | return NULL; | 469 | return NULL; |
@@ -496,9 +496,9 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
496 | /* | 496 | /* |
497 | if (container->type == C_VIEW && swayc_is_fullscreen(container)) { | 497 | if (container->type == C_VIEW && swayc_is_fullscreen(container)) { |
498 | wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output"); | 498 | wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output"); |
499 | container = swayc_parent_by_type(container, C_OUTPUT); | 499 | container = sway_container_parent(container, C_OUTPUT); |
500 | get_layout_center_position(container, &abs_pos); | 500 | get_layout_center_position(container, &abs_pos); |
501 | swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true); | 501 | struct sway_container *output = swayc_adjacent_output(container, dir, &abs_pos, true); |
502 | return get_swayc_in_output_direction(output, dir); | 502 | return get_swayc_in_output_direction(output, dir); |
503 | } | 503 | } |
504 | if (container->type == C_WORKSPACE && container->fullscreen) { | 504 | if (container->type == C_WORKSPACE && container->fullscreen) { |
@@ -507,7 +507,7 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
507 | } | 507 | } |
508 | */ | 508 | */ |
509 | 509 | ||
510 | swayc_t *wrap_candidate = NULL; | 510 | struct sway_container *wrap_candidate = NULL; |
511 | while (true) { | 511 | while (true) { |
512 | // Test if we can even make a difference here | 512 | // Test if we can even make a difference here |
513 | bool can_move = false; | 513 | bool can_move = false; |
@@ -525,12 +525,12 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
525 | struct wlr_output *wlr_adjacent = | 525 | struct wlr_output *wlr_adjacent = |
526 | wlr_output_layout_adjacent_output(layout, wlr_dir, | 526 | wlr_output_layout_adjacent_output(layout, wlr_dir, |
527 | container->sway_output->wlr_output, lx, ly); | 527 | container->sway_output->wlr_output, lx, ly); |
528 | swayc_t *adjacent = sway_output_from_wlr(wlr_adjacent); | 528 | struct sway_container *adjacent = sway_output_from_wlr(wlr_adjacent); |
529 | 529 | ||
530 | if (!adjacent || adjacent == container) { | 530 | if (!adjacent || adjacent == container) { |
531 | return wrap_candidate; | 531 | return wrap_candidate; |
532 | } | 532 | } |
533 | swayc_t *next = get_swayc_in_output_direction(adjacent, dir, seat); | 533 | struct sway_container *next = get_swayc_in_output_direction(adjacent, dir, seat); |
534 | if (next == NULL) { | 534 | if (next == NULL) { |
535 | return NULL; | 535 | return NULL; |
536 | } | 536 | } |
@@ -587,7 +587,7 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container, | |||
587 | } | 587 | } |
588 | } | 588 | } |
589 | 589 | ||
590 | swayc_t *get_swayc_in_direction(swayc_t *container, struct sway_seat *seat, | 590 | struct sway_container *get_swayc_in_direction(struct sway_container *container, struct sway_seat *seat, |
591 | enum movement_direction dir) { | 591 | enum movement_direction dir) { |
592 | return get_swayc_in_direction_under(container, dir, seat, NULL); | 592 | return get_swayc_in_direction_under(container, dir, seat, NULL); |
593 | } | 593 | } |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 3da3fde6..32e82845 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -17,7 +17,7 @@ struct workspace_by_number_data { | |||
17 | const char *name; | 17 | const char *name; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | void next_name_map(swayc_t *ws, void *data) { | 20 | void next_name_map(struct sway_container *ws, void *data) { |
21 | int *count = data; | 21 | int *count = data; |
22 | ++count; | 22 | ++count; |
23 | } | 23 | } |
@@ -37,7 +37,7 @@ char *workspace_next_name(const char *output_name) { | |||
37 | return name; | 37 | return name; |
38 | } | 38 | } |
39 | 39 | ||
40 | static bool _workspace_by_number(swayc_t *view, void *data) { | 40 | static bool _workspace_by_number(struct sway_container *view, void *data) { |
41 | if (view->type != C_WORKSPACE) { | 41 | if (view->type != C_WORKSPACE) { |
42 | return false; | 42 | return false; |
43 | } | 43 | } |
@@ -46,27 +46,27 @@ static bool _workspace_by_number(swayc_t *view, void *data) { | |||
46 | return a == wbnd->len && strncmp(view->name, wbnd->name, a) == 0; | 46 | return a == wbnd->len && strncmp(view->name, wbnd->name, a) == 0; |
47 | } | 47 | } |
48 | 48 | ||
49 | swayc_t *workspace_by_number(const char* name) { | 49 | struct sway_container *workspace_by_number(const char* name) { |
50 | struct workspace_by_number_data wbnd = {0, "1234567890", name}; | 50 | struct workspace_by_number_data wbnd = {0, "1234567890", name}; |
51 | wbnd.len = strspn(name, wbnd.cset); | 51 | wbnd.len = strspn(name, wbnd.cset); |
52 | if (wbnd.len <= 0) { | 52 | if (wbnd.len <= 0) { |
53 | return NULL; | 53 | return NULL; |
54 | } | 54 | } |
55 | return swayc_by_test(&root_container, _workspace_by_number, (void *) &wbnd); | 55 | return sway_container_find(&root_container, _workspace_by_number, (void *) &wbnd); |
56 | } | 56 | } |
57 | 57 | ||
58 | static bool _workspace_by_name(swayc_t *view, void *data) { | 58 | static bool _workspace_by_name(struct sway_container *view, void *data) { |
59 | return (view->type == C_WORKSPACE) && | 59 | return (view->type == C_WORKSPACE) && |
60 | (strcasecmp(view->name, (char *) data) == 0); | 60 | (strcasecmp(view->name, (char *) data) == 0); |
61 | } | 61 | } |
62 | 62 | ||
63 | swayc_t *workspace_by_name(const char *name) { | 63 | struct sway_container *workspace_by_name(const char *name) { |
64 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 64 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
65 | swayc_t *current_workspace = NULL, *current_output = NULL; | 65 | struct sway_container *current_workspace = NULL, *current_output = NULL; |
66 | swayc_t *focus = sway_seat_get_focus(seat); | 66 | struct sway_container *focus = sway_seat_get_focus(seat); |
67 | if (focus) { | 67 | if (focus) { |
68 | current_workspace = swayc_parent_by_type(focus, C_WORKSPACE); | 68 | current_workspace = sway_container_parent(focus, C_WORKSPACE); |
69 | current_output = swayc_parent_by_type(focus, C_OUTPUT); | 69 | current_output = sway_container_parent(focus, C_OUTPUT); |
70 | } | 70 | } |
71 | if (strcmp(name, "prev") == 0) { | 71 | if (strcmp(name, "prev") == 0) { |
72 | return workspace_prev(current_workspace); | 72 | return workspace_prev(current_workspace); |
@@ -79,12 +79,12 @@ swayc_t *workspace_by_name(const char *name) { | |||
79 | } else if (strcmp(name, "current") == 0) { | 79 | } else if (strcmp(name, "current") == 0) { |
80 | return current_workspace; | 80 | return current_workspace; |
81 | } else { | 81 | } else { |
82 | return swayc_by_test(&root_container, _workspace_by_name, (void *) name); | 82 | return sway_container_find(&root_container, _workspace_by_name, (void *) name); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | swayc_t *workspace_create(const char *name) { | 86 | struct sway_container *workspace_create(const char *name) { |
87 | swayc_t *parent; | 87 | struct sway_container *parent; |
88 | // Search for workspace<->output pair | 88 | // Search for workspace<->output pair |
89 | int i, e = config->workspace_outputs->length; | 89 | int i, e = config->workspace_outputs->length; |
90 | for (i = 0; i < e; ++i) { | 90 | for (i = 0; i < e; ++i) { |
@@ -95,7 +95,7 @@ swayc_t *workspace_create(const char *name) { | |||
95 | for (i = 0; i < e; ++i) { | 95 | for (i = 0; i < e; ++i) { |
96 | parent = root_container.children->items[i]; | 96 | parent = root_container.children->items[i]; |
97 | if (strcmp(parent->name, wso->output) == 0) { | 97 | if (strcmp(parent->name, wso->output) == 0) { |
98 | return new_workspace(parent, name); | 98 | return sway_container_workspace_create(parent, name); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | break; | 101 | break; |
@@ -103,10 +103,10 @@ swayc_t *workspace_create(const char *name) { | |||
103 | } | 103 | } |
104 | // Otherwise create a new one | 104 | // Otherwise create a new one |
105 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 105 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
106 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 106 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
107 | parent = focus; | 107 | parent = focus; |
108 | parent = swayc_parent_by_type(parent, C_OUTPUT); | 108 | parent = sway_container_parent(parent, C_OUTPUT); |
109 | return new_workspace(parent, name); | 109 | return sway_container_workspace_create(parent, name); |
110 | } | 110 | } |
111 | 111 | ||
112 | /** | 112 | /** |
@@ -114,17 +114,17 @@ swayc_t *workspace_create(const char *name) { | |||
114 | * the end and beginning. If next is false, the previous workspace is returned, | 114 | * the end and beginning. If next is false, the previous workspace is returned, |
115 | * otherwise the next one is returned. | 115 | * otherwise the next one is returned. |
116 | */ | 116 | */ |
117 | swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) { | 117 | struct sway_container *workspace_output_prev_next_impl(struct sway_container *output, bool next) { |
118 | if (!sway_assert(output->type == C_OUTPUT, | 118 | if (!sway_assert(output->type == C_OUTPUT, |
119 | "Argument must be an output, is %d", output->type)) { | 119 | "Argument must be an output, is %d", output->type)) { |
120 | return NULL; | 120 | return NULL; |
121 | } | 121 | } |
122 | 122 | ||
123 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 123 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
124 | swayc_t *focus = sway_seat_get_focus_inactive(seat, output); | 124 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, output); |
125 | swayc_t *workspace = (focus->type == C_WORKSPACE ? | 125 | struct sway_container *workspace = (focus->type == C_WORKSPACE ? |
126 | focus : | 126 | focus : |
127 | swayc_parent_by_type(focus, C_WORKSPACE)); | 127 | sway_container_parent(focus, C_WORKSPACE)); |
128 | 128 | ||
129 | int i; | 129 | int i; |
130 | for (i = 0; i < output->children->length; i++) { | 130 | for (i = 0; i < output->children->length; i++) { |
@@ -144,13 +144,13 @@ swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) { | |||
144 | * next is false, the previous workspace is returned, otherwise the next one is | 144 | * next is false, the previous workspace is returned, otherwise the next one is |
145 | * returned. | 145 | * returned. |
146 | */ | 146 | */ |
147 | swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) { | 147 | struct sway_container *workspace_prev_next_impl(struct sway_container *workspace, bool next) { |
148 | if (!sway_assert(workspace->type == C_WORKSPACE, | 148 | if (!sway_assert(workspace->type == C_WORKSPACE, |
149 | "Argument must be a workspace, is %d", workspace->type)) { | 149 | "Argument must be a workspace, is %d", workspace->type)) { |
150 | return NULL; | 150 | return NULL; |
151 | } | 151 | } |
152 | 152 | ||
153 | swayc_t *current_output = workspace->parent; | 153 | struct sway_container *current_output = workspace->parent; |
154 | int offset = next ? 1 : -1; | 154 | int offset = next ? 1 : -1; |
155 | int start = next ? 0 : 1; | 155 | int start = next ? 0 : 1; |
156 | int end; | 156 | int end; |
@@ -170,7 +170,7 @@ swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) { | |||
170 | int num_outputs = root_container.children->length; | 170 | int num_outputs = root_container.children->length; |
171 | for (i = 0; i < num_outputs; i++) { | 171 | for (i = 0; i < num_outputs; i++) { |
172 | if (root_container.children->items[i] == current_output) { | 172 | if (root_container.children->items[i] == current_output) { |
173 | swayc_t *next_output = root_container.children->items[ | 173 | struct sway_container *next_output = root_container.children->items[ |
174 | wrap(i + offset, num_outputs)]; | 174 | wrap(i + offset, num_outputs)]; |
175 | return workspace_output_prev_next_impl(next_output, next); | 175 | return workspace_output_prev_next_impl(next_output, next); |
176 | } | 176 | } |
@@ -180,40 +180,40 @@ swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) { | |||
180 | return NULL; | 180 | return NULL; |
181 | } | 181 | } |
182 | 182 | ||
183 | swayc_t *workspace_output_next(swayc_t *current) { | 183 | struct sway_container *workspace_output_next(struct sway_container *current) { |
184 | return workspace_output_prev_next_impl(current, true); | 184 | return workspace_output_prev_next_impl(current, true); |
185 | } | 185 | } |
186 | 186 | ||
187 | swayc_t *workspace_next(swayc_t *current) { | 187 | struct sway_container *workspace_next(struct sway_container *current) { |
188 | return workspace_prev_next_impl(current, true); | 188 | return workspace_prev_next_impl(current, true); |
189 | } | 189 | } |
190 | 190 | ||
191 | swayc_t *workspace_output_prev(swayc_t *current) { | 191 | struct sway_container *workspace_output_prev(struct sway_container *current) { |
192 | return workspace_output_prev_next_impl(current, false); | 192 | return workspace_output_prev_next_impl(current, false); |
193 | } | 193 | } |
194 | 194 | ||
195 | swayc_t *workspace_prev(swayc_t *current) { | 195 | struct sway_container *workspace_prev(struct sway_container *current) { |
196 | return workspace_prev_next_impl(current, false); | 196 | return workspace_prev_next_impl(current, false); |
197 | } | 197 | } |
198 | 198 | ||
199 | bool workspace_switch(swayc_t *workspace) { | 199 | bool workspace_switch(struct sway_container *workspace) { |
200 | if (!workspace) { | 200 | if (!workspace) { |
201 | return false; | 201 | return false; |
202 | } | 202 | } |
203 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 203 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
204 | swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); | 204 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); |
205 | if (!seat || !focus) { | 205 | if (!seat || !focus) { |
206 | return false; | 206 | return false; |
207 | } | 207 | } |
208 | swayc_t *active_ws = focus; | 208 | struct sway_container *active_ws = focus; |
209 | if (active_ws->type != C_WORKSPACE) { | 209 | if (active_ws->type != C_WORKSPACE) { |
210 | swayc_parent_by_type(focus, C_WORKSPACE); | 210 | sway_container_parent(focus, C_WORKSPACE); |
211 | } | 211 | } |
212 | 212 | ||
213 | if (config->auto_back_and_forth | 213 | if (config->auto_back_and_forth |
214 | && active_ws == workspace | 214 | && active_ws == workspace |
215 | && prev_workspace_name) { | 215 | && prev_workspace_name) { |
216 | swayc_t *new_ws = workspace_by_name(prev_workspace_name); | 216 | struct sway_container *new_ws = workspace_by_name(prev_workspace_name); |
217 | workspace = new_ws ? new_ws : workspace_create(prev_workspace_name); | 217 | workspace = new_ws ? new_ws : workspace_create(prev_workspace_name); |
218 | } | 218 | } |
219 | 219 | ||
@@ -231,12 +231,12 @@ bool workspace_switch(swayc_t *workspace) { | |||
231 | // TODO: Deal with sticky containers | 231 | // TODO: Deal with sticky containers |
232 | 232 | ||
233 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); | 233 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); |
234 | swayc_t *next = sway_seat_get_focus_inactive(seat, workspace); | 234 | struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace); |
235 | if (next == NULL) { | 235 | if (next == NULL) { |
236 | next = workspace; | 236 | next = workspace; |
237 | } | 237 | } |
238 | sway_seat_set_focus(seat, next); | 238 | sway_seat_set_focus(seat, next); |
239 | swayc_t *output = swayc_parent_by_type(workspace, C_OUTPUT); | 239 | struct sway_container *output = sway_container_parent(workspace, C_OUTPUT); |
240 | arrange_windows(output, -1, -1); | 240 | arrange_windows(output, -1, -1); |
241 | return true; | 241 | return true; |
242 | } | 242 | } |