diff --git a/src/draw.c b/src/draw.c index d74b637c4..2647f53e8 100644 --- a/src/draw.c +++ b/src/draw.c @@ -245,15 +245,15 @@ static struct dimensions calculate_notification_dimensions(struct colored_layout dim.h += progress_bar_height; dim.w = dim.text_width + icon_width + 2 * settings.h_padding; + if (have_progress_bar(cl)) + dim.w = MAX(settings.progress_bar_min_width, dim.w); + dim.h = MIN(settings.height.max, dim.h + settings.padding * 2); dim.h = MAX(settings.height.min, dim.h); dim.w = MAX(settings.width.min, dim.w); dim.w = MIN(settings.width.max, dim.w); - if (have_progress_bar(cl)) - dim.w = MAX(settings.progress_bar_min_width, dim.w); - cl->n->displayed_height = dim.h; return dim; } @@ -711,7 +711,7 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width, int // alignment work correctly layout_setup(cl, width, height, scale); - // NOTE: Includes the last padding + // NOTE: Includes paddings! int h_without_progress_bar = height; if (have_progress_bar(cl)) { h_without_progress_bar -= settings.progress_bar_height + settings.padding; @@ -727,7 +727,7 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width, int text_y = settings.padding; if (settings.vertical_alignment == VERTICAL_CENTER) { - text_y += h_without_progress_bar / 2 - text_h / 2; + text_y = h_without_progress_bar / 2 - text_h / 2; } else if (settings.vertical_alignment == VERTICAL_BOTTOM) { text_y = h_without_progress_bar - settings.padding - text_h; } // else VERTICAL_TOP @@ -765,6 +765,9 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width, int break; } + if (image_y < settings.padding || image_y > h_without_progress_bar) + image_y = settings.padding; + // icon position if (cl->n->icon_position == ICON_TOP) { image_x = (width - image_width) / 2; diff --git a/test/functional-tests/dunstrc.vertical_align b/test/functional-tests/dunstrc.vertical_align index f16b3e062..b451c01f8 100644 --- a/test/functional-tests/dunstrc.vertical_align +++ b/test/functional-tests/dunstrc.vertical_align @@ -33,6 +33,18 @@ category = .*icon-top.* icon_position = top +[alignment-left] + category = .*alignment-left.* + alignment = left + +[alignment-right] + category = .*alignment-right.* + alignment = right + +[alignment-center] + category = .*alignment-center.* + alignment = center + [global] icon_path = /usr/share/icons/Papirus/24x24/status/:/usr/share/icons/Papirus/24x24/devices/:/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ enable_posix_regex = yes diff --git a/test/functional-tests/test.sh b/test/functional-tests/test.sh index 27c02d553..4a59ae918 100755 --- a/test/functional-tests/test.sh +++ b/test/functional-tests/test.sh @@ -296,10 +296,10 @@ function dynamic_height { tmp_dunstrc dunstrc.vertical_align "height = ($min, $max)" start_dunst dunstrc.tmp - $DUNSTIFY -a "dunst tester" -u l "text" "height min = $min"$'\n'"height max = $max" - $DUNSTIFY -a "dunst tester" -h int:value:$((RANDOM%100)) -u l "text+ progress bar" "height min = $min"$'\n'"height max = $max" - $DUNSTIFY -a "dunst tester" -u n "text + icon" "height min = $min"$'\n'"height max = $max" - $DUNSTIFY -a "dunst tester" -h int:value:$((RANDOM%100)) -u n "text + icon + progress bar" "height min = $min"$'\n'"height max = $max" + $DUNSTIFY -a "dunst tester" -u l "text" "height min = $min, max = $max" + $DUNSTIFY -a "dunst tester" -h int:value:$((RANDOM%100)) -u l "text + progress bar" "height min = $min, max = $max" + $DUNSTIFY -a "dunst tester" -u n "text + icon" "height min = $min, max = $max" + $DUNSTIFY -a "dunst tester" -h int:value:$((RANDOM%100)) -u n "text + icon + progress bar" "height min = $min, max = $max" $DUNSTIFY -a "dunst tester" -h string:category:hide -u l "text hidden" "SHOULD BE NOT VISIBLE" $DUNSTIFY -a "dunst tester" -h string:category:hide -h int:value:$((RANDOM%100)) -u l "text hidden + progress bar" "SHOULD BE NOT VISIBLE"