summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/deps.mk4
-rw-r--r--src/signals.c63
-rw-r--r--src/signals.h31
-rw-r--r--src/slideshow.c4
4 files changed, 101 insertions, 1 deletions
diff --git a/src/deps.mk b/src/deps.mk
index 5cd4fdf..c3e5043 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -27,8 +27,10 @@ multiwindow.o: multiwindow.c feh.h structs.h menu.h ipc.h utils.h \
getopt.h debug.h winwidget.h timers.h filelist.h options.h
options.o: options.c feh.h structs.h menu.h ipc.h utils.h getopt.h \
debug.h filelist.h options.h
+signals.o: signals.c feh.h structs.h menu.h ipc.h utils.h getopt.h \
+ debug.h winwidget.h
slideshow.o: slideshow.c feh.h structs.h menu.h ipc.h utils.h getopt.h \
- debug.h filelist.h timers.h winwidget.h options.h
+ debug.h filelist.h timers.h winwidget.h options.h signals.h
support.o: support.c feh.h structs.h menu.h ipc.h utils.h getopt.h \
debug.h filelist.h options.h support.h
thumbnail.o: thumbnail.c feh.h structs.h menu.h ipc.h utils.h getopt.h \
diff --git a/src/signals.c b/src/signals.c
new file mode 100644
index 0000000..4e51c77
--- /dev/null
+++ b/src/signals.c
@@ -0,0 +1,63 @@
+/* signals.c
+
+Copyright (C) 2010 by Daniel Friesel
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies of the Software and its documentation and acknowledgment shall be
+given in the documentation and software packages that this Software was
+used.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+
+#include "feh.h"
+#include "winwidget.h"
+
+void feh_handle_signal(int);
+
+void setup_signal_handlers()
+{
+ struct sigaction feh_sh;
+ sigset_t feh_ss;
+ D_ENTER(4);
+
+ sigemptyset(&feh_ss);
+ sigaddset(&feh_ss, SIGUSR1);
+ sigaddset(&feh_ss, SIGUSR2);
+
+ feh_sh.sa_handler = feh_handle_signal;
+ feh_sh.sa_mask = feh_ss;
+
+ sigaction(SIGUSR1, &feh_sh, NULL);
+ sigaction(SIGUSR2, &feh_sh, NULL);
+ D_RETURN_(4);
+}
+
+void feh_handle_signal(int signo)
+{
+ D_ENTER(4);
+ winwidget winwid
+ = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW);
+
+ if (winwid) {
+ if (signo == SIGUSR1)
+ slideshow_change_image(winwid, SLIDE_NEXT);
+ else if (signo == SIGUSR2)
+ slideshow_change_image(winwid, SLIDE_PREV);
+ }
+
+ D_RETURN_(4);
+}
diff --git a/src/signals.h b/src/signals.h
new file mode 100644
index 0000000..526285d
--- /dev/null
+++ b/src/signals.h
@@ -0,0 +1,31 @@
+/* signals.h
+
+Copyright (C) 2010 by Daniel Friesel
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies of the Software and its documentation and acknowledgment shall be
+given in the documentation and software packages that this Software was
+used.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+
+#ifndef SIGNALS_H
+#define SIGNALS_H
+
+void setup_signal_handlers();
+
+#endif
diff --git a/src/slideshow.c b/src/slideshow.c
index 4f95c46..d4cc1b4 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "timers.h"
#include "winwidget.h"
#include "options.h"
+#include "signals.h"
void init_slideshow_mode(void)
{
@@ -75,6 +76,9 @@ void init_slideshow_mode(void)
}
if (!success)
show_mini_usage();
+
+ setup_signal_handlers();
+
D_RETURN_(3);
}