diff --git a/src/dunst.c b/src/dunst.c index ef6df80..16867dc 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -83,8 +83,6 @@ void check_timeouts(void) /*TODO: move to queues.c */ void update_lists() { - int limit; - check_timeouts(); if (pause_display) { @@ -95,20 +93,10 @@ void update_lists() return; } - if (xctx.geometry.h == 0) { - limit = 0; - } else if (xctx.geometry.h == 1) { - limit = 1; - } else if (settings.indicate_hidden) { - limit = xctx.geometry.h - 1; - } else { - limit = xctx.geometry.h; - } - /* move notifications from queue to displayed */ while (queue->length > 0) { - if (limit > 0 && displayed->length >= limit) { + if (displayed_limit > 0 && displayed->length >= displayed_limit) { /* the list is full */ break; } diff --git a/src/queues.c b/src/queues.c index e1f1a26..41bc922 100644 --- a/src/queues.c +++ b/src/queues.c @@ -14,6 +14,8 @@ GQueue *queue = NULL; /* all new notifications get into here */ GQueue *displayed = NULL; /* currently displayed notifications */ GQueue *history = NULL; /* history of displayed notifications */ +unsigned int displayed_limit = 0; + void queues_init(void) { history = g_queue_new(); @@ -21,6 +23,11 @@ void queues_init(void) queue = g_queue_new(); } +void queues_displayed_limit(unsigned int limit) +{ + displayed_limit = limit; +} + bool notification_replace_by_id(notification *new) { diff --git a/src/queues.h b/src/queues.h index 6440e5d..7b53c58 100644 --- a/src/queues.h +++ b/src/queues.h @@ -8,12 +8,19 @@ extern GQueue *queue; extern GQueue *displayed; extern GQueue *history; +extern unsigned int displayed_limit; /* * Initialise neccessary queues */ void queues_init(void); +/* + * Set maximum notification count to display + * and store in displayed queue + */ +void queues_displayed_limit(unsigned int limit); + /* * Replace the notification which matches the id field of * the new notification. The given notification is inserted diff --git a/src/x11/x.c b/src/x11/x.c index 587dd2b..156bfca 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -1015,6 +1015,17 @@ void x_setup(void) &xctx.geometry.x, &xctx.geometry.y, &xctx.geometry.w, &xctx.geometry.h); + /* calculate maximum notification count and push information to queue */ + if (xctx.geometry.h == 0) { + queues_displayed_limit(0); + } else if (xctx.geometry.h == 1) { + queues_displayed_limit(1); + } else if (settings.indicate_hidden) { + queues_displayed_limit(xctx.geometry.h - 1); + } else { + queues_displayed_limit(xctx.geometry.h); + } + xctx.screensaver_info = XScreenSaverAllocInfo(); init_screens();