diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2024-08-23 01:55:42 +0530 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2024-08-23 01:55:42 +0530 |
| commit | efaf486074509e21fd229290133bc6191db1c312 (patch) | |
| tree | 1f0cb77da08f47ac54c754a20547dd828ae0f580 | |
| parent | 34c865104d180bfb892b86425fd5f888fbe02537 (diff) | |
sway/tree/container: don't trunc coords in `floating_fix_coordinates`
This can cause issues such as the window not being shown at the exact
same coordinates when the old and new wlr_box aren't the same
dimensions and the container is being moved back-and-forth between them.
For example, in the case where a floating window gets moved
from one output to another but the outputs aren't the same resolution.
For e.g. have two displays that aren't the same resolution then:
1. Open a floating window and set it to pos 0,0 on output 2
2. Send it to scratchpad then `scratchpad show` on output 1
3. `scratchpad show` on output 2 again
Observe that the window isn't at 0,0 on output 2 anymore.
(cherry picked from commit 77b9ddabe2a97c5d04c30929b0f8cbde3470fdd7)
| -rw-r--r-- | sway/tree/container.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 80ef34fe..46c388b3 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -773,11 +773,11 @@ void floating_fix_coordinates(struct sway_container *con, struct wlr_box *old, s // Fall back to centering on the workspace. container_floating_move_to_center(con); } else { - int rel_x = con->pending.x - old->x + (con->pending.width / 2); - int rel_y = con->pending.y - old->y + (con->pending.height / 2); + double rel_x = con->pending.x - old->x + (con->pending.width / 2); + double rel_y = con->pending.y - old->y + (con->pending.height / 2); - con->pending.x = new->x + (double)(rel_x * new->width) / old->width - (con->pending.width / 2); - con->pending.y = new->y + (double)(rel_y * new->height) / old->height - (con->pending.height / 2); + con->pending.x = new->x + (rel_x * new->width) / old->width - (con->pending.width / 2); + con->pending.y = new->y + (rel_y * new->height) / old->height - (con->pending.height / 2); sway_log(SWAY_DEBUG, "Transformed container %p to coords (%f, %f)", con, con->pending.x, con->pending.y); } |
