From 2c979fe2691be65e000adbbeb5bd452692d80c7c Mon Sep 17 00:00:00 2001 From: Jens Peters Date: Sat, 22 Jun 2024 23:27:37 +0200 Subject: [PATCH] ssd: extend border over squared corners --- src/ssd/ssd-border.c | 69 ++++++++++++++++++++++++++++++++------------ src/ssd/ssd.c | 5 ++-- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/ssd/ssd-border.c b/src/ssd/ssd-border.c index 74f29ffa..63604244 100644 --- a/src/ssd/ssd-border.c +++ b/src/ssd/ssd-border.c @@ -86,6 +86,38 @@ ssd_border_update(struct ssd *ssd) int height = view_effective_height(view, /* use_pending */ false); int full_width = width + 2 * theme->border_width; + /* + * From here on we have to cover the following border scenarios: + * Non-tiled (partial border, rounded corners): + * _____________ + * o oox + * |---------------| + * |_______________| + * + * Tiled (full border, squared corners): + * _______________ + * |o oox| + * |---------------| + * |_______________| + * + * Tiled or non-tiled with zero title height (full boarder, no title): + * _______________ + * |_______________| + */ + + int side_height = ssd->state.was_tiled_not_maximized + ? height + ssd->titlebar.height + : height; + int side_y = ssd->state.was_tiled_not_maximized + ? -ssd->titlebar.height + : 0; + int top_width = ssd->titlebar.height <= 0 || ssd->state.was_tiled_not_maximized + ? full_width + : width - 2 * SSD_BUTTON_WIDTH; + int top_x = ssd->titlebar.height <= 0 || ssd->state.was_tiled_not_maximized + ? 0 + : theme->border_width + SSD_BUTTON_WIDTH; + struct ssd_part *part; struct wlr_scene_rect *rect; struct ssd_sub_tree *subtree; @@ -95,34 +127,35 @@ ssd_border_update(struct ssd *ssd) switch (part->type) { case LAB_SSD_PART_LEFT: wlr_scene_rect_set_size(rect, - theme->border_width, height); + theme->border_width, + side_height); + wlr_scene_node_set_position(part->node, + 0, + side_y); continue; case LAB_SSD_PART_RIGHT: wlr_scene_rect_set_size(rect, - theme->border_width, height); + theme->border_width, + side_height); wlr_scene_node_set_position(part->node, - theme->border_width + width, 0); + theme->border_width + width, + side_y); continue; case LAB_SSD_PART_BOTTOM: wlr_scene_rect_set_size(rect, - full_width, theme->border_width); + full_width, + theme->border_width); wlr_scene_node_set_position(part->node, - 0, height); + 0, + height); continue; case LAB_SSD_PART_TOP: - if (ssd->titlebar.height > 0) { - wlr_scene_rect_set_size(rect, - width - 2 * SSD_BUTTON_WIDTH, - theme->border_width); - wlr_scene_node_set_position(part->node, - theme->border_width + SSD_BUTTON_WIDTH, - -(ssd->titlebar.height + theme->border_width)); - } else { - wlr_scene_rect_set_size(rect, - full_width, theme->border_width); - wlr_scene_node_set_position(part->node, - 0, -theme->border_width); - } + wlr_scene_rect_set_size(rect, + top_width, + theme->border_width); + wlr_scene_node_set_position(part->node, + top_x, + -(ssd->titlebar.height + theme->border_width)); continue; default: continue; diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index 2ed852ec..86ac1272 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -248,8 +248,8 @@ ssd_update_geometry(struct ssd *ssd) } bool maximized = ssd->view->maximized == VIEW_AXIS_BOTH; if (ssd->state.was_maximized != maximized) { - ssd_border_update(ssd); ssd_titlebar_update(ssd); + ssd_border_update(ssd); ssd_shadow_update(ssd); /* * Not strictly necessary as ssd_titlebar_update() @@ -261,14 +261,15 @@ ssd_update_geometry(struct ssd *ssd) bool tiled_and_not_maximized = view_is_tiled(ssd->view) && !maximized; if (ssd->state.was_tiled_not_maximized != tiled_and_not_maximized) { ssd_titlebar_update(ssd); + ssd_border_update(ssd); /* see above about being future proof */ ssd->state.was_tiled_not_maximized = tiled_and_not_maximized; } return; } ssd_extents_update(ssd); - ssd_border_update(ssd); ssd_titlebar_update(ssd); + ssd_border_update(ssd); ssd_shadow_update(ssd); ssd->state.geometry = current; }