aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-03-11 22:21:38 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-03-11 21:31:47 -0600
commit1bab5a95531826fa54097bed48f8cc05d4233a9f (patch)
tree54b6492e55a28ccacfc45fa2be53145234e7ba3a /sway/ipc-json.c
parentRepair swaynag crash reading message from stdin (diff)
downloadsway-1bab5a95531826fa54097bed48f8cc05d4233a9f.tar.gz
sway-1bab5a95531826fa54097bed48f8cc05d4233a9f.tar.zst
sway-1bab5a95531826fa54097bed48f8cc05d4233a9f.zip
get_deco_rect: fix floaters on tabbed/stacked ws
This fixes the decoration rects for floating containers on a workspace that is either tabbed or stacked. Without this, the floater would incorrectly try to calculate where it's tab or stack decorations were on the workspace. This would cause a SIGFPE (due to a divide-by-zero) when the floater was on a tabbed workspace without any tiling children. Furthermore, the floater does not care what the workspace's layout is and should just use the location relative to the workspace. This should have no effect on children of a floating container.
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index bebe6dd7..f61e1a8c 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -352,8 +352,9 @@ static void ipc_json_describe_workspace(struct sway_workspace *workspace,
352 352
353static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { 353static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
354 enum sway_container_layout parent_layout = container_parent_layout(c); 354 enum sway_container_layout parent_layout = container_parent_layout(c);
355 if ((parent_layout != L_TABBED && parent_layout != L_STACKED && 355 bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED;
356 c->current.border != B_NORMAL) || 356 if (((!tab_or_stack || container_is_floating(c)) &&
357 c->current.border != B_NORMAL) ||
357 c->fullscreen_mode != FULLSCREEN_NONE || 358 c->fullscreen_mode != FULLSCREEN_NONE ||
358 c->workspace == NULL) { 359 c->workspace == NULL) {
359 deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0; 360 deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0;
@@ -370,17 +371,19 @@ static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
370 deco_rect->width = c->width; 371 deco_rect->width = c->width;
371 deco_rect->height = container_titlebar_height(); 372 deco_rect->height = container_titlebar_height();
372 373
373 if (parent_layout == L_TABBED) { 374 if (!container_is_floating(c)) {
374 deco_rect->width = c->parent 375 if (parent_layout == L_TABBED) {
375 ? c->parent->width / c->parent->children->length 376 deco_rect->width = c->parent
376 : c->workspace->width / c->workspace->tiling->length; 377 ? c->parent->width / c->parent->children->length
377 deco_rect->x += deco_rect->width * container_sibling_index(c); 378 : c->workspace->width / c->workspace->tiling->length;
378 } else if (container_parent_layout(c) == L_STACKED) { 379 deco_rect->x += deco_rect->width * container_sibling_index(c);
379 if (!c->view) { 380 } else if (parent_layout == L_STACKED) {
380 size_t siblings = container_get_siblings(c)->length; 381 if (!c->view) {
381 deco_rect->y -= deco_rect->height * siblings; 382 size_t siblings = container_get_siblings(c)->length;
383 deco_rect->y -= deco_rect->height * siblings;
384 }
385 deco_rect->y += deco_rect->height * container_sibling_index(c);
382 } 386 }
383 deco_rect->y += deco_rect->height * container_sibling_index(c);
384 } 387 }
385} 388}
386 389