diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-07 09:30:27 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-08 08:48:20 +1000 |
commit | a0649190deaaf093112e99881c25ff550f07e96b (patch) | |
tree | 922fc56dad707ceeebaf6ea3364751e51d764407 /sway/tree/container.c | |
parent | Implement move to workspace on a floating container (diff) | |
download | sway-a0649190deaaf093112e99881c25ff550f07e96b.tar.gz sway-a0649190deaaf093112e99881c25ff550f07e96b.tar.zst sway-a0649190deaaf093112e99881c25ff550f07e96b.zip |
Fix edge cases when moving floating container to new workspace
* Removes container_floating_move_to_container, instead opting to put
that logic in container_move_to
* In the seat code, focusing a floating view now updates the pending
state only and lets the next transaction carry it over to the current
state. This is required, otherwise it would crash.
* When unfullscreening a floating container, an output check is now done
to see if it should center it.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index f31c152f..4507655e 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1182,7 +1182,7 @@ void container_floating_translate(struct sway_container *con, | |||
1182 | * one, otherwise we'll choose whichever output is closest to the container's | 1182 | * one, otherwise we'll choose whichever output is closest to the container's |
1183 | * center. | 1183 | * center. |
1184 | */ | 1184 | */ |
1185 | static struct sway_container *container_floating_find_output( | 1185 | struct sway_container *container_floating_find_output( |
1186 | struct sway_container *con) { | 1186 | struct sway_container *con) { |
1187 | double center_x = con->x + con->width / 2; | 1187 | double center_x = con->x + con->width / 2; |
1188 | double center_y = con->y + con->height / 2; | 1188 | double center_y = con->y + con->height / 2; |
@@ -1245,39 +1245,6 @@ void container_floating_move_to_center(struct sway_container *con) { | |||
1245 | container_floating_translate(con, new_lx - con->x, new_ly - con->y); | 1245 | container_floating_translate(con, new_lx - con->x, new_ly - con->y); |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | void container_floating_move_to_container(struct sway_container *container, | ||
1249 | struct sway_container *destination) { | ||
1250 | // Resolve destination into a workspace | ||
1251 | struct sway_container *new_ws = NULL; | ||
1252 | if (destination->type == C_OUTPUT) { | ||
1253 | new_ws = output_get_active_workspace(destination->sway_output); | ||
1254 | } else if (destination->type == C_WORKSPACE) { | ||
1255 | new_ws = destination; | ||
1256 | } else { | ||
1257 | new_ws = container_parent(destination, C_WORKSPACE); | ||
1258 | } | ||
1259 | if (!new_ws) { | ||
1260 | // This can happen if the user has run "move container to mark foo", | ||
1261 | // where mark foo is on a hidden scratchpad container. | ||
1262 | return; | ||
1263 | } | ||
1264 | struct sway_container *old_ws = container_parent(container, C_WORKSPACE); | ||
1265 | if (old_ws != new_ws) { | ||
1266 | container_remove_child(container); | ||
1267 | container_add_child(new_ws->sway_workspace->floating, container); | ||
1268 | arrange_windows(old_ws); | ||
1269 | arrange_windows(new_ws); | ||
1270 | workspace_detect_urgent(old_ws); | ||
1271 | workspace_detect_urgent(new_ws); | ||
1272 | } | ||
1273 | // If the container's center doesn't overlap the new workspace, center it | ||
1274 | // within the workspace. | ||
1275 | struct sway_container *output = container_floating_find_output(container); | ||
1276 | if (new_ws->parent != output) { | ||
1277 | container_floating_move_to_center(container); | ||
1278 | } | ||
1279 | } | ||
1280 | |||
1281 | void container_set_dirty(struct sway_container *container) { | 1248 | void container_set_dirty(struct sway_container *container) { |
1282 | if (container->dirty) { | 1249 | if (container->dirty) { |
1283 | return; | 1250 | return; |
@@ -1357,6 +1324,11 @@ void container_set_fullscreen(struct sway_container *container, bool enable) { | |||
1357 | container->y = container->saved_y; | 1324 | container->y = container->saved_y; |
1358 | container->width = container->saved_width; | 1325 | container->width = container->saved_width; |
1359 | container->height = container->saved_height; | 1326 | container->height = container->saved_height; |
1327 | struct sway_container *output = | ||
1328 | container_floating_find_output(container); | ||
1329 | if (!container_has_ancestor(container, output)) { | ||
1330 | container_floating_move_to_center(container); | ||
1331 | } | ||
1360 | } else { | 1332 | } else { |
1361 | container->width = container->saved_width; | 1333 | container->width = container->saved_width; |
1362 | container->height = container->saved_height; | 1334 | container->height = container->saved_height; |