From 95e722431c986db3e02616b4fb5a8f59764e5a59 Mon Sep 17 00:00:00 2001 From: William McKinnon Date: Sun, 23 Feb 2025 15:39:56 -0500 Subject: [PATCH] fix: border corners appearing when border set to 0 --- sway/desktop/transaction.c | 57 +++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 23311568..f089bf29 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -478,38 +478,43 @@ static void arrange_container(struct sway_container *con, int border_right = con->current.border_right ? border_width : 0; int vert_border_height = MAX(0, height - border_top - border_bottom); - wlr_scene_rect_set_size(con->border.top, width, border_top + corner_radius); - wlr_scene_rect_set_size(con->border.bottom, width, border_bottom + corner_radius); wlr_scene_rect_set_size(con->border.left, border_left, vert_border_height - vert_border_offset - corner_radius); wlr_scene_rect_set_size(con->border.right, border_right, vert_border_height - vert_border_offset - corner_radius); - wlr_scene_rect_set_corner_radius(con->border.top, !has_corner_radius ? 0 : - corner_radius + border_width, CORNER_LOCATION_TOP); - wlr_scene_rect_set_corner_radius(con->border.bottom, !has_corner_radius ? 0 : - corner_radius + border_width, CORNER_LOCATION_BOTTOM); + if (border_top) { + wlr_scene_rect_set_size(con->border.top, width, border_top + corner_radius); + wlr_scene_rect_set_corner_radius(con->border.top, !has_corner_radius ? 0 : + corner_radius + border_width, CORNER_LOCATION_TOP); + wlr_scene_rect_set_clipped_region(con->border.top, (struct clipped_region) { + .corner_radius = corner_radius, + .corners = CORNER_LOCATION_TOP, + .area = { + .x = border_width, + .y = border_width, + .width = width - 2 * border_width, + .height = border_top + corner_radius + } + }); + } - wlr_scene_rect_set_clipped_region(con->border.top, (struct clipped_region) { - .corner_radius = corner_radius, - .corners = CORNER_LOCATION_TOP, - .area = { - .x = border_width, - .y = border_width, - .width = width - 2 * border_width, - .height = border_top + corner_radius - } - }); - wlr_scene_rect_set_clipped_region(con->border.bottom, (struct clipped_region) { - .corner_radius = corner_radius, - .corners = CORNER_LOCATION_BOTTOM, - .area = { - .x = border_width, - .y = 0, - .width = width - 2 * border_width, - .height = border_bottom - border_width + corner_radius, - } - }); + if (border_bottom) { + wlr_scene_rect_set_size(con->border.bottom, width, border_bottom + corner_radius); + wlr_scene_rect_set_corner_radius(con->border.bottom, !has_corner_radius ? 0 : + corner_radius + border_width, CORNER_LOCATION_BOTTOM); + + wlr_scene_rect_set_clipped_region(con->border.bottom, (struct clipped_region) { + .corner_radius = corner_radius, + .corners = CORNER_LOCATION_BOTTOM, + .area = { + .x = border_width, + .y = 0, + .width = width - 2 * border_width, + .height = border_bottom - border_width + corner_radius, + } + }); + } wlr_scene_node_set_position(&con->border.top->node, 0, 0); wlr_scene_node_set_position(&con->border.bottom->node,