diff options
-rw-r--r-- | sway/tree/container.c | 40 | ||||
-rw-r--r-- | sway/tree/layout.c | 73 | ||||
-rw-r--r-- | sway/tree/workspace.c | 30 |
3 files changed, 94 insertions, 49 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index b343d236..1f537025 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -86,7 +86,8 @@ static void container_destroy(struct sway_container *cont) { | |||
86 | free(cont); | 86 | free(cont); |
87 | } | 87 | } |
88 | 88 | ||
89 | struct sway_container *container_output_create(struct sway_output *sway_output) { | 89 | struct sway_container *container_output_create( |
90 | struct sway_output *sway_output) { | ||
90 | struct wlr_box size; | 91 | struct wlr_box size; |
91 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, | 92 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, |
92 | &size.height); | 93 | &size.height); |
@@ -150,8 +151,10 @@ struct sway_container *container_output_create(struct sway_output *sway_output) | |||
150 | return output; | 151 | return output; |
151 | } | 152 | } |
152 | 153 | ||
153 | struct sway_container *container_workspace_create(struct sway_container *output, const char *name) { | 154 | struct sway_container *container_workspace_create(struct sway_container |
154 | if (!sway_assert(output, "container_workspace_create called with null output")) { | 155 | *output, const char *name) { |
156 | if (!sway_assert(output, | ||
157 | "container_workspace_create called with null output")) { | ||
155 | return NULL; | 158 | return NULL; |
156 | } | 159 | } |
157 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); | 160 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); |
@@ -172,8 +175,10 @@ struct sway_container *container_workspace_create(struct sway_container *output, | |||
172 | return workspace; | 175 | return workspace; |
173 | } | 176 | } |
174 | 177 | ||
175 | struct sway_container *container_view_create(struct sway_container *sibling, struct sway_view *sway_view) { | 178 | struct sway_container *container_view_create(struct sway_container *sibling, |
176 | if (!sway_assert(sibling, "container_view_create called with NULL sibling/parent")) { | 179 | struct sway_view *sway_view) { |
180 | if (!sway_assert(sibling, | ||
181 | "container_view_create called with NULL sibling/parent")) { | ||
177 | return NULL; | 182 | return NULL; |
178 | } | 183 | } |
179 | const char *title = view_get_title(sway_view); | 184 | const char *title = view_get_title(sway_view); |
@@ -198,7 +203,8 @@ struct sway_container *container_view_create(struct sway_container *sibling, str | |||
198 | } | 203 | } |
199 | 204 | ||
200 | struct sway_container *container_output_destroy(struct sway_container *output) { | 205 | struct sway_container *container_output_destroy(struct sway_container *output) { |
201 | if (!sway_assert(output, "null output passed to container_output_destroy")) { | 206 | if (!sway_assert(output, |
207 | "null output passed to container_output_destroy")) { | ||
202 | return NULL; | 208 | return NULL; |
203 | } | 209 | } |
204 | 210 | ||
@@ -215,7 +221,8 @@ struct sway_container *container_output_destroy(struct sway_container *output) { | |||
215 | container_add_child(root_container.children->items[p], child); | 221 | container_add_child(root_container.children->items[p], child); |
216 | } | 222 | } |
217 | container_sort_workspaces(root_container.children->items[p]); | 223 | container_sort_workspaces(root_container.children->items[p]); |
218 | container_arrange_windows(root_container.children->items[p], -1, -1); | 224 | container_arrange_windows(root_container.children->items[p], |
225 | -1, -1); | ||
219 | } | 226 | } |
220 | } | 227 | } |
221 | 228 | ||
@@ -246,7 +253,8 @@ struct sway_container *container_view_destroy(struct sway_container *view) { | |||
246 | return parent; | 253 | return parent; |
247 | } | 254 | } |
248 | 255 | ||
249 | struct sway_container *container_set_layout(struct sway_container *container, enum sway_container_layout layout) { | 256 | struct sway_container *container_set_layout(struct sway_container *container, |
257 | enum sway_container_layout layout) { | ||
250 | if (container->type == C_WORKSPACE) { | 258 | if (container->type == C_WORKSPACE) { |
251 | container->workspace_layout = layout; | 259 | container->workspace_layout = layout; |
252 | if (layout == L_HORIZ || layout == L_VERT) { | 260 | if (layout == L_HORIZ || layout == L_VERT) { |
@@ -258,7 +266,8 @@ struct sway_container *container_set_layout(struct sway_container *container, en | |||
258 | return container; | 266 | return container; |
259 | } | 267 | } |
260 | 268 | ||
261 | void container_descendents(struct sway_container *root, enum sway_container_type type, | 269 | void container_descendents(struct sway_container *root, |
270 | enum sway_container_type type, | ||
262 | void (*func)(struct sway_container *item, void *data), void *data) { | 271 | void (*func)(struct sway_container *item, void *data), void *data) { |
263 | for (int i = 0; i < root->children->length; ++i) { | 272 | for (int i = 0; i < root->children->length; ++i) { |
264 | struct sway_container *item = root->children->items[i]; | 273 | struct sway_container *item = root->children->items[i]; |
@@ -291,7 +300,8 @@ struct sway_container *container_find(struct sway_container *container, | |||
291 | return NULL; | 300 | return NULL; |
292 | } | 301 | } |
293 | 302 | ||
294 | struct sway_container *container_parent(struct sway_container *container, enum sway_container_type type) { | 303 | struct sway_container *container_parent(struct sway_container *container, |
304 | enum sway_container_type type) { | ||
295 | if (!sway_assert(container, "container is NULL")) { | 305 | if (!sway_assert(container, "container is NULL")) { |
296 | return NULL; | 306 | return NULL; |
297 | } | 307 | } |
@@ -304,7 +314,8 @@ struct sway_container *container_parent(struct sway_container *container, enum s | |||
304 | return container; | 314 | return container; |
305 | } | 315 | } |
306 | 316 | ||
307 | void sway_container_for_each(struct sway_container *container, void (*f)(struct sway_container *view, void *data), void *data) { | 317 | void sway_container_for_each(struct sway_container *container, |
318 | void (*f)(struct sway_container *view, void *data), void *data) { | ||
308 | if (container) { | 319 | if (container) { |
309 | int i; | 320 | int i; |
310 | if (container->children) { | 321 | if (container->children) { |
@@ -326,7 +337,8 @@ void sway_container_for_each(struct sway_container *container, void (*f)(struct | |||
326 | } | 337 | } |
327 | } | 338 | } |
328 | 339 | ||
329 | struct sway_container *sway_container_at(struct sway_container *parent, double lx, double ly, | 340 | struct sway_container *sway_container_at(struct sway_container *parent, |
341 | double lx, double ly, | ||
330 | struct wlr_surface **surface, double *sx, double *sy) { | 342 | struct wlr_surface **surface, double *sx, double *sy) { |
331 | list_t *queue = get_bfs_queue(); | 343 | list_t *queue = get_bfs_queue(); |
332 | if (!queue) { | 344 | if (!queue) { |
@@ -411,8 +423,8 @@ struct sway_container *sway_container_at(struct sway_container *parent, double l | |||
411 | return NULL; | 423 | return NULL; |
412 | } | 424 | } |
413 | 425 | ||
414 | void sway_container_for_each_bfs(struct sway_container *con, void (*f)(struct sway_container *con, void *data), | 426 | void sway_container_for_each_bfs(struct sway_container *con, |
415 | void *data) { | 427 | void (*f)(struct sway_container *con, void *data), void *data) { |
416 | list_t *queue = get_bfs_queue(); | 428 | list_t *queue = get_bfs_queue(); |
417 | if (!queue) { | 429 | if (!queue) { |
418 | return; | 430 | return; |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index fb34573f..53ff9ffa 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -16,14 +16,16 @@ | |||
16 | 16 | ||
17 | struct sway_container 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, |
20 | void *data) { | ||
20 | struct wlr_box *layout_box = wlr_output_layout_get_box( | 21 | struct wlr_box *layout_box = wlr_output_layout_get_box( |
21 | root_container.sway_root->output_layout, NULL); | 22 | root_container.sway_root->output_layout, NULL); |
22 | root_container.width = layout_box->width; | 23 | root_container.width = layout_box->width; |
23 | root_container.height = layout_box->height; | 24 | root_container.height = layout_box->height; |
24 | 25 | ||
25 | for (int i = 0 ; i < root_container.children->length; ++i) { | 26 | for (int i = 0 ; i < root_container.children->length; ++i) { |
26 | struct sway_container *output_container = root_container.children->items[i]; | 27 | struct sway_container *output_container = |
28 | root_container.children->items[i]; | ||
27 | if (output_container->type != C_OUTPUT) { | 29 | if (output_container->type != C_OUTPUT) { |
28 | continue; | 30 | continue; |
29 | } | 31 | } |
@@ -79,7 +81,8 @@ static int index_child(const struct sway_container *child) { | |||
79 | return i; | 81 | return i; |
80 | } | 82 | } |
81 | 83 | ||
82 | struct sway_container *container_add_sibling(struct sway_container *fixed, struct sway_container *active) { | 84 | struct sway_container *container_add_sibling(struct sway_container *fixed, |
85 | struct sway_container *active) { | ||
83 | // TODO handle floating | 86 | // TODO handle floating |
84 | struct sway_container *parent = fixed->parent; | 87 | struct sway_container *parent = fixed->parent; |
85 | int i = index_child(fixed); | 88 | int i = index_child(fixed); |
@@ -88,7 +91,8 @@ struct sway_container *container_add_sibling(struct sway_container *fixed, struc | |||
88 | return active->parent; | 91 | return active->parent; |
89 | } | 92 | } |
90 | 93 | ||
91 | void container_add_child(struct sway_container *parent, struct sway_container *child) { | 94 | void container_add_child(struct sway_container *parent, |
95 | struct sway_container *child) { | ||
92 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", | 96 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", |
93 | child, child->type, child->width, child->height, | 97 | child, child->type, child->width, child->height, |
94 | parent, parent->type, parent->width, parent->height); | 98 | parent, parent->type, parent->width, parent->height); |
@@ -96,7 +100,9 @@ void container_add_child(struct sway_container *parent, struct sway_container *c | |||
96 | child->parent = parent; | 100 | child->parent = parent; |
97 | // set focus for this container | 101 | // set focus for this container |
98 | /* TODO WLR | 102 | /* TODO WLR |
99 | if (parent->type == C_WORKSPACE && child->type == C_VIEW && (parent->workspace_layout == L_TABBED || parent->workspace_layout == L_STACKED)) { | 103 | if (parent->type == C_WORKSPACE && child->type == C_VIEW && |
104 | (parent->workspace_layout == L_TABBED || parent->workspace_layout == | ||
105 | L_STACKED)) { | ||
100 | child = new_container(child, parent->workspace_layout); | 106 | child = new_container(child, parent->workspace_layout); |
101 | } | 107 | } |
102 | */ | 108 | */ |
@@ -115,7 +121,8 @@ struct sway_container *container_remove_child(struct sway_container *child) { | |||
115 | return parent; | 121 | return parent; |
116 | } | 122 | } |
117 | 123 | ||
118 | enum sway_container_layout container_get_default_layout(struct sway_container *output) { | 124 | enum sway_container_layout container_get_default_layout( |
125 | struct sway_container *output) { | ||
119 | /* TODO WLR | 126 | /* TODO WLR |
120 | if (config->default_layout != L_NONE) { | 127 | if (config->default_layout != L_NONE) { |
121 | //return config->default_layout; | 128 | //return config->default_layout; |
@@ -160,7 +167,8 @@ static void apply_vert_layout(struct sway_container *container, const double x, | |||
160 | const double height, const int start, | 167 | const double height, const int start, |
161 | const int end); | 168 | const int end); |
162 | 169 | ||
163 | void container_arrange_windows(struct sway_container *container, double width, double height) { | 170 | void container_arrange_windows(struct sway_container *container, |
171 | double width, double height) { | ||
164 | int i; | 172 | int i; |
165 | if (width == -1 || height == -1) { | 173 | if (width == -1 || height == -1) { |
166 | width = container->width; | 174 | width = container->width; |
@@ -203,7 +211,8 @@ void container_arrange_windows(struct sway_container *container, double width, d | |||
203 | return; | 211 | return; |
204 | case C_WORKSPACE: | 212 | case C_WORKSPACE: |
205 | { | 213 | { |
206 | struct sway_container *output = container_parent(container, C_OUTPUT); | 214 | struct sway_container *output = |
215 | container_parent(container, C_OUTPUT); | ||
207 | struct wlr_box *area = &output->sway_output->usable_area; | 216 | struct wlr_box *area = &output->sway_output->usable_area; |
208 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", | 217 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", |
209 | area->width, area->height, area->x, area->y); | 218 | area->width, area->height, area->x, area->y); |
@@ -259,7 +268,8 @@ static void apply_horiz_layout(struct sway_container *container, | |||
259 | double scale = 0; | 268 | double scale = 0; |
260 | // Calculate total width | 269 | // Calculate total width |
261 | for (int i = start; i < end; ++i) { | 270 | for (int i = start; i < end; ++i) { |
262 | double *old_width = &((struct sway_container *)container->children->items[i])->width; | 271 | double *old_width = |
272 | &((struct sway_container *)container->children->items[i])->width; | ||
263 | if (*old_width <= 0) { | 273 | if (*old_width <= 0) { |
264 | if (end - start > 1) { | 274 | if (end - start > 1) { |
265 | *old_width = width / (end - start - 1); | 275 | *old_width = width / (end - start - 1); |
@@ -309,7 +319,8 @@ void apply_vert_layout(struct sway_container *container, | |||
309 | double scale = 0; | 319 | double scale = 0; |
310 | // Calculate total height | 320 | // Calculate total height |
311 | for (i = start; i < end; ++i) { | 321 | for (i = start; i < end; ++i) { |
312 | double *old_height = &((struct sway_container *)container->children->items[i])->height; | 322 | double *old_height = |
323 | &((struct sway_container *)container->children->items[i])->height; | ||
313 | if (*old_height <= 0) { | 324 | if (*old_height <= 0) { |
314 | if (end - start > 1) { | 325 | if (end - start > 1) { |
315 | *old_height = height / (end - start - 1); | 326 | *old_height = height / (end - start - 1); |
@@ -354,8 +365,9 @@ void apply_vert_layout(struct sway_container *container, | |||
354 | /** | 365 | /** |
355 | * Get swayc in the direction of newly entered output. | 366 | * Get swayc in the direction of newly entered output. |
356 | */ | 367 | */ |
357 | static struct sway_container *get_swayc_in_output_direction(struct sway_container *output, | 368 | static struct sway_container *get_swayc_in_output_direction( |
358 | enum movement_direction dir, struct sway_seat *seat) { | 369 | struct sway_container *output, enum movement_direction dir, |
370 | struct sway_seat *seat) { | ||
359 | if (!output) { | 371 | if (!output) { |
360 | return NULL; | 372 | return NULL; |
361 | } | 373 | } |
@@ -380,13 +392,15 @@ static struct sway_container *get_swayc_in_output_direction(struct sway_containe | |||
380 | return ws->children->items[0]; | 392 | return ws->children->items[0]; |
381 | case MOVE_UP: | 393 | case MOVE_UP: |
382 | case MOVE_DOWN: { | 394 | case MOVE_DOWN: { |
383 | struct sway_container *focused = sway_seat_get_focus_inactive(seat, ws); | 395 | struct sway_container *focused = |
396 | sway_seat_get_focus_inactive(seat, ws); | ||
384 | if (focused && focused->parent) { | 397 | if (focused && focused->parent) { |
385 | struct sway_container *parent = focused->parent; | 398 | struct sway_container *parent = focused->parent; |
386 | if (parent->layout == L_VERT) { | 399 | if (parent->layout == L_VERT) { |
387 | if (dir == MOVE_UP) { | 400 | if (dir == MOVE_UP) { |
388 | // get child furthest down on new output | 401 | // get child furthest down on new output |
389 | return parent->children->items[parent->children->length-1]; | 402 | int idx = parent->children->length - 1; |
403 | return parent->children->items[idx]; | ||
390 | } else if (dir == MOVE_DOWN) { | 404 | } else if (dir == MOVE_DOWN) { |
391 | // get child furthest up on new output | 405 | // get child furthest up on new output |
392 | return parent->children->items[0]; | 406 | return parent->children->items[0]; |
@@ -404,7 +418,8 @@ static struct sway_container *get_swayc_in_output_direction(struct sway_containe | |||
404 | return ws; | 418 | return ws; |
405 | } | 419 | } |
406 | 420 | ||
407 | static void get_layout_center_position(struct sway_container *container, int *x, int *y) { | 421 | static void get_layout_center_position(struct sway_container *container, |
422 | int *x, int *y) { | ||
408 | // FIXME view coords are inconsistently referred to in layout/output systems | 423 | // FIXME view coords are inconsistently referred to in layout/output systems |
409 | if (container->type == C_OUTPUT) { | 424 | if (container->type == C_OUTPUT) { |
410 | *x = container->x + container->width/2; | 425 | *x = container->x + container->width/2; |
@@ -423,7 +438,8 @@ static void get_layout_center_position(struct sway_container *container, int *x, | |||
423 | } | 438 | } |
424 | } | 439 | } |
425 | 440 | ||
426 | static bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out) { | 441 | static bool sway_dir_to_wlr(enum movement_direction dir, |
442 | enum wlr_direction *out) { | ||
427 | switch (dir) { | 443 | switch (dir) { |
428 | case MOVE_UP: | 444 | case MOVE_UP: |
429 | *out = WLR_DIRECTION_UP; | 445 | *out = WLR_DIRECTION_UP; |
@@ -457,8 +473,9 @@ static struct sway_container *sway_output_from_wlr(struct wlr_output *output) { | |||
457 | return NULL; | 473 | return NULL; |
458 | } | 474 | } |
459 | 475 | ||
460 | static struct sway_container *get_swayc_in_direction_under(struct sway_container *container, | 476 | static struct sway_container *get_swayc_in_direction_under( |
461 | enum movement_direction dir, struct sway_seat *seat, struct sway_container *limit) { | 477 | struct sway_container *container, enum movement_direction dir, |
478 | struct sway_seat *seat, struct sway_container *limit) { | ||
462 | if (dir == MOVE_CHILD) { | 479 | if (dir == MOVE_CHILD) { |
463 | return sway_seat_get_focus_inactive(seat, container); | 480 | return sway_seat_get_focus_inactive(seat, container); |
464 | } | 481 | } |
@@ -498,7 +515,8 @@ static struct sway_container *get_swayc_in_direction_under(struct sway_container | |||
498 | wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output"); | 515 | wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output"); |
499 | container = container_parent(container, C_OUTPUT); | 516 | container = container_parent(container, C_OUTPUT); |
500 | get_layout_center_position(container, &abs_pos); | 517 | get_layout_center_position(container, &abs_pos); |
501 | struct sway_container *output = swayc_adjacent_output(container, dir, &abs_pos, true); | 518 | struct sway_container *output = |
519 | swayc_adjacent_output(container, dir, &abs_pos, true); | ||
502 | return get_swayc_in_output_direction(output, dir); | 520 | return get_swayc_in_output_direction(output, dir); |
503 | } | 521 | } |
504 | if (container->type == C_WORKSPACE && container->fullscreen) { | 522 | if (container->type == C_WORKSPACE && container->fullscreen) { |
@@ -521,16 +539,19 @@ static struct sway_container *get_swayc_in_direction_under(struct sway_container | |||
521 | } | 539 | } |
522 | int lx, ly; | 540 | int lx, ly; |
523 | get_layout_center_position(container, &lx, &ly); | 541 | get_layout_center_position(container, &lx, &ly); |
524 | struct wlr_output_layout *layout = root_container.sway_root->output_layout; | 542 | struct wlr_output_layout *layout = |
543 | root_container.sway_root->output_layout; | ||
525 | struct wlr_output *wlr_adjacent = | 544 | struct wlr_output *wlr_adjacent = |
526 | wlr_output_layout_adjacent_output(layout, wlr_dir, | 545 | wlr_output_layout_adjacent_output(layout, wlr_dir, |
527 | container->sway_output->wlr_output, lx, ly); | 546 | container->sway_output->wlr_output, lx, ly); |
528 | struct sway_container *adjacent = sway_output_from_wlr(wlr_adjacent); | 547 | struct sway_container *adjacent = |
548 | sway_output_from_wlr(wlr_adjacent); | ||
529 | 549 | ||
530 | if (!adjacent || adjacent == container) { | 550 | if (!adjacent || adjacent == container) { |
531 | return wrap_candidate; | 551 | return wrap_candidate; |
532 | } | 552 | } |
533 | struct sway_container *next = get_swayc_in_output_direction(adjacent, dir, seat); | 553 | struct sway_container *next = |
554 | get_swayc_in_output_direction(adjacent, dir, seat); | ||
534 | if (next == NULL) { | 555 | if (next == NULL) { |
535 | return NULL; | 556 | return NULL; |
536 | } | 557 | } |
@@ -570,8 +591,9 @@ static struct sway_container *get_swayc_in_direction_under(struct sway_container | |||
570 | } | 591 | } |
571 | } | 592 | } |
572 | } else { | 593 | } else { |
573 | wlr_log(L_DEBUG, "%s cont %d-%p dir %i sibling %d: %p", __func__, | 594 | wlr_log(L_DEBUG, |
574 | idx, container, dir, desired, parent->children->items[desired]); | 595 | "%s cont %d-%p dir %i sibling %d: %p", __func__, idx, |
596 | container, dir, desired, parent->children->items[desired]); | ||
575 | return parent->children->items[desired]; | 597 | return parent->children->items[desired]; |
576 | } | 598 | } |
577 | } | 599 | } |
@@ -587,7 +609,8 @@ static struct sway_container *get_swayc_in_direction_under(struct sway_container | |||
587 | } | 609 | } |
588 | } | 610 | } |
589 | 611 | ||
590 | struct sway_container *container_get_in_direction(struct sway_container *container, struct sway_seat *seat, | 612 | struct sway_container *container_get_in_direction( |
613 | struct sway_container *container, struct sway_seat *seat, | ||
591 | enum movement_direction dir) { | 614 | enum movement_direction dir) { |
592 | return get_swayc_in_direction_under(container, dir, seat, NULL); | 615 | return get_swayc_in_direction_under(container, dir, seat, NULL); |
593 | } | 616 | } |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 0fdd9975..369cf14c 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -52,7 +52,8 @@ struct sway_container *workspace_by_number(const char* name) { | |||
52 | if (wbnd.len <= 0) { | 52 | if (wbnd.len <= 0) { |
53 | return NULL; | 53 | return NULL; |
54 | } | 54 | } |
55 | return container_find(&root_container, _workspace_by_number, (void *) &wbnd); | 55 | return container_find(&root_container, |
56 | _workspace_by_number, (void *) &wbnd); | ||
56 | } | 57 | } |
57 | 58 | ||
58 | static bool _workspace_by_name(struct sway_container *view, void *data) { | 59 | static bool _workspace_by_name(struct sway_container *view, void *data) { |
@@ -79,7 +80,8 @@ struct sway_container *workspace_by_name(const char *name) { | |||
79 | } else if (strcmp(name, "current") == 0) { | 80 | } else if (strcmp(name, "current") == 0) { |
80 | return current_workspace; | 81 | return current_workspace; |
81 | } else { | 82 | } else { |
82 | return container_find(&root_container, _workspace_by_name, (void *) name); | 83 | return container_find(&root_container, _workspace_by_name, |
84 | (void *)name); | ||
83 | } | 85 | } |
84 | } | 86 | } |
85 | 87 | ||
@@ -103,7 +105,8 @@ struct sway_container *workspace_create(const char *name) { | |||
103 | } | 105 | } |
104 | // Otherwise create a new one | 106 | // Otherwise create a new one |
105 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 107 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
106 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); | 108 | struct sway_container *focus = |
109 | sway_seat_get_focus_inactive(seat, &root_container); | ||
107 | parent = focus; | 110 | parent = focus; |
108 | parent = container_parent(parent, C_OUTPUT); | 111 | parent = container_parent(parent, C_OUTPUT); |
109 | return container_workspace_create(parent, name); | 112 | return container_workspace_create(parent, name); |
@@ -114,7 +117,8 @@ struct sway_container *workspace_create(const char *name) { | |||
114 | * the end and beginning. If next is false, the previous workspace is returned, | 117 | * the end and beginning. If next is false, the previous workspace is returned, |
115 | * otherwise the next one is returned. | 118 | * otherwise the next one is returned. |
116 | */ | 119 | */ |
117 | struct sway_container *workspace_output_prev_next_impl(struct sway_container *output, bool next) { | 120 | struct sway_container *workspace_output_prev_next_impl( |
121 | struct sway_container *output, bool next) { | ||
118 | if (!sway_assert(output->type == C_OUTPUT, | 122 | if (!sway_assert(output->type == C_OUTPUT, |
119 | "Argument must be an output, is %d", output->type)) { | 123 | "Argument must be an output, is %d", output->type)) { |
120 | return NULL; | 124 | return NULL; |
@@ -134,7 +138,8 @@ struct sway_container *workspace_output_prev_next_impl(struct sway_container *ou | |||
134 | } | 138 | } |
135 | } | 139 | } |
136 | 140 | ||
137 | // Doesn't happen, at worst the for loop returns the previously active workspace | 141 | // Doesn't happen, at worst the for loop returns the previously active |
142 | // workspace | ||
138 | return NULL; | 143 | return NULL; |
139 | } | 144 | } |
140 | 145 | ||
@@ -144,7 +149,8 @@ struct sway_container *workspace_output_prev_next_impl(struct sway_container *ou | |||
144 | * next is false, the previous workspace is returned, otherwise the next one is | 149 | * next is false, the previous workspace is returned, otherwise the next one is |
145 | * returned. | 150 | * returned. |
146 | */ | 151 | */ |
147 | struct sway_container *workspace_prev_next_impl(struct sway_container *workspace, bool next) { | 152 | struct sway_container *workspace_prev_next_impl( |
153 | struct sway_container *workspace, bool next) { | ||
148 | if (!sway_assert(workspace->type == C_WORKSPACE, | 154 | if (!sway_assert(workspace->type == C_WORKSPACE, |
149 | "Argument must be a workspace, is %d", workspace->type)) { | 155 | "Argument must be a workspace, is %d", workspace->type)) { |
150 | return NULL; | 156 | return NULL; |
@@ -166,7 +172,8 @@ struct sway_container *workspace_prev_next_impl(struct sway_container *workspace | |||
166 | } | 172 | } |
167 | } | 173 | } |
168 | 174 | ||
169 | // Given workspace is the first/last on the output, jump to the previous/next output | 175 | // Given workspace is the first/last on the output, jump to the |
176 | // previous/next output | ||
170 | int num_outputs = root_container.children->length; | 177 | int num_outputs = root_container.children->length; |
171 | for (i = 0; i < num_outputs; i++) { | 178 | for (i = 0; i < num_outputs; i++) { |
172 | if (root_container.children->items[i] == current_output) { | 179 | if (root_container.children->items[i] == current_output) { |
@@ -176,7 +183,8 @@ struct sway_container *workspace_prev_next_impl(struct sway_container *workspace | |||
176 | } | 183 | } |
177 | } | 184 | } |
178 | 185 | ||
179 | // Doesn't happen, at worst the for loop returns the previously active workspace on the active output | 186 | // Doesn't happen, at worst the for loop returns the previously active |
187 | // workspace on the active output | ||
180 | return NULL; | 188 | return NULL; |
181 | } | 189 | } |
182 | 190 | ||
@@ -201,7 +209,8 @@ bool workspace_switch(struct sway_container *workspace) { | |||
201 | return false; | 209 | return false; |
202 | } | 210 | } |
203 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 211 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
204 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); | 212 | struct sway_container *focus = |
213 | sway_seat_get_focus_inactive(seat, &root_container); | ||
205 | if (!seat || !focus) { | 214 | if (!seat || !focus) { |
206 | return false; | 215 | return false; |
207 | } | 216 | } |
@@ -230,7 +239,8 @@ bool workspace_switch(struct sway_container *workspace) { | |||
230 | 239 | ||
231 | // TODO: Deal with sticky containers | 240 | // TODO: Deal with sticky containers |
232 | 241 | ||
233 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); | 242 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", |
243 | workspace, workspace->name); | ||
234 | struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace); | 244 | struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace); |
235 | if (next == NULL) { | 245 | if (next == NULL) { |
236 | next = workspace; | 246 | next = workspace; |