From 18027e517aa5768df81447061d94db867f15845a Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 2 Dec 2011 16:31:49 +0200 Subject: [PATCH] shell: automatic exec and kill of wscreensaver Signed-off-by: Pekka Paalanen --- compositor/shell.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/compositor/shell.c b/compositor/shell.c index 32738819..99c2af5a 100644 --- a/compositor/shell.c +++ b/compositor/shell.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "compositor.h" @@ -58,6 +59,7 @@ struct wl_shell { struct { struct wl_resource *binding; struct wl_list surfaces; + struct wlsc_process process; } screensaver; }; @@ -489,19 +491,31 @@ static const struct wl_shell_interface shell_implementation = { shell_get_shell_surface }; +static void +handle_screensaver_sigchld(struct wlsc_process *proc, int status) +{ + proc->pid = 0; +} + static void launch_screensaver(struct wl_shell *shell) { if (shell->screensaver.binding) return; - /* TODO: exec() the screensaver process */ + wlsc_client_launch(shell->compositor, + &shell->screensaver.process, + "./clients/wscreensaver", + handle_screensaver_sigchld); } static void terminate_screensaver(struct wl_shell *shell) { - /* TODO */ + if (shell->screensaver.process.pid == 0) + return; + + kill(shell->screensaver.process.pid, SIGTERM); } static void