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.
master
Brian Ashworth 6 years ago committed by Drew DeVault
parent 79369681ab
commit 1bab5a9553

@ -352,7 +352,8 @@ static void ipc_json_describe_workspace(struct sway_workspace *workspace,
static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
enum sway_container_layout parent_layout = container_parent_layout(c); enum sway_container_layout parent_layout = container_parent_layout(c);
if ((parent_layout != L_TABBED && parent_layout != L_STACKED && bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED;
if (((!tab_or_stack || container_is_floating(c)) &&
c->current.border != B_NORMAL) || c->current.border != B_NORMAL) ||
c->fullscreen_mode != FULLSCREEN_NONE || c->fullscreen_mode != FULLSCREEN_NONE ||
c->workspace == NULL) { c->workspace == NULL) {
@ -370,12 +371,13 @@ static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
deco_rect->width = c->width; deco_rect->width = c->width;
deco_rect->height = container_titlebar_height(); deco_rect->height = container_titlebar_height();
if (!container_is_floating(c)) {
if (parent_layout == L_TABBED) { if (parent_layout == L_TABBED) {
deco_rect->width = c->parent deco_rect->width = c->parent
? c->parent->width / c->parent->children->length ? c->parent->width / c->parent->children->length
: c->workspace->width / c->workspace->tiling->length; : c->workspace->width / c->workspace->tiling->length;
deco_rect->x += deco_rect->width * container_sibling_index(c); deco_rect->x += deco_rect->width * container_sibling_index(c);
} else if (container_parent_layout(c) == L_STACKED) { } else if (parent_layout == L_STACKED) {
if (!c->view) { if (!c->view) {
size_t siblings = container_get_siblings(c)->length; size_t siblings = container_get_siblings(c)->length;
deco_rect->y -= deco_rect->height * siblings; deco_rect->y -= deco_rect->height * siblings;
@ -383,6 +385,7 @@ static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
deco_rect->y += deco_rect->height * container_sibling_index(c); deco_rect->y += deco_rect->height * container_sibling_index(c);
} }
} }
}
static void ipc_json_describe_view(struct sway_container *c, json_object *object) { static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
json_object_object_add(object, "pid", json_object_new_int(c->view->pid)); json_object_object_add(object, "pid", json_object_new_int(c->view->pid));

Loading…
Cancel
Save