From 99b482c4840f57c6c0dfb471be6e9822e0453b75 Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Fri, 22 Jun 2012 18:22:46 +0200 Subject: [PATCH] send proper message id to client --- dunst.c | 8 +++++++- dunst.h | 4 +++- dunst_dbus.c | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dunst.c b/dunst.c index b749ce1..3ac44d5 100644 --- a/dunst.c +++ b/dunst.c @@ -83,6 +83,8 @@ static XScreenSaverInfo *screensaver_info; static int font_h; static char *config_file; +int next_notification_id = 1; + /* notification lists */ list *notification_queue = NULL; /* all new notifications get into here */ list *displayed_notifications = NULL; /* currently displayed notifications */ @@ -534,7 +536,7 @@ void history_pop(void) } } -void init_notification(notification * n) +int init_notification(notification * n) { const char *fg = NULL; const char *bg = NULL; @@ -573,6 +575,8 @@ void init_notification(notification * n) n->redisplayed = False; + n->id = ++next_notification_id; + dunst_printf(MSG, "%s\n", n->msg); dunst_printf(INFO, "{\n appname: %s\n summary: %s\n body: %s\n icon: %s\n urgency: %d\n timeout: %d\n}", @@ -580,6 +584,8 @@ void init_notification(notification * n) n->urgency, n->timeout); l_push(notification_queue, n); + + return n->id; } rule_t *initrule(void) diff --git a/dunst.h b/dunst.h index a9ab393..6203731 100644 --- a/dunst.h +++ b/dunst.h @@ -42,6 +42,7 @@ typedef struct _notification { int timeout; int urgency; int redisplayed; /* has been displayed before? */ + int id; ColorSet *colors; char *color_strings[2]; } notification; @@ -56,5 +57,6 @@ typedef struct _dimension_t { #endif /* vim: set ts=8 sw=8 tw=0: */ -void init_notification(notification * n); +/* return id of notification */ +int init_notification(notification * n); void map_win(void); diff --git a/dunst_dbus.c b/dunst_dbus.c index 662406e..6170a4f 100644 --- a/dunst_dbus.c +++ b/dunst_dbus.c @@ -251,7 +251,7 @@ void notify(DBusMessage * dmsg) char *hint_name; int i; - int id = 23; + int id; const char *appname = NULL; const char *summary = NULL; const char *body = NULL; @@ -324,7 +324,7 @@ void notify(DBusMessage * dmsg) } n->color_strings[ColFG] = fgcolor == NULL ? NULL : strdup(fgcolor); n->color_strings[ColBG] = bgcolor == NULL ? NULL : strdup(bgcolor); - init_notification(n); + id = init_notification(n); map_win(); reply = dbus_message_new_method_return(dmsg);