From e955f1edd1104795daf7727f683300287d4e5686 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 7 Dec 2011 11:49:52 +0200 Subject: [PATCH] shell: use desktop-shell ini file for screensaver path Read the same configuration file in the shell plugin (desktop-shell) as the desktop-shell client does. Add a new section "screensaver", where "path" defines the path of the idle animation client to be executed. Not defining "path" disables the animation. Idle animations are not in use by default. It must be configured in wayland-desktop-shell.ini or launched manually. Signed-off-by: Pekka Paalanen --- compositor/Makefile.am | 3 ++- compositor/shell.c | 32 +++++++++++++++++++++++++++++++- wayland-desktop-shell.ini | 4 ++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/compositor/Makefile.am b/compositor/Makefile.am index 6716446b3..ce5a3d2fd 100644 --- a/compositor/Makefile.am +++ b/compositor/Makefile.am @@ -74,7 +74,8 @@ endif if ENABLE_DESKTOP_SHELL desktop_shell = desktop-shell.la desktop_shell_la_LDFLAGS = -module -avoid-version -desktop_shell_la_LIBADD = $(COMPOSITOR_LIBS) +desktop_shell_la_LIBADD = $(COMPOSITOR_LIBS) \ + ../shared/libconfig-parser.la desktop_shell_la_CFLAGS = $(GCC_CFLAGS) desktop_shell_la_SOURCES = \ shell.c \ diff --git a/compositor/shell.c b/compositor/shell.c index 99c2af5a2..6cabcfcb2 100644 --- a/compositor/shell.c +++ b/compositor/shell.c @@ -33,6 +33,7 @@ #include #include "compositor.h" #include "desktop-shell-server-protocol.h" +#include "../shared/config-parser.h" struct shell_surface; @@ -57,6 +58,7 @@ struct wl_shell { struct wl_list panels; struct { + const char *path; struct wl_resource *binding; struct wl_list surfaces; struct wlsc_process process; @@ -95,6 +97,28 @@ struct wlsc_move_grab { int32_t dx, dy; }; +static int +shell_configuration(struct wl_shell *shell) +{ + int ret; + char *config_file; + + struct config_key saver_keys[] = { + { "path", CONFIG_KEY_STRING, &shell->screensaver.path }, + }; + + struct config_section cs[] = { + { "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL }, + }; + + config_file = config_file_path("wayland-desktop-shell.ini"); + ret = parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell); + free(config_file); + + return ret; + /* FIXME: free(shell->screensaver.path) on plugin fini */ +} + static void move_grab_motion(struct wl_grab *grab, uint32_t time, int32_t x, int32_t y) @@ -503,9 +527,12 @@ launch_screensaver(struct wl_shell *shell) if (shell->screensaver.binding) return; + if (!shell->screensaver.path) + return; + wlsc_client_launch(shell->compositor, &shell->screensaver.process, - "./clients/wscreensaver", + shell->screensaver.path, handle_screensaver_sigchld); } @@ -1214,6 +1241,9 @@ shell_init(struct wlsc_compositor *ec) wl_list_init(&shell->panels); wl_list_init(&shell->screensaver.surfaces); + if (shell_configuration(shell) < 0) + return -1; + if (wl_display_add_global(ec->wl_display, &wl_shell_interface, shell, bind_shell) == NULL) return -1; diff --git a/wayland-desktop-shell.ini b/wayland-desktop-shell.ini index 3a8693538..d438a85e0 100644 --- a/wayland-desktop-shell.ini +++ b/wayland-desktop-shell.ini @@ -18,3 +18,7 @@ path=/usr/bin/google-chrome [launcher] icon=/usr/share/icons/gnome/24x24/apps/arts.png path=./clients/flower + +[screensaver] +#path=./clients/wscreensaver +