From 5ff85b3d28434f531aab3af10c56ac432a9c2998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 9 Jul 2014 16:48:24 +0200 Subject: [PATCH 1/2] Integrate signal handling with the GLib main loop --- dunst.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/dunst.c b/dunst.c index c695002..74c3fcc 100644 --- a/dunst.c +++ b/dunst.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -271,6 +272,22 @@ gboolean run(void *data) return false; } +gboolean pause_signal (gpointer data) +{ + pause_display = true; + wake_up(); + + return G_SOURCE_CONTINUE; +} + +gboolean unpause_signal (gpointer data) +{ + pause_display = false; + wake_up(); + + return G_SOURCE_CONTINUE; +} + int main(int argc, char *argv[]) { @@ -300,9 +317,6 @@ int main(int argc, char *argv[]) x_setup(); - signal(SIGUSR1, pause_signal_handler); - signal(SIGUSR2, pause_signal_handler); - if (settings.startup_notification) { notification *n = malloc(sizeof(notification)); n->appname = strdup("dunst"); @@ -345,6 +359,9 @@ int main(int argc, char *argv[]) g_source_attach(x11_source, NULL); + g_unix_signal_add(SIGUSR1, pause_signal, NULL); + g_unix_signal_add(SIGUSR2, unpause_signal, NULL); + run(NULL); g_main_loop_run(mainloop); @@ -353,20 +370,6 @@ int main(int argc, char *argv[]) return 0; } -void pause_signal_handler(int sig) -{ - if (sig == SIGUSR1) { - pause_display = true; - wake_up(); - } - if (sig == SIGUSR2) { - pause_display = false; - wake_up(); - } - - signal(sig, pause_signal_handler); -} - void usage(int exit_status) { fputs("usage:\n", stderr); From 36a858da3fa43b43febf99880dba514e5402dd6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 9 Jul 2014 17:09:52 +0200 Subject: [PATCH 2/2] Set dependency to '>=glib-2.36' as needed by the glib signal handler --- config.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 566739e..5171442 100644 --- a/config.mk +++ b/config.mk @@ -25,7 +25,9 @@ endif CPPFLAGS += -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS} CFLAGS += -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} ${CPPFLAGS} ${EXTRACFLAGS} -pkg_config_packs:="dbus-1 x11 freetype2 xext xft xscrnsaver glib-2.0 gio-2.0 pango cairo pangocairo" +pkg_config_packs := dbus-1 x11 freetype2 xext xft xscrnsaver \ + "glib-2.0 >= 2.36" gio-2.0 \ + pango cairo pangocairo # check if we need libxdg-basedir ifeq (,$(findstring STATIC_CONFIG,$(CFLAGS)))