container: Add container_is_current_floating

Needed to check if containers are currently floating from render code,
as container_is_floating checks pending state.
This commit is contained in:
Kenny Levinsen 2021-02-22 19:33:08 +01:00 committed by Simon Ser
parent e0a94bee8d
commit 2c917a8c34
3 changed files with 20 additions and 2 deletions

View file

@ -210,9 +210,16 @@ void container_set_geometry_from_content(struct sway_container *con);
/** /**
* Determine if the given container is itself floating. * Determine if the given container is itself floating.
* This will return false for any descendants of a floating container. * This will return false for any descendants of a floating container.
*
* Uses pending container state.
*/ */
bool container_is_floating(struct sway_container *container); 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. * Get a container's box in layout coordinates.
*/ */

View file

@ -359,7 +359,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
container_current_parent_layout(con); container_current_parent_layout(con);
if (state->border_right) { 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); memcpy(&color, colors->indicator, sizeof(float) * 4);
} else { } else {
memcpy(&color, colors->child_border, sizeof(float) * 4); 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 (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); memcpy(&color, colors->indicator, sizeof(float) * 4);
} else { } else {
memcpy(&color, colors->child_border, sizeof(float) * 4); memcpy(&color, colors->child_border, sizeof(float) * 4);

View file

@ -858,6 +858,17 @@ bool container_is_floating(struct sway_container *container) {
return false; 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) { void container_get_box(struct sway_container *container, struct wlr_box *box) {
box->x = container->pending.x; box->x = container->pending.x;
box->y = container->pending.y; box->y = container->pending.y;