aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorAnkit Pandey <anpandey@protonmail.com>2022-12-11 16:44:48 -0800
committerRonan Pigott <ronan@rjp.ie>2023-03-14 23:26:42 -0700
commit90c2d631e2dc4c7633bb8fcd92f300a4a2dffb86 (patch)
tree218db72a61c8e7b55cf39d241e51ee0780636670 /sway/commands
parentebeed7e303110403cc0134a1927008998caa8d96 (diff)
root: Try to preserve relative positions of floating containers
This makes the behavior of floating containers more consistent with i3. The coordinates of the container are scaled when the size of the workspace it is on changes or when the container is moved between workspaces on different outputs. For scratchpad containers, add a new state that preserves the dimensions of the last output the window appeared on. This is necessary because after a container is hidden in the scratchpad, we expect it to be in the same relative position on the output when it reappears. We can't just use the container's attached workspace because that workspace's dimensions might have been changed or the workspace as a whole could have been destroyed.
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/move.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 7bd1fe3e..9e40a3b4 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -206,9 +206,17 @@ static void container_move_to_workspace(struct sway_container *container,
container_detach(container);
workspace_add_floating(workspace, container);
container_handle_fullscreen_reparent(container);
- // If changing output, center it within the workspace
+ // If changing output, adjust the coordinates of the window.
if (old_output != workspace->output && !container->pending.fullscreen_mode) {
- container_floating_move_to_center(container);
+ struct wlr_box workspace_box, old_workspace_box;
+ workspace_get_box(workspace, &workspace_box);
+ workspace_get_box(old_workspace, &old_workspace_box);
+ floating_fix_coordinates(container, &old_workspace_box, &workspace_box);
+ if (container->scratchpad && workspace->output) {
+ struct wlr_box output_box;
+ output_get_box(workspace->output, &output_box);
+ container->transform = workspace_box;
+ }
}
} else {
container_detach(container);