aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/output.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-03-23 17:24:53 -0400
committerLibravatar emersion <contact@emersion.fr>2019-03-23 23:39:42 +0200
commitcd8b4ace926bd5a5289a5d5d6f6dddc1e4732287 (patch)
treec6923a5abb407b59dea0e42364ee988a6c39c3ff /sway/tree/output.c
parentcriteria: fix __focused__ when no focus or unset (diff)
downloadsway-cd8b4ace926bd5a5289a5d5d6f6dddc1e4732287.tar.gz
sway-cd8b4ace926bd5a5289a5d5d6f6dddc1e4732287.tar.zst
sway-cd8b4ace926bd5a5289a5d5d6f6dddc1e4732287.zip
fix opening a floating view on the NOOP output
Since the NOOP output has no size, the minimum floating size is greater than the workspace size for the NOOP output. In this case, the floater gets centered in the output instead of the workspace. However, the NOOP output is not part of the output layout and thus has a NULL box. Attempting to access the properties of this box was causing a segfault. This fixes the issue by just setting the floater's box to all zeroes when mapping on the NOOP output. When the workspace gets moved from the NOOP output to a new output, any floater whose width or height is zero or has an x or y location outside of the output, gets passed to `container_init_floating` again. This will then set the appropriate size and centering. For any floater that has a valid size and location, they are preserved.
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r--sway/tree/output.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 1202ba3c..7867c6bc 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -60,6 +60,27 @@ static void restore_workspaces(struct sway_output *output) {
60 struct sway_workspace *ws = root->noop_output->workspaces->items[0]; 60 struct sway_workspace *ws = root->noop_output->workspaces->items[0];
61 workspace_detach(ws); 61 workspace_detach(ws);
62 output_add_workspace(output, ws); 62 output_add_workspace(output, ws);
63
64 // If the floater was made floating while on the NOOP output, its width
65 // and height will be zero and it should be reinitialized as a floating
66 // container to get the appropriate size and location. Additionally, if
67 // the floater is wider or taller than the output or is completely
68 // outside of the output's bounds, do the same as the output layout has
69 // likely changed and the maximum size needs to be checked and the
70 // floater re-centered
71 for (int i = 0; i < ws->floating->length; i++) {
72 struct sway_container *floater = ws->floating->items[i];
73 if (floater->width == 0 || floater->height == 0 ||
74 floater->width > output->width ||
75 floater->height > output->height ||
76 floater->x > output->lx + output->width ||
77 floater->y > output->ly + output->height ||
78 floater->x + floater->width < output->lx ||
79 floater->y + floater->height < output->ly) {
80 container_init_floating(floater);
81 }
82 }
83
63 ipc_event_workspace(NULL, ws, "move"); 84 ipc_event_workspace(NULL, ws, "move");
64 } 85 }
65 86