diff options
Diffstat (limited to 'sway/tree/arrange.c')
-rw-r--r-- | sway/tree/arrange.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index 4aa82c35..d4003fe6 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
2 | #include <ctype.h> | 1 | #include <ctype.h> |
3 | #include <stdbool.h> | 2 | #include <stdbool.h> |
4 | #include <stdlib.h> | 3 | #include <stdlib.h> |
@@ -264,6 +263,9 @@ void arrange_workspace(struct sway_workspace *workspace) { | |||
264 | area->width, area->height, area->x, area->y); | 263 | area->width, area->height, area->x, area->y); |
265 | 264 | ||
266 | bool first_arrange = workspace->width == 0 && workspace->height == 0; | 265 | bool first_arrange = workspace->width == 0 && workspace->height == 0; |
266 | struct wlr_box prev_box; | ||
267 | workspace_get_box(workspace, &prev_box); | ||
268 | |||
267 | double prev_x = workspace->x - workspace->current_gaps.left; | 269 | double prev_x = workspace->x - workspace->current_gaps.left; |
268 | double prev_y = workspace->y - workspace->current_gaps.top; | 270 | double prev_y = workspace->y - workspace->current_gaps.top; |
269 | workspace->width = area->width; | 271 | workspace->width = area->width; |
@@ -277,13 +279,14 @@ void arrange_workspace(struct sway_workspace *workspace) { | |||
277 | if (!first_arrange && (diff_x != 0 || diff_y != 0)) { | 279 | if (!first_arrange && (diff_x != 0 || diff_y != 0)) { |
278 | for (int i = 0; i < workspace->floating->length; ++i) { | 280 | for (int i = 0; i < workspace->floating->length; ++i) { |
279 | struct sway_container *floater = workspace->floating->items[i]; | 281 | struct sway_container *floater = workspace->floating->items[i]; |
280 | container_floating_translate(floater, diff_x, diff_y); | ||
281 | double center_x = floater->pending.x + floater->pending.width / 2; | ||
282 | double center_y = floater->pending.y + floater->pending.height / 2; | ||
283 | struct wlr_box workspace_box; | 282 | struct wlr_box workspace_box; |
284 | workspace_get_box(workspace, &workspace_box); | 283 | workspace_get_box(workspace, &workspace_box); |
285 | if (!wlr_box_contains_point(&workspace_box, center_x, center_y)) { | 284 | floating_fix_coordinates(floater, &prev_box, &workspace_box); |
286 | container_floating_move_to_center(floater); | 285 | // Set transformation for scratchpad windows. |
286 | if (floater->scratchpad) { | ||
287 | struct wlr_box output_box; | ||
288 | output_get_box(output, &output_box); | ||
289 | floater->transform = output_box; | ||
287 | } | 290 | } |
288 | } | 291 | } |
289 | } | 292 | } |
@@ -311,12 +314,13 @@ void arrange_output(struct sway_output *output) { | |||
311 | if (config->reloading) { | 314 | if (config->reloading) { |
312 | return; | 315 | return; |
313 | } | 316 | } |
314 | const struct wlr_box *output_box = wlr_output_layout_get_box( | 317 | struct wlr_box output_box; |
315 | root->output_layout, output->wlr_output); | 318 | wlr_output_layout_get_box(root->output_layout, |
316 | output->lx = output_box->x; | 319 | output->wlr_output, &output_box); |
317 | output->ly = output_box->y; | 320 | output->lx = output_box.x; |
318 | output->width = output_box->width; | 321 | output->ly = output_box.y; |
319 | output->height = output_box->height; | 322 | output->width = output_box.width; |
323 | output->height = output_box.height; | ||
320 | 324 | ||
321 | for (int i = 0; i < output->workspaces->length; ++i) { | 325 | for (int i = 0; i < output->workspaces->length; ++i) { |
322 | struct sway_workspace *workspace = output->workspaces->items[i]; | 326 | struct sway_workspace *workspace = output->workspaces->items[i]; |
@@ -328,12 +332,12 @@ void arrange_root(void) { | |||
328 | if (config->reloading) { | 332 | if (config->reloading) { |
329 | return; | 333 | return; |
330 | } | 334 | } |
331 | const struct wlr_box *layout_box = | 335 | struct wlr_box layout_box; |
332 | wlr_output_layout_get_box(root->output_layout, NULL); | 336 | wlr_output_layout_get_box(root->output_layout, NULL, &layout_box); |
333 | root->x = layout_box->x; | 337 | root->x = layout_box.x; |
334 | root->y = layout_box->y; | 338 | root->y = layout_box.y; |
335 | root->width = layout_box->width; | 339 | root->width = layout_box.width; |
336 | root->height = layout_box->height; | 340 | root->height = layout_box.height; |
337 | 341 | ||
338 | if (root->fullscreen_global) { | 342 | if (root->fullscreen_global) { |
339 | struct sway_container *fs = root->fullscreen_global; | 343 | struct sway_container *fs = root->fullscreen_global; |