diff options
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 921b7d19..7e98dc92 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -48,7 +48,7 @@ struct sway_output *workspace_get_initial_output(const char *name) { | |||
48 | if (focus && focus->type == N_WORKSPACE) { | 48 | if (focus && focus->type == N_WORKSPACE) { |
49 | return focus->sway_workspace->output; | 49 | return focus->sway_workspace->output; |
50 | } else if (focus && focus->type == N_CONTAINER) { | 50 | } else if (focus && focus->type == N_CONTAINER) { |
51 | return focus->sway_container->workspace->output; | 51 | return focus->sway_container->pending.workspace->output; |
52 | } | 52 | } |
53 | // Fallback to the first output or noop output for headless | 53 | // Fallback to the first output or noop output for headless |
54 | return root->outputs->length ? root->outputs->items[0] : root->noop_output; | 54 | return root->outputs->length ? root->outputs->items[0] : root->noop_output; |
@@ -561,25 +561,30 @@ struct sway_workspace *workspace_output_prev( | |||
561 | return workspace_output_prev_next_impl(current->output, -1, create); | 561 | return workspace_output_prev_next_impl(current->output, -1, create); |
562 | } | 562 | } |
563 | 563 | ||
564 | bool workspace_switch(struct sway_workspace *workspace, | 564 | struct sway_workspace *workspace_auto_back_and_forth( |
565 | bool no_auto_back_and_forth) { | 565 | struct sway_workspace *workspace) { |
566 | struct sway_seat *seat = input_manager_current_seat(); | 566 | struct sway_seat *seat = input_manager_current_seat(); |
567 | struct sway_workspace *active_ws = NULL; | 567 | struct sway_workspace *active_ws = NULL; |
568 | struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); | 568 | struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); |
569 | if (focus && focus->type == N_WORKSPACE) { | 569 | if (focus && focus->type == N_WORKSPACE) { |
570 | active_ws = focus->sway_workspace; | 570 | active_ws = focus->sway_workspace; |
571 | } else if (focus && focus->type == N_CONTAINER) { | 571 | } else if (focus && focus->type == N_CONTAINER) { |
572 | active_ws = focus->sway_container->workspace; | 572 | active_ws = focus->sway_container->pending.workspace; |
573 | } | 573 | } |
574 | 574 | ||
575 | if (!no_auto_back_and_forth && config->auto_back_and_forth && active_ws | 575 | if (config->auto_back_and_forth && active_ws && active_ws == workspace && |
576 | && active_ws == workspace && seat->prev_workspace_name) { | 576 | seat->prev_workspace_name) { |
577 | struct sway_workspace *new_ws = | 577 | struct sway_workspace *new_ws = |
578 | workspace_by_name(seat->prev_workspace_name); | 578 | workspace_by_name(seat->prev_workspace_name); |
579 | workspace = new_ws ? | 579 | workspace = new_ws ? |
580 | new_ws : | 580 | new_ws : |
581 | workspace_create(NULL, seat->prev_workspace_name); | 581 | workspace_create(NULL, seat->prev_workspace_name); |
582 | } | 582 | } |
583 | return workspace; | ||
584 | } | ||
585 | |||
586 | bool workspace_switch(struct sway_workspace *workspace) { | ||
587 | struct sway_seat *seat = input_manager_current_seat(); | ||
583 | 588 | ||
584 | sway_log(SWAY_DEBUG, "Switching to workspace %p:%s", | 589 | sway_log(SWAY_DEBUG, "Switching to workspace %p:%s", |
585 | workspace, workspace->name); | 590 | workspace, workspace->name); |
@@ -736,13 +741,13 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws, | |||
736 | } | 741 | } |
737 | 742 | ||
738 | static void set_workspace(struct sway_container *container, void *data) { | 743 | static void set_workspace(struct sway_container *container, void *data) { |
739 | container->workspace = container->parent->workspace; | 744 | container->pending.workspace = container->pending.parent->pending.workspace; |
740 | } | 745 | } |
741 | 746 | ||
742 | static void workspace_attach_tiling(struct sway_workspace *ws, | 747 | static void workspace_attach_tiling(struct sway_workspace *ws, |
743 | struct sway_container *con) { | 748 | struct sway_container *con) { |
744 | list_add(ws->tiling, con); | 749 | list_add(ws->tiling, con); |
745 | con->workspace = ws; | 750 | con->pending.workspace = ws; |
746 | container_for_each_child(con, set_workspace, NULL); | 751 | container_for_each_child(con, set_workspace, NULL); |
747 | container_handle_fullscreen_reparent(con); | 752 | container_handle_fullscreen_reparent(con); |
748 | workspace_update_representation(ws); | 753 | workspace_update_representation(ws); |
@@ -753,7 +758,7 @@ static void workspace_attach_tiling(struct sway_workspace *ws, | |||
753 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { | 758 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { |
754 | struct sway_container *fs = ws->fullscreen; | 759 | struct sway_container *fs = ws->fullscreen; |
755 | struct sway_container *middle = container_create(NULL); | 760 | struct sway_container *middle = container_create(NULL); |
756 | middle->layout = ws->layout; | 761 | middle->pending.layout = ws->layout; |
757 | while (ws->tiling->length) { | 762 | while (ws->tiling->length) { |
758 | struct sway_container *child = ws->tiling->items[0]; | 763 | struct sway_container *child = ws->tiling->items[0]; |
759 | container_detach(child); | 764 | container_detach(child); |
@@ -771,9 +776,9 @@ void workspace_unwrap_children(struct sway_workspace *ws, | |||
771 | return; | 776 | return; |
772 | } | 777 | } |
773 | 778 | ||
774 | ws->layout = wrap->layout; | 779 | ws->layout = wrap->pending.layout; |
775 | while (wrap->children->length) { | 780 | while (wrap->pending.children->length) { |
776 | struct sway_container *child = wrap->children->items[0]; | 781 | struct sway_container *child = wrap->pending.children->items[0]; |
777 | container_detach(child); | 782 | container_detach(child); |
778 | workspace_add_tiling(ws, child); | 783 | workspace_add_tiling(ws, child); |
779 | } | 784 | } |
@@ -793,14 +798,18 @@ void workspace_detach(struct sway_workspace *workspace) { | |||
793 | 798 | ||
794 | struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, | 799 | struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, |
795 | struct sway_container *con) { | 800 | struct sway_container *con) { |
796 | if (con->workspace) { | 801 | if (con->pending.workspace) { |
802 | struct sway_container *old_parent = con->pending.parent; | ||
797 | container_detach(con); | 803 | container_detach(con); |
804 | if (old_parent) { | ||
805 | container_reap_empty(old_parent); | ||
806 | } | ||
798 | } | 807 | } |
799 | if (config->default_layout != L_NONE) { | 808 | if (config->default_layout != L_NONE) { |
800 | con = container_split(con, config->default_layout); | 809 | con = container_split(con, config->default_layout); |
801 | } | 810 | } |
802 | list_add(workspace->tiling, con); | 811 | list_add(workspace->tiling, con); |
803 | con->workspace = workspace; | 812 | con->pending.workspace = workspace; |
804 | container_for_each_child(con, set_workspace, NULL); | 813 | container_for_each_child(con, set_workspace, NULL); |
805 | container_handle_fullscreen_reparent(con); | 814 | container_handle_fullscreen_reparent(con); |
806 | workspace_update_representation(workspace); | 815 | workspace_update_representation(workspace); |
@@ -811,11 +820,11 @@ struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, | |||
811 | 820 | ||
812 | void workspace_add_floating(struct sway_workspace *workspace, | 821 | void workspace_add_floating(struct sway_workspace *workspace, |
813 | struct sway_container *con) { | 822 | struct sway_container *con) { |
814 | if (con->workspace) { | 823 | if (con->pending.workspace) { |
815 | container_detach(con); | 824 | container_detach(con); |
816 | } | 825 | } |
817 | list_add(workspace->floating, con); | 826 | list_add(workspace->floating, con); |
818 | con->workspace = workspace; | 827 | con->pending.workspace = workspace; |
819 | container_for_each_child(con, set_workspace, NULL); | 828 | container_for_each_child(con, set_workspace, NULL); |
820 | container_handle_fullscreen_reparent(con); | 829 | container_handle_fullscreen_reparent(con); |
821 | node_set_dirty(&workspace->node); | 830 | node_set_dirty(&workspace->node); |
@@ -825,7 +834,7 @@ void workspace_add_floating(struct sway_workspace *workspace, | |||
825 | void workspace_insert_tiling_direct(struct sway_workspace *workspace, | 834 | void workspace_insert_tiling_direct(struct sway_workspace *workspace, |
826 | struct sway_container *con, int index) { | 835 | struct sway_container *con, int index) { |
827 | list_insert(workspace->tiling, index, con); | 836 | list_insert(workspace->tiling, index, con); |
828 | con->workspace = workspace; | 837 | con->pending.workspace = workspace; |
829 | container_for_each_child(con, set_workspace, NULL); | 838 | container_for_each_child(con, set_workspace, NULL); |
830 | container_handle_fullscreen_reparent(con); | 839 | container_handle_fullscreen_reparent(con); |
831 | workspace_update_representation(workspace); | 840 | workspace_update_representation(workspace); |
@@ -835,7 +844,7 @@ void workspace_insert_tiling_direct(struct sway_workspace *workspace, | |||
835 | 844 | ||
836 | struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace, | 845 | struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace, |
837 | struct sway_container *con, int index) { | 846 | struct sway_container *con, int index) { |
838 | if (con->workspace) { | 847 | if (con->pending.workspace) { |
839 | container_detach(con); | 848 | container_detach(con); |
840 | } | 849 | } |
841 | if (config->default_layout != L_NONE) { | 850 | if (config->default_layout != L_NONE) { |
@@ -905,7 +914,7 @@ struct sway_container *workspace_split(struct sway_workspace *workspace, | |||
905 | enum sway_container_layout old_layout = workspace->layout; | 914 | enum sway_container_layout old_layout = workspace->layout; |
906 | struct sway_container *middle = workspace_wrap_children(workspace); | 915 | struct sway_container *middle = workspace_wrap_children(workspace); |
907 | workspace->layout = layout; | 916 | workspace->layout = layout; |
908 | middle->layout = old_layout; | 917 | middle->pending.layout = old_layout; |
909 | 918 | ||
910 | struct sway_seat *seat; | 919 | struct sway_seat *seat; |
911 | wl_list_for_each(seat, &server.input->seats, link) { | 920 | wl_list_for_each(seat, &server.input->seats, link) { |