From c70da444a9156a4aafe7f2d68749ed91cbe78b7c Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 12 Oct 2017 21:49:49 +0200 Subject: [PATCH] Move pause_display to queues.c Hint for dbus.c lines (134,138): pause_display => (displayed->length == 0) --- src/dunst.c | 11 +++++------ src/dunst.h | 1 - src/notification.c | 4 ++-- src/queues.c | 16 ++++++++++++++++ src/queues.h | 11 +++++++++++ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/dunst.c b/src/dunst.c index d32601a..bc0ad0b 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -36,7 +36,6 @@ typedef struct _x11_source { } x11_source_t; /* index of colors fit to urgency level */ -bool pause_display = false; GMainLoop *mainloop = NULL; @@ -85,7 +84,7 @@ void update_lists() { check_timeouts(); - if (pause_display) { + if (queues_pause_status()) { while (displayed->length > 0) { g_queue_insert_sorted(queue, g_queue_pop_head(displayed), notification_cmp_data, NULL); @@ -130,11 +129,11 @@ gboolean run(void *data) timeout_cnt--; } - if (displayed->length > 0 && !xctx.visible && !pause_display) { + if (displayed->length > 0 && !xctx.visible) { x_win_show(); } - if (xctx.visible && (pause_display || displayed->length == 0)) { + if (xctx.visible && displayed->length == 0) { x_win_hide(); } @@ -162,7 +161,7 @@ gboolean run(void *data) gboolean pause_signal(gpointer data) { - pause_display = true; + queues_pause_on(); wake_up(); return G_SOURCE_CONTINUE; @@ -170,7 +169,7 @@ gboolean pause_signal(gpointer data) gboolean unpause_signal(gpointer data) { - pause_display = false; + queues_pause_off(); wake_up(); return G_SOURCE_CONTINUE; diff --git a/src/dunst.h b/src/dunst.h index f91d7ba..9fa6a7e 100644 --- a/src/dunst.h +++ b/src/dunst.h @@ -17,7 +17,6 @@ #define ColBG 0 extern GSList *rules; -extern bool pause_display; extern const char *color_strings[3][3]; /* return id of notification */ diff --git a/src/notification.c b/src/notification.c index 0703377..a737696 100644 --- a/src/notification.c +++ b/src/notification.c @@ -294,12 +294,12 @@ void notification_init(notification *n) // TODO: this does not belong into notification_init if (strcmp("DUNST_COMMAND_PAUSE", n->summary) == 0) { - pause_display = true; + queues_pause_on(); return; } if (strcmp("DUNST_COMMAND_RESUME", n->summary) == 0) { - pause_display = false; + queues_pause_off(); return; } diff --git a/src/queues.c b/src/queues.c index 0782835..c2df37c 100644 --- a/src/queues.c +++ b/src/queues.c @@ -16,6 +16,7 @@ GQueue *history = NULL; /* history of displayed notifications */ unsigned int displayed_limit = 0; int next_notification_id = 1; +bool pause_displayed = false; static int queues_stack_duplicate(notification *n); @@ -244,6 +245,21 @@ gint64 queues_get_next_datachange(gint64 time) return sleep != G_MAXINT64 ? sleep : -1; } +void queues_pause_on(void) +{ + pause_displayed = true; +} + +void queues_pause_off(void) +{ + pause_displayed = false; +} + +bool queues_pause_status(void) +{ + return pause_displayed; +} + static void teardown_notification(gpointer data) { notification *n = data; diff --git a/src/queues.h b/src/queues.h index 942d0a0..31976d2 100644 --- a/src/queues.h +++ b/src/queues.h @@ -74,6 +74,17 @@ void move_all_to_history(void); */ gint64 queues_get_next_datachange(gint64 time); +/* + * Pause queue-management of dunst + * pause_on = paused (no notifications displayed) + * pause_off = running + * + * Calling update_lists is neccessary + */ +void queues_pause_on(void); +void queues_pause_off(void); +bool queues_pause_status(void); + /* * Remove all notifications from all lists * and free the notifications