diff --git a/src/draw.c b/src/draw.c index 17f24b9..6d40a02 100644 --- a/src/draw.c +++ b/src/draw.c @@ -26,7 +26,7 @@ typedef struct { char *text; PangoAttrList *attr; cairo_surface_t *icon; - notification *n; + const notification *n; } colored_layout; window_x11 *win; @@ -245,7 +245,7 @@ static PangoLayout *layout_create(cairo_t *c) return layout; } -static colored_layout *layout_init_shared(cairo_t *c, notification *n) +static colored_layout *layout_init_shared(cairo_t *c, const notification *n) { colored_layout *cl = g_malloc(sizeof(colored_layout)); cl->l = layout_create(c); @@ -301,7 +301,7 @@ static colored_layout *layout_init_shared(cairo_t *c, notification *n) return cl; } -static colored_layout *layout_derive_xmore(cairo_t *c, notification *n, int qlen) +static colored_layout *layout_derive_xmore(cairo_t *c, const notification *n, int qlen) { colored_layout *cl = layout_init_shared(c, n); cl->text = g_strdup_printf("(%d more)", qlen); @@ -350,12 +350,10 @@ static GSList *create_layouts(cairo_t *c) int qlen = queues_length_waiting(); bool xmore_is_needed = qlen > 0 && settings.indicate_hidden; - notification *last = NULL; for (const GList *iter = queues_get_displayed(); iter; iter = iter->next) { notification *n = iter->data; - last = n; notification_update_text_to_render(n); @@ -371,7 +369,7 @@ static GSList *create_layouts(cairo_t *c) if (xmore_is_needed && settings.geometry.h != 1) { /* append xmore message as new message */ layouts = g_slist_append(layouts, - layout_derive_xmore(c, last, qlen)); + layout_derive_xmore(c, queues_get_head_waiting(), qlen)); } return layouts; diff --git a/src/queues.c b/src/queues.c index dbca601..d6a17a9 100644 --- a/src/queues.c +++ b/src/queues.c @@ -49,6 +49,14 @@ const GList *queues_get_displayed(void) return g_queue_peek_head_link(displayed); } +/* see queues.h */ +const notification *queues_get_head_waiting(void) +{ + if (waiting->length == 0) + return NULL; + return g_queue_peek_head(waiting); +} + /* see queues.h */ unsigned int queues_length_waiting(void) { diff --git a/src/queues.h b/src/queues.h index 4f4dc64..1e185d7 100644 --- a/src/queues.h +++ b/src/queues.h @@ -25,6 +25,13 @@ void queues_init(void); */ const GList *queues_get_displayed(void); +/** + * Get the highest notification in line + * + * @return a notification or NULL, if waiting is empty + */ +const notification *queues_get_head_waiting(void); + /** * Returns the current amount of notifications, * which are waiting to get displayed