From 2c917a8c3453ec54a80581d82bc8a520e822bd56 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 22 Feb 2021 19:33:08 +0100 Subject: [PATCH] container: Add container_is_current_floating Needed to check if containers are currently floating from render code, as container_is_floating checks pending state. --- include/sway/tree/container.h | 7 +++++++ sway/desktop/render.c | 4 ++-- sway/tree/container.c | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index ff3f9599e..5c368df26 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -210,9 +210,16 @@ void container_set_geometry_from_content(struct sway_container *con); /** * Determine if the given container is itself floating. * This will return false for any descendants of a floating container. + * + * Uses pending container state. */ bool container_is_floating(struct sway_container *container); +/** + * Same as above, but for current container state. + */ +bool container_is_current_floating(struct sway_container *container); + /** * Get a container's box in layout coordinates. */ diff --git a/sway/desktop/render.c b/sway/desktop/render.c index ce90eae01..f314db731 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -359,7 +359,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, container_current_parent_layout(con); if (state->border_right) { - if (!container_is_floating(con) && siblings->length == 1 && layout == L_HORIZ) { + if (!container_is_current_floating(con) && siblings->length == 1 && layout == L_HORIZ) { memcpy(&color, colors->indicator, sizeof(float) * 4); } else { memcpy(&color, colors->child_border, sizeof(float) * 4); @@ -374,7 +374,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, } if (state->border_bottom) { - if (!container_is_floating(con) && siblings->length == 1 && layout == L_VERT) { + if (!container_is_current_floating(con) && siblings->length == 1 && layout == L_VERT) { memcpy(&color, colors->indicator, sizeof(float) * 4); } else { memcpy(&color, colors->child_border, sizeof(float) * 4); diff --git a/sway/tree/container.c b/sway/tree/container.c index 8c8dfb3b1..79c232748 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -858,6 +858,17 @@ bool container_is_floating(struct sway_container *container) { return false; } +bool container_is_current_floating(struct sway_container *container) { + if (!container->current.parent && container->current.workspace && + list_find(container->current.workspace->floating, container) != -1) { + return true; + } + if (container->scratchpad) { + return true; + } + return false; +} + void container_get_box(struct sway_container *container, struct wlr_box *box) { box->x = container->pending.x; box->y = container->pending.y;