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/desktop/transaction.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/desktop/transaction.c')
-rw-r--r-- | sway/desktop/transaction.c | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 9f488963..6c392bab 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -128,8 +128,8 @@ static void copy_workspace_state(struct sway_workspace *ws, | |||
128 | // Set focused_inactive_child to the direct tiling child | 128 | // Set focused_inactive_child to the direct tiling child |
129 | struct sway_container *focus = seat_get_focus_inactive_tiling(seat, ws); | 129 | struct sway_container *focus = seat_get_focus_inactive_tiling(seat, ws); |
130 | if (focus) { | 130 | if (focus) { |
131 | while (focus->parent) { | 131 | while (focus->pending.parent) { |
132 | focus = focus->parent; | 132 | focus = focus->pending.parent; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | state->focused_inactive_child = focus; | 135 | state->focused_inactive_child = focus; |
@@ -139,32 +139,19 @@ static void copy_container_state(struct sway_container *container, | |||
139 | struct sway_transaction_instruction *instruction) { | 139 | struct sway_transaction_instruction *instruction) { |
140 | struct sway_container_state *state = &instruction->container_state; | 140 | struct sway_container_state *state = &instruction->container_state; |
141 | 141 | ||
142 | state->layout = container->layout; | 142 | if (state->children) { |
143 | state->x = container->x; | 143 | list_free(state->children); |
144 | state->y = container->y; | 144 | } |
145 | state->width = container->width; | 145 | |
146 | state->height = container->height; | 146 | memcpy(state, &container->pending, sizeof(struct sway_container_state)); |
147 | state->fullscreen_mode = container->fullscreen_mode; | ||
148 | state->parent = container->parent; | ||
149 | state->workspace = container->workspace; | ||
150 | state->border = container->border; | ||
151 | state->border_thickness = container->border_thickness; | ||
152 | state->border_top = container->border_top; | ||
153 | state->border_left = container->border_left; | ||
154 | state->border_right = container->border_right; | ||
155 | state->border_bottom = container->border_bottom; | ||
156 | state->content_x = container->content_x; | ||
157 | state->content_y = container->content_y; | ||
158 | state->content_width = container->content_width; | ||
159 | state->content_height = container->content_height; | ||
160 | 147 | ||
161 | if (!container->view) { | 148 | if (!container->view) { |
162 | if (state->children) { | 149 | // We store a copy of the child list to avoid having it mutated after |
163 | state->children->length = 0; | 150 | // we copy the state. |
164 | } else { | 151 | state->children = create_list(); |
165 | state->children = create_list(); | 152 | list_cat(state->children, container->pending.children); |
166 | } | 153 | } else { |
167 | list_cat(state->children, container->children); | 154 | state->children = NULL; |
168 | } | 155 | } |
169 | 156 | ||
170 | struct sway_seat *seat = input_manager_current_seat(); | 157 | struct sway_seat *seat = input_manager_current_seat(); |