From 9534cd4d46a9089f26e5d5304899541b728e5e13 Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Sun, 9 Sep 2012 08:55:41 +0200 Subject: [PATCH] configurable total height of separator --- config.def.h | 1 + dunst.c | 32 ++++++++++++++++++-------------- dunstrc | 13 +++++++++---- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/config.def.h b/config.def.h index 2d5e173..bcdf40b 100644 --- a/config.def.h +++ b/config.def.h @@ -23,6 +23,7 @@ int word_wrap = False; int line_height = 0; /* if line height < font height, it will be raised to font height */ int separator_enabled = False; +float separator_total_height = 1; /* height of the complete separator */ float separator_width = 0.7; /* width in relation to window width */ float separator_height = 0.1; /* height in relation to line_height */ enum separator_color sep_color = AUTO; /* AUTO or FOREGROUND */ diff --git a/dunst.c b/dunst.c index e37db52..3d08baa 100644 --- a/dunst.c +++ b/dunst.c @@ -573,12 +573,6 @@ void draw_win(void) line_cnt += n->draw_txt_buf.line_count; } - if (separator_enabled) { - line_cnt += l_length(displayed_notifications) - 1; - if (indicate_hidden && !l_is_empty(notification_queue)) - line_cnt++; - } - /* if we have a dynamic width, calculate the actual width */ if (width == 0) { for (l_node * iter = displayed_notifications->head; iter; @@ -601,6 +595,10 @@ void draw_win(void) height = MAX(geometry.h, (line_cnt * line_height)); } + int separator_total_pix_height = separator_total_height * line_height; + if (separator_enabled) + height += (line_cnt - 1) * separator_total_pix_height; + /* add "(x more)" */ draw_txt x_more; x_more.txt = NULL; @@ -666,7 +664,7 @@ void draw_win(void) /* draw separator */ if (separator_enabled && line_cnt > 1) { dc->x = 0; - drawrect(dc, 0, 0, width, line_height, True, n->colors->BG); + drawrect(dc, 0, 0, width, separator_total_pix_height, True, n->colors->BG); double color; if (sep_color == AUTO) @@ -674,13 +672,17 @@ void draw_win(void) else color = n->colors->FG; - int new_y = dc->y + line_height; - int sep_height = line_height * separator_height; - sep_height = sep_height < 1 ? 1 : sep_height; - int sep_width = width * separator_width; - dc->y = dc->y + (line_height - sep_height) / 2; - dc->x = (width - sep_width) / 2; - drawrect(dc, 0, 0, sep_width, sep_height, True, color); + int new_y = dc->y + separator_total_pix_height; + int sep_pix_height = line_height * separator_height; + + sep_pix_height = sep_pix_height < 1 ? 1 : sep_pix_height; + if (sep_pix_height > separator_total_pix_height) + sep_pix_height = separator_total_pix_height; + + int sep_pix_width = width * separator_width; + dc->y = dc->y + (separator_total_pix_height - sep_pix_height) / 2; + dc->x = (width - sep_pix_width) / 2; + drawrect(dc, 0, 0, sep_pix_width, sep_pix_height, True, color); dc->y = new_y; } } @@ -1580,6 +1582,8 @@ dunst_ini_handle(void *user_data, const char *section, separator_width = strtod(value, NULL); if (strcmp(name, "height") == 0) separator_height = strtod(value, NULL); + if (strcmp(name, "total_height") == 0) + separator_total_height = strtod(value, NULL); if (strcmp(name, "color") == 0) { char *str = dunst_ini_get_string(value); if (strcmp(str, "auto") == 0) diff --git a/dunstrc b/dunstrc index 2532cdd..e5e3875 100644 --- a/dunstrc +++ b/dunstrc @@ -68,13 +68,18 @@ [separator] - #enable drawing of separator line + # Draw a separator between notifications? enable = no - #width of separator line in relation to window width + # total height of the separator in relation to line height + total_height = 0.3 + + # width of the separator decoration width = 0.8 - #height of separator line in relation to line height - height = 0.3 + + # height of the separator decoration + height = 0.8 + # color can either be "foreground" to use the foreground color or # "auto" to generate a fitting color depending on the background color