diff --git a/CHANGELOG.md b/CHANGELOG.md index 71f89c1..14b684b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - `fullscreen` rule to hide notifications when a fullscreen window is active - When new notifications arrive, but display is full, important notifications don't have to wait for a timeout in a displayed notification (#541) +- ` more` notifications don't occupy space anymore, if there is only a single + notification waiting to get displayed. The notification gets displayed directly (#467) ## 1.3.2 - 2018-05-06 diff --git a/src/queues.c b/src/queues.c index 600a3e7..dbca601 100644 --- a/src/queues.c +++ b/src/queues.c @@ -30,7 +30,6 @@ static GQueue *waiting = NULL; /**< all new notifications get into here */ static GQueue *displayed = NULL; /**< currently displayed notifications */ static GQueue *history = NULL; /**< history of displayed notifications */ -unsigned int displayed_limit = 0; int next_notification_id = 1; bool pause_displayed = false; @@ -44,12 +43,6 @@ void queues_init(void) waiting = g_queue_new(); } -/* see queues.h */ -void queues_displayed_limit(unsigned int limit) -{ - displayed_limit = limit; -} - /* see queues.h */ const GList *queues_get_displayed(void) { @@ -353,13 +346,23 @@ void queues_update(bool fullscreen) } } + int cur_displayed_limit; + if (settings.geometry.h == 0) + cur_displayed_limit = INT_MAX; + else if ( settings.indicate_hidden + && settings.geometry.h > 1 + && displayed->length + waiting->length > settings.geometry.h) + cur_displayed_limit = settings.geometry.h-1; + else + cur_displayed_limit = settings.geometry.h; + /* move notifications from queue to displayed */ GList *iter = g_queue_peek_head_link(waiting); while (iter) { notification *n = iter->data; GList *nextiter = iter->next; - if (displayed_limit > 0 && displayed->length >= displayed_limit) { + if (displayed->length >= cur_displayed_limit) { /* the list is full */ break; } @@ -382,6 +385,12 @@ void queues_update(bool fullscreen) iter = nextiter; } + /* if necessary, push the overhanging notifications from displayed to waiting again */ + while (displayed->length > cur_displayed_limit) { + notification *n = g_queue_pop_tail(displayed); + g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL); //TODO: actually it should be on the head if unsorted + } + /* If displayed is actually full, let the more important notifications * from waiting seep into displayed. */ diff --git a/src/queues.h b/src/queues.h index 2bda3e8..4f4dc64 100644 --- a/src/queues.h +++ b/src/queues.h @@ -18,14 +18,6 @@ */ void queues_init(void); -/** - * Set maximum notification count to display - * and store in displayed queue - * - * @param limit The maximum amount - */ -void queues_displayed_limit(unsigned int limit); - /** * Receive the current list of displayed notifications * diff --git a/src/x11/x.c b/src/x11/x.c index 21eed84..bf50a73 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -516,17 +516,6 @@ struct geometry x_parse_geometry(const char *geom_str) geometry.negative_x = mask & XNegative; geometry.negative_y = mask & YNegative; - /* calculate maximum notification count and push information to queue */ - if (geometry.h == 0) { - queues_displayed_limit(0); - } else if (geometry.h == 1) { - queues_displayed_limit(1); - } else if (settings.indicate_hidden) { - queues_displayed_limit(geometry.h - 1); - } else { - queues_displayed_limit(geometry.h); - } - return geometry; }