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/input/seatop_move_tiling.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/input/seatop_move_tiling.c')
-rw-r--r-- | sway/input/seatop_move_tiling.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c index 7d9ecd8f..446612c6 100644 --- a/sway/input/seatop_move_tiling.c +++ b/sway/input/seatop_move_tiling.c | |||
@@ -120,8 +120,8 @@ static void handle_motion_postthreshold(struct sway_seat *seat) { | |||
120 | 120 | ||
121 | // Deny moving within own workspace if this is the only child | 121 | // Deny moving within own workspace if this is the only child |
122 | struct sway_container *con = node->sway_container; | 122 | struct sway_container *con = node->sway_container; |
123 | if (workspace_num_tiling_views(e->con->workspace) == 1 && | 123 | if (workspace_num_tiling_views(e->con->pending.workspace) == 1 && |
124 | con->workspace == e->con->workspace) { | 124 | con->pending.workspace == e->con->pending.workspace) { |
125 | e->target_node = NULL; | 125 | e->target_node = NULL; |
126 | e->target_edge = WLR_EDGE_NONE; | 126 | e->target_edge = WLR_EDGE_NONE; |
127 | return; | 127 | return; |
@@ -133,8 +133,8 @@ static void handle_motion_postthreshold(struct sway_seat *seat) { | |||
133 | enum wlr_edges edge = WLR_EDGE_NONE; | 133 | enum wlr_edges edge = WLR_EDGE_NONE; |
134 | enum sway_container_layout layout = container_parent_layout(con); | 134 | enum sway_container_layout layout = container_parent_layout(con); |
135 | struct wlr_box parent; | 135 | struct wlr_box parent; |
136 | con->parent ? container_get_box(con->parent, &parent) : | 136 | con->pending.parent ? container_get_box(con->pending.parent, &parent) : |
137 | workspace_get_box(con->workspace, &parent); | 137 | workspace_get_box(con->pending.workspace, &parent); |
138 | if (layout == L_HORIZ || layout == L_TABBED) { | 138 | if (layout == L_HORIZ || layout == L_TABBED) { |
139 | if (cursor->cursor->y < parent.y + DROP_LAYOUT_BORDER) { | 139 | if (cursor->cursor->y < parent.y + DROP_LAYOUT_BORDER) { |
140 | edge = WLR_EDGE_TOP; | 140 | edge = WLR_EDGE_TOP; |
@@ -161,7 +161,7 @@ static void handle_motion_postthreshold(struct sway_seat *seat) { | |||
161 | desktop_damage_box(&e->drop_box); | 161 | desktop_damage_box(&e->drop_box); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | con = con->parent; | 164 | con = con->pending.parent; |
165 | } | 165 | } |
166 | 166 | ||
167 | // Use the hovered view - but we must be over the actual surface | 167 | // Use the hovered view - but we must be over the actual surface |
@@ -174,23 +174,23 @@ static void handle_motion_postthreshold(struct sway_seat *seat) { | |||
174 | } | 174 | } |
175 | 175 | ||
176 | // Find the closest edge | 176 | // Find the closest edge |
177 | size_t thickness = fmin(con->content_width, con->content_height) * 0.3; | 177 | size_t thickness = fmin(con->pending.content_width, con->pending.content_height) * 0.3; |
178 | size_t closest_dist = INT_MAX; | 178 | size_t closest_dist = INT_MAX; |
179 | size_t dist; | 179 | size_t dist; |
180 | e->target_edge = WLR_EDGE_NONE; | 180 | e->target_edge = WLR_EDGE_NONE; |
181 | if ((dist = cursor->cursor->y - con->y) < closest_dist) { | 181 | if ((dist = cursor->cursor->y - con->pending.y) < closest_dist) { |
182 | closest_dist = dist; | 182 | closest_dist = dist; |
183 | e->target_edge = WLR_EDGE_TOP; | 183 | e->target_edge = WLR_EDGE_TOP; |
184 | } | 184 | } |
185 | if ((dist = cursor->cursor->x - con->x) < closest_dist) { | 185 | if ((dist = cursor->cursor->x - con->pending.x) < closest_dist) { |
186 | closest_dist = dist; | 186 | closest_dist = dist; |
187 | e->target_edge = WLR_EDGE_LEFT; | 187 | e->target_edge = WLR_EDGE_LEFT; |
188 | } | 188 | } |
189 | if ((dist = con->x + con->width - cursor->cursor->x) < closest_dist) { | 189 | if ((dist = con->pending.x + con->pending.width - cursor->cursor->x) < closest_dist) { |
190 | closest_dist = dist; | 190 | closest_dist = dist; |
191 | e->target_edge = WLR_EDGE_RIGHT; | 191 | e->target_edge = WLR_EDGE_RIGHT; |
192 | } | 192 | } |
193 | if ((dist = con->y + con->height - cursor->cursor->y) < closest_dist) { | 193 | if ((dist = con->pending.y + con->pending.height - cursor->cursor->y) < closest_dist) { |
194 | closest_dist = dist; | 194 | closest_dist = dist; |
195 | e->target_edge = WLR_EDGE_BOTTOM; | 195 | e->target_edge = WLR_EDGE_BOTTOM; |
196 | } | 196 | } |
@@ -200,10 +200,10 @@ static void handle_motion_postthreshold(struct sway_seat *seat) { | |||
200 | } | 200 | } |
201 | 201 | ||
202 | e->target_node = node; | 202 | e->target_node = node; |
203 | e->drop_box.x = con->content_x; | 203 | e->drop_box.x = con->pending.content_x; |
204 | e->drop_box.y = con->content_y; | 204 | e->drop_box.y = con->pending.content_y; |
205 | e->drop_box.width = con->content_width; | 205 | e->drop_box.width = con->pending.content_width; |
206 | e->drop_box.height = con->content_height; | 206 | e->drop_box.height = con->pending.content_height; |
207 | resize_box(&e->drop_box, e->target_edge, thickness); | 207 | resize_box(&e->drop_box, e->target_edge, thickness); |
208 | desktop_damage_box(&e->drop_box); | 208 | desktop_damage_box(&e->drop_box); |
209 | } | 209 | } |
@@ -234,11 +234,11 @@ static void finalize_move(struct sway_seat *seat) { | |||
234 | } | 234 | } |
235 | 235 | ||
236 | struct sway_container *con = e->con; | 236 | struct sway_container *con = e->con; |
237 | struct sway_container *old_parent = con->parent; | 237 | struct sway_container *old_parent = con->pending.parent; |
238 | struct sway_workspace *old_ws = con->workspace; | 238 | struct sway_workspace *old_ws = con->pending.workspace; |
239 | struct sway_node *target_node = e->target_node; | 239 | struct sway_node *target_node = e->target_node; |
240 | struct sway_workspace *new_ws = target_node->type == N_WORKSPACE ? | 240 | struct sway_workspace *new_ws = target_node->type == N_WORKSPACE ? |
241 | target_node->sway_workspace : target_node->sway_container->workspace; | 241 | target_node->sway_workspace : target_node->sway_container->pending.workspace; |
242 | enum wlr_edges edge = e->target_edge; | 242 | enum wlr_edges edge = e->target_edge; |
243 | int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT; | 243 | int after = edge != WLR_EDGE_TOP && edge != WLR_EDGE_LEFT; |
244 | bool swap = edge == WLR_EDGE_NONE && target_node->type == N_CONTAINER; | 244 | bool swap = edge == WLR_EDGE_NONE && target_node->type == N_CONTAINER; |
@@ -285,8 +285,8 @@ static void finalize_move(struct sway_seat *seat) { | |||
285 | int index = list_find(siblings, con); | 285 | int index = list_find(siblings, con); |
286 | struct sway_container *sibling = index == 0 ? | 286 | struct sway_container *sibling = index == 0 ? |
287 | siblings->items[1] : siblings->items[index - 1]; | 287 | siblings->items[1] : siblings->items[index - 1]; |
288 | con->width = sibling->width; | 288 | con->pending.width = sibling->pending.width; |
289 | con->height = sibling->height; | 289 | con->pending.height = sibling->pending.height; |
290 | con->width_fraction = sibling->width_fraction; | 290 | con->width_fraction = sibling->width_fraction; |
291 | con->height_fraction = sibling->height_fraction; | 291 | con->height_fraction = sibling->height_fraction; |
292 | } | 292 | } |