27int next_notification_id = 1;
51 return g_queue_peek_head(
waiting);
75 return g_queue_peek_head_link(
history);
97 g_queue_delete_link(queueA, elemA);
98 g_queue_delete_link(queueB, elemB);
115 if (status.pause_level > n->override_pause_level) {
119 if (status.fullscreen && shown)
121 else if (status.fullscreen && !shown)
146 bool is_idle = status.fullscreen ? false : status.idle;
155 if (status.mouse_over && !n->
transient) {
176 LOG_M(
"Skipping notification: '%s' '%s'",
STR_NN(n->body),
STR_NN(n->summary));
180 bool inserted =
false;
188 n->id = ++next_notification_id;
195 if (
settings.sort == SORT_TYPE_UPDATE) {
209 if (print_notifications)
226 for (
size_t i = 0; i <
sizeof(allqueues)/
sizeof(GQueue*); i++) {
227 for (GList *iter = g_queue_peek_head_link(allqueues[i]); iter; iter = iter->next) {
229 if (notification_is_duplicate(old,
new)) {
252 if (old->
progress == new->progress) {
260 signal_notification_closed(old, 1);
283 for (
size_t i = 0; i <
sizeof(allqueues)/
sizeof(GQueue*); i++) {
284 for (GList *iter = g_queue_peek_head_link(allqueues[i]); iter; iter = iter->next) {
287 &&
STR_EQ(old->appname, new->appname)) {
291 bool replace =
false;
298 if (!new->iconname) {
309 signal_notification_closed(old, 1);
331 for (
size_t i = 0; i <
sizeof(allqueues)/
sizeof(GQueue*); i++) {
332 for (GList *iter = g_queue_peek_head_link(allqueues[i]);
336 if (old->id == new->id) {
359 for (
size_t i = 0; i <
sizeof(allqueues)/
sizeof(GQueue*); i++) {
360 for (GList *iter = g_queue_peek_head_link(allqueues[i]); iter;
364 g_queue_remove(allqueues[i], n);
374 signal_notification_closed(target,
reason);
393static void queues_destroy_notification(
struct notification *n, gpointer user_data)
402 guint n = g_queue_get_length(
history);
403 g_queue_foreach(
history, (GFunc)queues_destroy_notification, NULL);
429 for (GList *iter = g_queue_peek_head_link(
history); iter;
452 guint maxlen =
settings.history_length;
483 for (GList *iter = g_queue_peek_head_link(
history); iter;
503 GList *iter, *nextiter;
508 iter = g_queue_peek_head_link(
displayed);
511 nextiter = iter->next;
513 if (notification_is_locked(n)) {
518 if (n->marked_for_closure) {
520 n->marked_for_closure = 0;
549 int cur_displayed_limit;
550 if (
settings.notification_limit == 0)
551 cur_displayed_limit = INT_MAX;
555 cur_displayed_limit =
settings.notification_limit-1;
557 cur_displayed_limit =
settings.notification_limit;
560 iter = g_queue_peek_head_link(
waiting);
561 while (
displayed->length < cur_displayed_limit && iter) {
563 nextiter = iter->next;
578 g_queue_delete_link(
waiting, iter);
586 while (
displayed->length > cur_displayed_limit) {
595 GList *i_waiting, *i_displayed;
597 while ( (i_waiting = g_queue_peek_head_link(
waiting))
598 && (i_displayed = g_queue_peek_tail_link(
displayed))) {
601 i_waiting = i_waiting->prev;
604 if (i_waiting &&
notification_cmp(i_displayed->data, i_waiting->data) > 0) {
607 todisp->
start = time;
616 signal_length_propertieschanged();
622 gint64 wakeup_time = G_MAXINT64;
623 gint64 next_second = time +
S2US(1) - (time %
S2US(1));
625 for (GList *iter = g_queue_peek_head_link(
displayed); iter;
631 if (timeout_ts > time)
632 wakeup_time = MIN(wakeup_time, timeout_ts);
638 if (
settings.show_age_threshold >= 0) {
648 wakeup_time = MIN(wakeup_time, next_second);
655 return wakeup_time != G_MAXINT64 ? wakeup_time : -1;
667 for (
size_t i = 0; i <
sizeof(recqueues)/
sizeof(GQueue*); i++) {
668 for (GList *iter = g_queue_peek_head_link(recqueues[i]); iter;
682 for (
size_t i = 0; i <
sizeof(recqueues)/
sizeof(GQueue*); i++) {
683 for (GList *iter = g_queue_peek_head_link(recqueues[i]); iter;
687 rule_apply(cur->original, cur,
false);
reason
The reasons according to the notification spec.
@ REASON_TIME
The notification timed out.
@ REASON_USER
The user closed the notification.
Logging subsystem and helpers.
int notification_cmp_data(const void *va, const void *vb, void *data)
Wrapper for notification_cmp to match glib's compare functions signature.
int notification_cmp(const struct notification *a, const struct notification *b)
Helper function to compare two given notifications.
void notification_run_script(struct notification *n)
Run the script associated with the given notification.
void notification_icon_replace_path(struct notification *n, const char *new_icon)
Replace the current notification's icon with the icon specified by path.
void notification_transfer_icon(struct notification *from, struct notification *to)
Transfer the image surface of from to to.
void notification_print(const struct notification *n)
print a human readable representation of the given notification to stdout.
void notification_unref(struct notification *n)
Decrease the reference counter of the notification.
Notification type definitions.
@ FS_SHOW
Show the message when in fullscreen mode.
@ FS_PUSHBACK
When entering fullscreen mode, push the notification back to waiting.
int queues_notification_insert(struct notification *n)
Insert a fully initialized notification into queues.
static GQueue * history
history of displayed notifications
unsigned int queues_length_waiting(void)
Returns the current amount of notifications, which are waiting to get displayed.
void queues_notification_remove(struct notification *n, enum reason reason)
Remove the given notification from all queues.
static bool queues_stack_by_tag(struct notification *n)
Replaces the first notification of the same stack_tag.
void queues_init(void)
Initialise necessary queues.
static GQueue * waiting
all new notifications get into here
static void teardown_notification(gpointer data)
Helper function for queues_teardown() to free a single notification.
GList * queues_get_displayed(void)
Receive the current list of displayed notifications.
void queues_history_pop(void)
Pushes the latest notification of history to the displayed queue and removes it from history.
void queues_teardown(void)
Remove all notifications from all list and free the notifications.
static GQueue * displayed
currently displayed notifications
void queues_notification_close(struct notification *n, enum reason reason)
Close the given notification.
gint64 queues_get_next_datachange(gint64 time)
Calculate the distance to the next event, when an element in the queues changes.
void queues_reapply_all_rules(void)
Reapply all rules to the queue (used when reloading configs)
guint queues_history_clear(void)
Removes all notifications from history Returns the number of removed notifications.
unsigned int queues_length_history(void)
Returns the current amount of notifications, which are already in history.
static bool queues_notification_is_finished(struct notification *n, struct dunst_status status, gint64 time)
Check if a notification has timed out.
void queues_notification_close_id(gint id, enum reason reason)
Close the notification that has n->id == id.
static bool queues_notification_is_ready(const struct notification *n, struct dunst_status status, bool shown)
Check if a notification is eligible to get shown.
static bool queues_stack_duplicate(struct notification *n)
Replaces duplicate notification and stacks it.
unsigned int queues_length_displayed(void)
Returns the current amount of notifications, which are shown in the UI.
void queues_history_pop_by_id(gint id)
Pushes the latest notification found in the history buffer identified by it's assigned id.
void queues_history_push_all(void)
Push all waiting and displayed notifications to history.
bool queues_notification_replace_id(struct notification *new)
Replace the notification which matches the id field of the new notification.
static void queues_swap_notifications(GQueue *queueA, GList *elemA, GQueue *queueB, GList *elemB)
Swap two given queue elements.
struct notification * queues_get_head_waiting(void)
Get the highest notification in line.
void queues_history_push(struct notification *n)
Push a single notification to history The given notification has to be removed its queue.
void queues_update(struct dunst_status status, gint64 time)
Move inserted notifications from waiting queue to displayed queue and show them.
struct notification * queues_get_by_id(gint id)
Get the notification which has the given id in the displayed and waiting queue or NULL if not found.
GList * queues_get_history(void)
Recieve the list of all notifications encountered.
bool queues_history_remove_by_id(gint id)
Removes an notification identified by the given id from the history.
Queues for history, waiting and displayed notifications.
Rules managment and helpers.
Type definitions for settings.
char * stack_tag
stack notifications by tag
char * msg
formatted message
int locked
If non-zero the notification is locked.
char * iconname
plain icon information (may be a path or just a name) as recieved from dbus.
int skip_display
insert notification into history, skipping initial waiting and display
int progress
percentage (-1: undefined)
gint64 icon_time
Time of reception of the icon (or opening of the file in case of a path)
int history_ignore
push to history or free directly
cairo_surface_t * icon
The raw cached icon data used to draw.
guint8 marked_for_removal
If set, the notification is marked for removal in history.
gint64 timestamp
arrival time (in milliseconds)
char * icon_id
Plain icon information, which acts as the icon's id.
enum behavior_fullscreen fullscreen
The instruction what to do with it, when desktop enters fullscreen.
bool redisplayed
has been displayed before?
gint64 start
begin of current display (in milliseconds)
bool transient
timeout albeit user is idle
gint64 timeout
time to display (in milliseconds)
int dup_count
amount of duplicate notifications stacked onto this
gint64 modification_time(const char *path)
Get the modification time of the file at path.
gint64 time_monotonic_now(void)
Get the current monotonic time.
bool is_like_path(const char *string)
Check if the strings looks like a path.
String, time and other various helpers.
#define STR_EMPTY(s)
Test if a string is NULL or empty.
#define S2US(s)
Convert seconds into microseconds.
#define STR_EQ(a, b)
Test if string a and b contain the same chars.
#define STR_FULL(s)
Test if a string is non-NULL and not empty.
#define STR_NN(s)
Get a non null string from a possibly null one.
#define ASSERT_OR_RET(expr, val)
Assert that expr evaluates to true, if not return val.