diff options
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index ffcbe933..e40792ae 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -627,6 +627,21 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws, | |||
627 | return NULL; | 627 | return NULL; |
628 | } | 628 | } |
629 | 629 | ||
630 | static void set_workspace(struct sway_container *container, void *data) { | ||
631 | container->workspace = container->parent->workspace; | ||
632 | } | ||
633 | |||
634 | static void workspace_attach_tiling(struct sway_workspace *ws, | ||
635 | struct sway_container *con) { | ||
636 | list_add(ws->tiling, con); | ||
637 | con->workspace = ws; | ||
638 | container_for_each_child(con, set_workspace, NULL); | ||
639 | container_handle_fullscreen_reparent(con); | ||
640 | workspace_update_representation(ws); | ||
641 | node_set_dirty(&ws->node); | ||
642 | node_set_dirty(&con->node); | ||
643 | } | ||
644 | |||
630 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { | 645 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { |
631 | struct sway_container *fs = ws->fullscreen; | 646 | struct sway_container *fs = ws->fullscreen; |
632 | struct sway_container *middle = container_create(NULL); | 647 | struct sway_container *middle = container_create(NULL); |
@@ -636,7 +651,7 @@ struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { | |||
636 | container_detach(child); | 651 | container_detach(child); |
637 | container_add_child(middle, child); | 652 | container_add_child(middle, child); |
638 | } | 653 | } |
639 | workspace_add_tiling(ws, middle); | 654 | workspace_attach_tiling(ws, middle); |
640 | ws->fullscreen = fs; | 655 | ws->fullscreen = fs; |
641 | return middle; | 656 | return middle; |
642 | } | 657 | } |
@@ -668,15 +683,14 @@ void workspace_detach(struct sway_workspace *workspace) { | |||
668 | node_set_dirty(&output->node); | 683 | node_set_dirty(&output->node); |
669 | } | 684 | } |
670 | 685 | ||
671 | static void set_workspace(struct sway_container *container, void *data) { | 686 | struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, |
672 | container->workspace = container->parent->workspace; | ||
673 | } | ||
674 | |||
675 | void workspace_add_tiling(struct sway_workspace *workspace, | ||
676 | struct sway_container *con) { | 687 | struct sway_container *con) { |
677 | if (con->workspace) { | 688 | if (con->workspace) { |
678 | container_detach(con); | 689 | container_detach(con); |
679 | } | 690 | } |
691 | if (config->default_layout != L_NONE) { | ||
692 | con = container_split(con, config->default_layout); | ||
693 | } | ||
680 | list_add(workspace->tiling, con); | 694 | list_add(workspace->tiling, con); |
681 | con->workspace = workspace; | 695 | con->workspace = workspace; |
682 | container_for_each_child(con, set_workspace, NULL); | 696 | container_for_each_child(con, set_workspace, NULL); |
@@ -684,6 +698,7 @@ void workspace_add_tiling(struct sway_workspace *workspace, | |||
684 | workspace_update_representation(workspace); | 698 | workspace_update_representation(workspace); |
685 | node_set_dirty(&workspace->node); | 699 | node_set_dirty(&workspace->node); |
686 | node_set_dirty(&con->node); | 700 | node_set_dirty(&con->node); |
701 | return con; | ||
687 | } | 702 | } |
688 | 703 | ||
689 | void workspace_add_floating(struct sway_workspace *workspace, | 704 | void workspace_add_floating(struct sway_workspace *workspace, |
@@ -699,13 +714,13 @@ void workspace_add_floating(struct sway_workspace *workspace, | |||
699 | node_set_dirty(&con->node); | 714 | node_set_dirty(&con->node); |
700 | } | 715 | } |
701 | 716 | ||
702 | void workspace_insert_tiling(struct sway_workspace *workspace, | 717 | struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace, |
703 | struct sway_container *con, int index) { | 718 | struct sway_container *con, int index) { |
704 | if (con->workspace) { | 719 | if (con->workspace) { |
705 | container_detach(con); | 720 | container_detach(con); |
706 | } | 721 | } |
707 | if (workspace->layout == L_STACKED || workspace->layout == L_TABBED) { | 722 | if (config->default_layout != L_NONE) { |
708 | con = container_split(con, workspace->layout); | 723 | con = container_split(con, config->default_layout); |
709 | } | 724 | } |
710 | list_insert(workspace->tiling, index, con); | 725 | list_insert(workspace->tiling, index, con); |
711 | con->workspace = workspace; | 726 | con->workspace = workspace; |
@@ -714,6 +729,7 @@ void workspace_insert_tiling(struct sway_workspace *workspace, | |||
714 | workspace_update_representation(workspace); | 729 | workspace_update_representation(workspace); |
715 | node_set_dirty(&workspace->node); | 730 | node_set_dirty(&workspace->node); |
716 | node_set_dirty(&con->node); | 731 | node_set_dirty(&con->node); |
732 | return con; | ||
717 | } | 733 | } |
718 | 734 | ||
719 | void workspace_add_gaps(struct sway_workspace *ws) { | 735 | void workspace_add_gaps(struct sway_workspace *ws) { |