Move maximum notification display count to x11
Decouple the x11 stuff from dunst.c, to be able to push update_lists to queues.c in the next commit
This commit is contained in:
parent
7110734b6e
commit
af9f6b8b7d
14
src/dunst.c
14
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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
|
11
src/x11/x.c
11
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user