change separator to be a solid line at the bottom

This commit is contained in:
Sascha Kruse 2012-09-09 10:19:58 +02:00
parent 28e6f27060
commit c3767d1a7b
3 changed files with 16 additions and 42 deletions

View File

@ -22,9 +22,7 @@ int verbosity = 0;
int word_wrap = False; int word_wrap = False;
int line_height = 0; /* if line height < font height, it will be raised to font height */ int line_height = 0; /* if line height < font height, it will be raised to font height */
int separator_enabled = False; int separator_height = 2; /* height of the separator line between two notifications */
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 */ enum separator_color sep_color = AUTO; /* AUTO or FOREGROUND */

38
dunst.c
View File

@ -573,12 +573,6 @@ void draw_win(void)
line_cnt += n->draw_txt_buf.line_count; 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 we have a dynamic width, calculate the actual width */
if (width == 0) { if (width == 0) {
for (l_node * iter = displayed_notifications->head; iter; for (l_node * iter = displayed_notifications->head; iter;
@ -601,6 +595,9 @@ void draw_win(void)
height = MAX(geometry.h, (line_cnt * line_height)); height = MAX(geometry.h, (line_cnt * line_height));
} }
height += (l_length(displayed_notifications) - 1) * separator_height;
/* add "(x more)" */ /* add "(x more)" */
draw_txt x_more; draw_txt x_more;
x_more.txt = NULL; x_more.txt = NULL;
@ -664,24 +661,16 @@ void draw_win(void)
} }
/* draw separator */ /* draw separator */
if (separator_enabled && line_cnt > 1) { if (separator_height > 0) {
dc->x = 0; dc -> x = 0;
drawrect(dc, 0, 0, width, line_height, True, n->colors->BG);
double color; double color;
if (sep_color == AUTO) if (sep_color == AUTO)
color = calculate_foreground_color(n->colors->BG); color = calculate_foreground_color(n->colors->BG);
else else
color = n->colors->FG; color = n->colors->FG;
int new_y = dc->y + line_height; drawrect(dc, 0, 0, width, separator_height, True, color);
int sep_height = line_height * separator_height; dc->y += 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);
dc->y = new_y;
} }
} }
@ -1571,16 +1560,9 @@ dunst_ini_handle(void *user_data, const char *section,
show_age_threshold = atoi(value); show_age_threshold = atoi(value);
else if (strcmp(name, "sticky_history") == 0) else if (strcmp(name, "sticky_history") == 0)
sticky_history = dunst_ini_get_boolean(value); sticky_history = dunst_ini_get_boolean(value);
else if (strcmp(name, "separator_height") == 0)
separator_height = atoi(value);
} else if (strcmp(section, "separator") == 0) { if (strcmp(name, "separator_color") == 0) {
if (strcmp(name, "enable") == 0)
separator_enabled = dunst_ini_get_boolean(value);
if (strcmp(name, "width") == 0)
separator_width = strtod(value, NULL);
if (strcmp(name, "height") == 0)
separator_height = strtod(value, NULL);
if (strcmp(name, "color") == 0) {
char *str = dunst_ini_get_string(value); char *str = dunst_ini_get_string(value);
if (strcmp(str, "auto") == 0) if (strcmp(str, "auto") == 0)
sep_color = AUTO; sep_color = AUTO;

16
dunstrc
View File

@ -66,19 +66,13 @@
# it will get raised to the font height. # it will get raised to the font height.
line_height = 0 line_height = 0
[separator] # height of the separator line in pixels (Set to 0 to disable)
separator_height = 2;
#enable drawing of separator line # This can either be "auto" or "foreground". "Auto" tries to find a color
enable = no # that fits nicely to the background color.
separator_color = auto
#width of separator line in relation to window width
width = 0.8
#height of separator line in relation to line height
height = 0.3
# color can either be "foreground" to use the foreground color or
# "auto" to generate a fitting color depending on the background color
color = auto
[shortcuts] [shortcuts]
# shortcuts are specified as [modifier+][modifier+]...key # shortcuts are specified as [modifier+][modifier+]...key