aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/arrange.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-22 17:46:12 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-22 17:46:12 +1000
commite1d5dc08048d8b0ef739302ee58bdc8642b44f13 (patch)
tree3df1787ec9350bc5edf1d9ca8643de4d9f7abbbe /sway/tree/arrange.c
parentMerge pull request #2505 from RyanDwyer/fix-set-fullscreen (diff)
downloadsway-e1d5dc08048d8b0ef739302ee58bdc8642b44f13.tar.gz
sway-e1d5dc08048d8b0ef739302ee58bdc8642b44f13.tar.zst
sway-e1d5dc08048d8b0ef739302ee58bdc8642b44f13.zip
Translate floating containers when a workspace is moved
When a workspace is moved to another output, or the output it's on changes its global layout position, the floating containers on that workspace should be translated by the same amount as the workspace. This keeps the floating containers in the same position relative to the workspace. A check is done to make sure the floating container's center point isn't being moved off screen. If it is, it is centered within the workspace. Fixes part of #2500.
Diffstat (limited to 'sway/tree/arrange.c')
-rw-r--r--sway/tree/arrange.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index cf4a5d9a..a4b058f3 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -206,10 +206,30 @@ static void arrange_workspace(struct sway_container *workspace) {
206 wlr_log(WLR_DEBUG, "Usable area for ws: %dx%d@%d,%d", 206 wlr_log(WLR_DEBUG, "Usable area for ws: %dx%d@%d,%d",
207 area->width, area->height, area->x, area->y); 207 area->width, area->height, area->x, area->y);
208 remove_gaps(workspace); 208 remove_gaps(workspace);
209
210 double prev_x = workspace->x;
211 double prev_y = workspace->y;
209 workspace->width = area->width; 212 workspace->width = area->width;
210 workspace->height = area->height; 213 workspace->height = area->height;
211 workspace->x = output->x + area->x; 214 workspace->x = output->x + area->x;
212 workspace->y = output->y + area->y; 215 workspace->y = output->y + area->y;
216
217 // Adjust any floating containers
218 double diff_x = workspace->x - prev_x;
219 double diff_y = workspace->y - prev_y;
220 for (int i = 0; i < workspace->sway_workspace->floating->length; ++i) {
221 struct sway_container *floater =
222 workspace->sway_workspace->floating->items[i];
223 container_floating_translate(floater, diff_x, diff_y);
224 double center_x = floater->x + floater->width / 2;
225 double center_y = floater->y + floater->height / 2;
226 struct wlr_box workspace_box;
227 container_get_box(workspace, &workspace_box);
228 if (!wlr_box_contains_point(&workspace_box, center_x, center_y)) {
229 container_floating_move_to_center(floater);
230 }
231 }
232
213 add_gaps(workspace); 233 add_gaps(workspace);
214 container_set_dirty(workspace); 234 container_set_dirty(workspace);
215 wlr_log(WLR_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, 235 wlr_log(WLR_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name,