From aa5cc977cc230f26c0d9bc3a8025b28dbcb32c42 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sat, 13 Jan 2018 00:58:18 +0100 Subject: [PATCH] Add pushback mode --- dunstrc | 7 +++++++ src/notification.c | 1 + src/notification.h | 7 ++++--- src/option_parser.c | 2 ++ src/queues.c | 19 ++++++++++++++++++- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/dunstrc b/dunstrc index ed8e4c6..6707411 100644 --- a/dunstrc +++ b/dunstrc @@ -294,6 +294,13 @@ # NOTE: It might be helpful to run dunst -print in a terminal in order # to find fitting options for rules. +# fullscreen values +# show: show the notifications, regardless if there is a fullscreen window opened +# delay: displays the new notification, if there is there is no fullscreen window active +# If the notification is already drawn, it won't get undrawn. +# pushback: same as delay, but when switching into fullscreen, the notification will get +# withdrawn from screen again and will get delayed like a new notification + #[fullscreen_delay_everything] # fullscreen = delay #[fullscreen_show_critical] diff --git a/src/notification.c b/src/notification.c index d18f001..b54b79f 100644 --- a/src/notification.c +++ b/src/notification.c @@ -34,6 +34,7 @@ const char *enum_to_string_fullscreen(enum behavior_fullscreen in) switch (in) { case FS_SHOW: return "show"; case FS_DELAY: return "delay"; + case FS_PUSHBACK: return "pushback"; case FS_NULL: return "(null)"; default: LOG_E("Enum behavior_fullscreen has wrong value."); diff --git a/src/notification.h b/src/notification.h index 09d2899..a866214 100644 --- a/src/notification.h +++ b/src/notification.h @@ -10,9 +10,10 @@ #define DUNST_NOTIF_MAX_CHARS 5000 enum behavior_fullscreen { - FS_NULL, //!< Invalid value - FS_DELAY, //!< Delay the notification until leaving fullscreen mode - FS_SHOW, //!< Show the message when in fullscreen mode + FS_NULL, //!< Invalid value + FS_DELAY, //!< Delay the notification until leaving fullscreen mode + FS_PUSHBACK, //!< When entering fullscreen mode, push the notification back to waiting + FS_SHOW, //!< Show the message when in fullscreen mode }; /// Representing the urgencies according to the notification spec diff --git a/src/option_parser.c b/src/option_parser.c index ca82813..b95f911 100644 --- a/src/option_parser.c +++ b/src/option_parser.c @@ -561,6 +561,8 @@ enum behavior_fullscreen parse_enum_fullscreen(const char *string, enum behavior return FS_SHOW; else if (strcmp(string, "delay") == 0) return FS_DELAY; + else if (strcmp(string, "pushback") == 0) + return FS_PUSHBACK; else { LOG_W("Unknown fullscreen value: '%s'\n", string); return def; diff --git a/src/queues.c b/src/queues.c index 09fed9c..cf229a2 100644 --- a/src/queues.c +++ b/src/queues.c @@ -332,6 +332,22 @@ void queues_update(bool fullscreen) return; } + /* move notifications back to queue, which are set to pushback */ + if (fullscreen) { + GList *iter = g_queue_peek_head_link(displayed); + while (iter) { + notification *n = iter->data; + GList *nextiter = iter->next; + + if (n->fullscreen == FS_PUSHBACK){ + g_queue_delete_link(displayed, iter); + g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL); + } + + iter = nextiter; + } + } + /* move notifications from queue to displayed */ GList *iter = g_queue_peek_head_link(waiting); while (iter) { @@ -346,7 +362,8 @@ void queues_update(bool fullscreen) if (!n) return; - if (fullscreen && n->fullscreen == FS_DELAY) { + if (fullscreen + && (n->fullscreen == FS_DELAY || n->fullscreen == FS_PUSHBACK)) { iter = nextiter; continue; }