aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/arrange.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-23 11:36:16 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-23 11:36:16 +1000
commit64445f421452b841eb124f7f89e06084b05b1a54 (patch)
tree46b3bd642ce0e09a2a048fe85224494daec1a80c /sway/tree/arrange.c
parentMerge pull request #2688 from RyanDwyer/exec-commands-without-focus (diff)
downloadsway-64445f421452b841eb124f7f89e06084b05b1a54.tar.gz
sway-64445f421452b841eb124f7f89e06084b05b1a54.tar.zst
sway-64445f421452b841eb124f7f89e06084b05b1a54.zip
Prevent sticky containers from jumping on workspace switch
If you have swaybar docked to the top, and you create a floating sticky container and switch workspaces on the same output, the sticky container would move down by the height of swaybar on each switch. This happens because when creating the workspace we set the dimensions to the same as the output, then the subsequent arrange corrects it. During this arrange, floating containers are translated so they stay relative to the workspace. This translation needs to not occur for the initial arrange. This patch makes workspaces have a zero width and height when first created, so we can detect whether this is the initial arrange and avoid translating the floating containers if so.
Diffstat (limited to 'sway/tree/arrange.c')
-rw-r--r--sway/tree/arrange.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index d50be25d..373460a2 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -186,6 +186,7 @@ void arrange_workspace(struct sway_workspace *workspace) {
186 area->width, area->height, area->x, area->y); 186 area->width, area->height, area->x, area->y);
187 workspace_remove_gaps(workspace); 187 workspace_remove_gaps(workspace);
188 188
189 bool first_arrange = workspace->width == 0 && workspace->height == 0;
189 double prev_x = workspace->x; 190 double prev_x = workspace->x;
190 double prev_y = workspace->y; 191 double prev_y = workspace->y;
191 workspace->width = area->width; 192 workspace->width = area->width;
@@ -196,7 +197,7 @@ void arrange_workspace(struct sway_workspace *workspace) {
196 // Adjust any floating containers 197 // Adjust any floating containers
197 double diff_x = workspace->x - prev_x; 198 double diff_x = workspace->x - prev_x;
198 double diff_y = workspace->y - prev_y; 199 double diff_y = workspace->y - prev_y;
199 if (diff_x != 0 || diff_y != 0) { 200 if (!first_arrange && (diff_x != 0 || diff_y != 0)) {
200 for (int i = 0; i < workspace->floating->length; ++i) { 201 for (int i = 0; i < workspace->floating->length; ++i) {
201 struct sway_container *floater = workspace->floating->items[i]; 202 struct sway_container *floater = workspace->floating->items[i];
202 container_floating_translate(floater, diff_x, diff_y); 203 container_floating_translate(floater, diff_x, diff_y);