Use the first waiting notification to generate xmore
Using the last notification from displayed creates confusion about nonexisting notifications.
This commit is contained in:
parent
f14b0b2b4a
commit
4c26ab442a
10
src/draw.c
10
src/draw.c
@ -26,7 +26,7 @@ typedef struct {
|
|||||||
char *text;
|
char *text;
|
||||||
PangoAttrList *attr;
|
PangoAttrList *attr;
|
||||||
cairo_surface_t *icon;
|
cairo_surface_t *icon;
|
||||||
notification *n;
|
const notification *n;
|
||||||
} colored_layout;
|
} colored_layout;
|
||||||
|
|
||||||
window_x11 *win;
|
window_x11 *win;
|
||||||
@ -245,7 +245,7 @@ static PangoLayout *layout_create(cairo_t *c)
|
|||||||
return layout;
|
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));
|
colored_layout *cl = g_malloc(sizeof(colored_layout));
|
||||||
cl->l = layout_create(c);
|
cl->l = layout_create(c);
|
||||||
@ -301,7 +301,7 @@ static colored_layout *layout_init_shared(cairo_t *c, notification *n)
|
|||||||
return cl;
|
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);
|
colored_layout *cl = layout_init_shared(c, n);
|
||||||
cl->text = g_strdup_printf("(%d more)", qlen);
|
cl->text = g_strdup_printf("(%d more)", qlen);
|
||||||
@ -350,12 +350,10 @@ static GSList *create_layouts(cairo_t *c)
|
|||||||
int qlen = queues_length_waiting();
|
int qlen = queues_length_waiting();
|
||||||
bool xmore_is_needed = qlen > 0 && settings.indicate_hidden;
|
bool xmore_is_needed = qlen > 0 && settings.indicate_hidden;
|
||||||
|
|
||||||
notification *last = NULL;
|
|
||||||
for (const GList *iter = queues_get_displayed();
|
for (const GList *iter = queues_get_displayed();
|
||||||
iter; iter = iter->next)
|
iter; iter = iter->next)
|
||||||
{
|
{
|
||||||
notification *n = iter->data;
|
notification *n = iter->data;
|
||||||
last = n;
|
|
||||||
|
|
||||||
notification_update_text_to_render(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) {
|
if (xmore_is_needed && settings.geometry.h != 1) {
|
||||||
/* append xmore message as new message */
|
/* append xmore message as new message */
|
||||||
layouts = g_slist_append(layouts,
|
layouts = g_slist_append(layouts,
|
||||||
layout_derive_xmore(c, last, qlen));
|
layout_derive_xmore(c, queues_get_head_waiting(), qlen));
|
||||||
}
|
}
|
||||||
|
|
||||||
return layouts;
|
return layouts;
|
||||||
|
@ -49,6 +49,14 @@ const GList *queues_get_displayed(void)
|
|||||||
return g_queue_peek_head_link(displayed);
|
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 */
|
/* see queues.h */
|
||||||
unsigned int queues_length_waiting(void)
|
unsigned int queues_length_waiting(void)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,13 @@ void queues_init(void);
|
|||||||
*/
|
*/
|
||||||
const GList *queues_get_displayed(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,
|
* Returns the current amount of notifications,
|
||||||
* which are waiting to get displayed
|
* which are waiting to get displayed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user