diff options
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index a6d1870c..292f2c9a 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -67,9 +67,7 @@ struct sway_container *workspace_create(struct sway_container *output, | |||
67 | return NULL; | 67 | return NULL; |
68 | } | 68 | } |
69 | swayws->swayc = workspace; | 69 | swayws->swayc = workspace; |
70 | swayws->floating = container_create(C_CONTAINER); | 70 | swayws->floating = create_list(); |
71 | swayws->floating->parent = swayws->swayc; | ||
72 | swayws->floating->layout = L_FLOATING; | ||
73 | swayws->output_priority = create_list(); | 71 | swayws->output_priority = create_list(); |
74 | workspace->sway_workspace = swayws; | 72 | workspace->sway_workspace = swayws; |
75 | workspace_output_add_priority(workspace, output); | 73 | workspace_output_add_priority(workspace, output); |
@@ -392,17 +390,15 @@ bool workspace_switch(struct sway_container *workspace, | |||
392 | struct sway_container *next_output = workspace->parent; | 390 | struct sway_container *next_output = workspace->parent; |
393 | struct sway_container *next_output_prev_ws = | 391 | struct sway_container *next_output_prev_ws = |
394 | seat_get_active_child(seat, next_output); | 392 | seat_get_active_child(seat, next_output); |
395 | struct sway_container *floating = | 393 | list_t *floating = next_output_prev_ws->sway_workspace->floating; |
396 | next_output_prev_ws->sway_workspace->floating; | ||
397 | bool has_sticky = false; | 394 | bool has_sticky = false; |
398 | if (workspace != next_output_prev_ws) { | 395 | if (workspace != next_output_prev_ws) { |
399 | for (int i = 0; i < floating->children->length; ++i) { | 396 | for (int i = 0; i < floating->length; ++i) { |
400 | struct sway_container *floater = floating->children->items[i]; | 397 | struct sway_container *floater = floating->items[i]; |
401 | if (floater->is_sticky) { | 398 | if (floater->is_sticky) { |
402 | has_sticky = true; | 399 | has_sticky = true; |
403 | container_remove_child(floater); | 400 | container_remove_child(floater); |
404 | container_add_child(workspace->sway_workspace->floating, | 401 | workspace_add_floating(workspace, floater); |
405 | floater); | ||
406 | if (floater == focus) { | 402 | if (floater == focus) { |
407 | seat_set_focus(seat, NULL); | 403 | seat_set_focus(seat, NULL); |
408 | seat_set_focus(seat, floater); | 404 | seat_set_focus(seat, floater); |
@@ -455,9 +451,9 @@ bool workspace_is_empty(struct sway_container *ws) { | |||
455 | return false; | 451 | return false; |
456 | } | 452 | } |
457 | // Sticky views are not considered to be part of this workspace | 453 | // Sticky views are not considered to be part of this workspace |
458 | struct sway_container *floating = ws->sway_workspace->floating; | 454 | list_t *floating = ws->sway_workspace->floating; |
459 | for (int i = 0; i < floating->children->length; ++i) { | 455 | for (int i = 0; i < floating->length; ++i) { |
460 | struct sway_container *floater = floating->children->items[i]; | 456 | struct sway_container *floater = floating->items[i]; |
461 | if (!floater->is_sticky) { | 457 | if (!floater->is_sticky) { |
462 | return false; | 458 | return false; |
463 | } | 459 | } |
@@ -548,9 +544,9 @@ void workspace_for_each_container(struct sway_container *ws, | |||
548 | container_for_each_child(container, f, data); | 544 | container_for_each_child(container, f, data); |
549 | } | 545 | } |
550 | // Floating | 546 | // Floating |
551 | for (int i = 0; i < ws->sway_workspace->floating->children->length; ++i) { | 547 | for (int i = 0; i < ws->sway_workspace->floating->length; ++i) { |
552 | struct sway_container *container = | 548 | struct sway_container *container = |
553 | ws->sway_workspace->floating->children->items[i]; | 549 | ws->sway_workspace->floating->items[i]; |
554 | f(container, data); | 550 | f(container, data); |
555 | container_for_each_child(container, f, data); | 551 | container_for_each_child(container, f, data); |
556 | } | 552 | } |
@@ -573,9 +569,8 @@ struct sway_container *workspace_find_container(struct sway_container *ws, | |||
573 | } | 569 | } |
574 | } | 570 | } |
575 | // Floating | 571 | // Floating |
576 | for (int i = 0; i < ws->sway_workspace->floating->children->length; ++i) { | 572 | for (int i = 0; i < ws->sway_workspace->floating->length; ++i) { |
577 | struct sway_container *child = | 573 | struct sway_container *child = ws->sway_workspace->floating->items[i]; |
578 | ws->sway_workspace->floating->children->items[i]; | ||
579 | if (test(child, data)) { | 574 | if (test(child, data)) { |
580 | return child; | 575 | return child; |
581 | } | 576 | } |
@@ -597,3 +592,18 @@ struct sway_container *workspace_wrap_children(struct sway_container *ws) { | |||
597 | container_add_child(ws, middle); | 592 | container_add_child(ws, middle); |
598 | return middle; | 593 | return middle; |
599 | } | 594 | } |
595 | |||
596 | void workspace_add_floating(struct sway_container *workspace, | ||
597 | struct sway_container *con) { | ||
598 | if (!sway_assert(workspace->type == C_WORKSPACE, "Expected a workspace")) { | ||
599 | return; | ||
600 | } | ||
601 | if (!sway_assert(con->parent == NULL, "Expected an orphan container")) { | ||
602 | return; | ||
603 | } | ||
604 | |||
605 | list_add(workspace->sway_workspace->floating, con); | ||
606 | con->parent = workspace; | ||
607 | container_set_dirty(workspace); | ||
608 | container_set_dirty(con); | ||
609 | } | ||