diff options
author | Kenny Levinsen <kl@kl.wtf> | 2021-02-12 23:22:51 +0100 |
---|---|---|
committer | Tudor Brindus <me@tbrindus.ca> | 2021-02-16 22:05:00 -0500 |
commit | a047b5ee4a2a67d30d93641ff86531d54b8e0879 (patch) | |
tree | 271666c6254e4fabf943c1153224059411a5ce56 /sway/tree/workspace.c | |
parent | Add missing transaction commits to seatop_default (diff) | |
download | sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.tar.gz sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.tar.zst sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.zip |
container: Move pending state to state struct
Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.
Instead, use the state struct for both current and pending.
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 921b7d19..4e735064 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; |
@@ -569,7 +569,7 @@ bool workspace_switch(struct sway_workspace *workspace, | |||
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 (!no_auto_back_and_forth && config->auto_back_and_forth && active_ws |
@@ -736,13 +736,13 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws, | |||
736 | } | 736 | } |
737 | 737 | ||
738 | static void set_workspace(struct sway_container *container, void *data) { | 738 | static void set_workspace(struct sway_container *container, void *data) { |
739 | container->workspace = container->parent->workspace; | 739 | container->pending.workspace = container->pending.parent->pending.workspace; |
740 | } | 740 | } |
741 | 741 | ||
742 | static void workspace_attach_tiling(struct sway_workspace *ws, | 742 | static void workspace_attach_tiling(struct sway_workspace *ws, |
743 | struct sway_container *con) { | 743 | struct sway_container *con) { |
744 | list_add(ws->tiling, con); | 744 | list_add(ws->tiling, con); |
745 | con->workspace = ws; | 745 | con->pending.workspace = ws; |
746 | container_for_each_child(con, set_workspace, NULL); | 746 | container_for_each_child(con, set_workspace, NULL); |
747 | container_handle_fullscreen_reparent(con); | 747 | container_handle_fullscreen_reparent(con); |
748 | workspace_update_representation(ws); | 748 | workspace_update_representation(ws); |
@@ -753,7 +753,7 @@ static void workspace_attach_tiling(struct sway_workspace *ws, | |||
753 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { | 753 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { |
754 | struct sway_container *fs = ws->fullscreen; | 754 | struct sway_container *fs = ws->fullscreen; |
755 | struct sway_container *middle = container_create(NULL); | 755 | struct sway_container *middle = container_create(NULL); |
756 | middle->layout = ws->layout; | 756 | middle->pending.layout = ws->layout; |
757 | while (ws->tiling->length) { | 757 | while (ws->tiling->length) { |
758 | struct sway_container *child = ws->tiling->items[0]; | 758 | struct sway_container *child = ws->tiling->items[0]; |
759 | container_detach(child); | 759 | container_detach(child); |
@@ -771,9 +771,9 @@ void workspace_unwrap_children(struct sway_workspace *ws, | |||
771 | return; | 771 | return; |
772 | } | 772 | } |
773 | 773 | ||
774 | ws->layout = wrap->layout; | 774 | ws->layout = wrap->pending.layout; |
775 | while (wrap->children->length) { | 775 | while (wrap->pending.children->length) { |
776 | struct sway_container *child = wrap->children->items[0]; | 776 | struct sway_container *child = wrap->pending.children->items[0]; |
777 | container_detach(child); | 777 | container_detach(child); |
778 | workspace_add_tiling(ws, child); | 778 | workspace_add_tiling(ws, child); |
779 | } | 779 | } |
@@ -793,14 +793,14 @@ void workspace_detach(struct sway_workspace *workspace) { | |||
793 | 793 | ||
794 | struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, | 794 | struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, |
795 | struct sway_container *con) { | 795 | struct sway_container *con) { |
796 | if (con->workspace) { | 796 | if (con->pending.workspace) { |
797 | container_detach(con); | 797 | container_detach(con); |
798 | } | 798 | } |
799 | if (config->default_layout != L_NONE) { | 799 | if (config->default_layout != L_NONE) { |
800 | con = container_split(con, config->default_layout); | 800 | con = container_split(con, config->default_layout); |
801 | } | 801 | } |
802 | list_add(workspace->tiling, con); | 802 | list_add(workspace->tiling, con); |
803 | con->workspace = workspace; | 803 | con->pending.workspace = workspace; |
804 | container_for_each_child(con, set_workspace, NULL); | 804 | container_for_each_child(con, set_workspace, NULL); |
805 | container_handle_fullscreen_reparent(con); | 805 | container_handle_fullscreen_reparent(con); |
806 | workspace_update_representation(workspace); | 806 | workspace_update_representation(workspace); |
@@ -811,11 +811,11 @@ struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, | |||
811 | 811 | ||
812 | void workspace_add_floating(struct sway_workspace *workspace, | 812 | void workspace_add_floating(struct sway_workspace *workspace, |
813 | struct sway_container *con) { | 813 | struct sway_container *con) { |
814 | if (con->workspace) { | 814 | if (con->pending.workspace) { |
815 | container_detach(con); | 815 | container_detach(con); |
816 | } | 816 | } |
817 | list_add(workspace->floating, con); | 817 | list_add(workspace->floating, con); |
818 | con->workspace = workspace; | 818 | con->pending.workspace = workspace; |
819 | container_for_each_child(con, set_workspace, NULL); | 819 | container_for_each_child(con, set_workspace, NULL); |
820 | container_handle_fullscreen_reparent(con); | 820 | container_handle_fullscreen_reparent(con); |
821 | node_set_dirty(&workspace->node); | 821 | node_set_dirty(&workspace->node); |
@@ -825,7 +825,7 @@ void workspace_add_floating(struct sway_workspace *workspace, | |||
825 | void workspace_insert_tiling_direct(struct sway_workspace *workspace, | 825 | void workspace_insert_tiling_direct(struct sway_workspace *workspace, |
826 | struct sway_container *con, int index) { | 826 | struct sway_container *con, int index) { |
827 | list_insert(workspace->tiling, index, con); | 827 | list_insert(workspace->tiling, index, con); |
828 | con->workspace = workspace; | 828 | con->pending.workspace = workspace; |
829 | container_for_each_child(con, set_workspace, NULL); | 829 | container_for_each_child(con, set_workspace, NULL); |
830 | container_handle_fullscreen_reparent(con); | 830 | container_handle_fullscreen_reparent(con); |
831 | workspace_update_representation(workspace); | 831 | workspace_update_representation(workspace); |
@@ -835,7 +835,7 @@ void workspace_insert_tiling_direct(struct sway_workspace *workspace, | |||
835 | 835 | ||
836 | struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace, | 836 | struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace, |
837 | struct sway_container *con, int index) { | 837 | struct sway_container *con, int index) { |
838 | if (con->workspace) { | 838 | if (con->pending.workspace) { |
839 | container_detach(con); | 839 | container_detach(con); |
840 | } | 840 | } |
841 | if (config->default_layout != L_NONE) { | 841 | if (config->default_layout != L_NONE) { |
@@ -905,7 +905,7 @@ struct sway_container *workspace_split(struct sway_workspace *workspace, | |||
905 | enum sway_container_layout old_layout = workspace->layout; | 905 | enum sway_container_layout old_layout = workspace->layout; |
906 | struct sway_container *middle = workspace_wrap_children(workspace); | 906 | struct sway_container *middle = workspace_wrap_children(workspace); |
907 | workspace->layout = layout; | 907 | workspace->layout = layout; |
908 | middle->layout = old_layout; | 908 | middle->pending.layout = old_layout; |
909 | 909 | ||
910 | struct sway_seat *seat; | 910 | struct sway_seat *seat; |
911 | wl_list_for_each(seat, &server.input->seats, link) { | 911 | wl_list_for_each(seat, &server.input->seats, link) { |