From 309ca6f6c73bfa702613d6322e0c508d7030e883 Mon Sep 17 00:00:00 2001 From: sewn Date: Fri, 22 Mar 2024 22:27:45 +0300 Subject: [PATCH] handle icon in minimum width calculation --- render.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/render.c b/render.c index 6c35a15..bf07e86 100644 --- a/render.c +++ b/render.c @@ -104,7 +104,6 @@ static int render_notification(cairo_t *cairo, struct mako_state *state, struct int notif_width = (style->width <= surface->width) ? style->width : surface->width; - // text_x is the offset of the text inside our draw operation double text_x = style->padding.left; if (icon != NULL && style->icon_location == MAKO_ICON_LOCATION_LEFT) { @@ -173,8 +172,15 @@ static int render_notification(cairo_t *cairo, struct mako_state *state, struct int text_height = buffer_text_height / scale; int text_width = buffer_text_width / scale; - notif_width = MAX(style->min_width, text_width + border_size + padding_width); + int min_width = text_width + border_size + padding_width; + if (icon && ! icon_vertical) { + min_width += icon->width; + min_width += style->icon_location == MAKO_ICON_LOCATION_LEFT ? + style->padding.left : style->padding.right; + } + notif_width = MAX(style->min_width, min_width); + // offset_x is for the entire draw operation inside the surface int offset_x; if (surface->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT) {