compositor: let shell override idle time

Move idle_time variable to struct wlsc_compositor, so that a shell
plugin can change it. Also store the original value from the command
line.

Add "duration" option to the desktop-shell screensaver config. This is
the time the screensaver will be visible, after idle timeout triggers
another time and blanks the screen.

Now you can have different delays to lock the screen, and switch off the
screen while a screensaver is running.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
dev
Pekka Paalanen 13 years ago
parent e955f1edd1
commit 7296e7984f
  1. 9
      compositor/compositor.c
  2. 2
      compositor/compositor.h
  3. 12
      compositor/shell.c
  4. 1
      wayland-desktop-shell.ini

@ -48,7 +48,6 @@
#include "compositor.h" #include "compositor.h"
static const char *option_socket_name = NULL; static const char *option_socket_name = NULL;
static int option_idle_time = 300;
static struct wl_list child_process_list; static struct wl_list child_process_list;
@ -1299,7 +1298,7 @@ wlsc_compositor_wake(struct wlsc_compositor *compositor)
wlsc_compositor_fade(compositor, 0.0); wlsc_compositor_fade(compositor, 0.0);
wl_event_source_timer_update(compositor->idle_source, wl_event_source_timer_update(compositor->idle_source,
option_idle_time * 1000); compositor->idle_time * 1000);
} }
WL_EXPORT void WL_EXPORT void
@ -2070,7 +2069,7 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
loop = wl_display_get_event_loop(ec->wl_display); loop = wl_display_get_event_loop(ec->wl_display);
ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec); ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
wl_event_source_timer_update(ec->idle_source, option_idle_time * 1000); wl_event_source_timer_update(ec->idle_source, ec->idle_time * 1000);
wlsc_compositor_schedule_repaint(ec); wlsc_compositor_schedule_repaint(ec);
@ -2139,6 +2138,7 @@ int main(int argc, char *argv[])
char *backend_options = ""; char *backend_options = "";
char *shell = NULL; char *shell = NULL;
char *p; char *p;
int option_idle_time = 300;
static const char opts[] = "B:b:o:S:i:s:x"; static const char opts[] = "B:b:o:S:i:s:x";
static const struct option longopts[ ] = { static const struct option longopts[ ] = {
@ -2218,6 +2218,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ec->option_idle_time = option_idle_time;
ec->idle_time = option_idle_time;
if (shell_init(ec) < 0) if (shell_init(ec) < 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

@ -219,6 +219,8 @@ struct wlsc_compositor {
uint32_t state; uint32_t state;
struct wl_event_source *idle_source; struct wl_event_source *idle_source;
uint32_t idle_inhibit; uint32_t idle_inhibit;
int option_idle_time; /* default timeout, s */
int idle_time; /* effective timeout, s */
/* Repaint state. */ /* Repaint state. */
struct timespec previous_swap; struct timespec previous_swap;

@ -59,6 +59,7 @@ struct wl_shell {
struct { struct {
const char *path; const char *path;
int duration;
struct wl_resource *binding; struct wl_resource *binding;
struct wl_list surfaces; struct wl_list surfaces;
struct wlsc_process process; struct wlsc_process process;
@ -102,9 +103,12 @@ shell_configuration(struct wl_shell *shell)
{ {
int ret; int ret;
char *config_file; char *config_file;
char *path = NULL;
int duration = 60;
struct config_key saver_keys[] = { struct config_key saver_keys[] = {
{ "path", CONFIG_KEY_STRING, &shell->screensaver.path }, { "path", CONFIG_KEY_STRING, &path },
{ "duration", CONFIG_KEY_INTEGER, &duration },
}; };
struct config_section cs[] = { struct config_section cs[] = {
@ -115,6 +119,9 @@ shell_configuration(struct wl_shell *shell)
ret = parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell); ret = parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
free(config_file); free(config_file);
shell->screensaver.path = path;
shell->screensaver.duration = duration;
return ret; return ret;
/* FIXME: free(shell->screensaver.path) on plugin fini */ /* FIXME: free(shell->screensaver.path) on plugin fini */
} }
@ -716,6 +723,7 @@ resume_desktop(struct wl_shell *shell)
shell->locked = false; shell->locked = false;
wlsc_compositor_repick(shell->compositor); wlsc_compositor_repick(shell->compositor);
shell->compositor->idle_time = shell->compositor->option_idle_time;
wlsc_compositor_wake(shell->compositor); wlsc_compositor_wake(shell->compositor);
} }
@ -907,6 +915,7 @@ lock(struct wlsc_shell *base)
show_screensaver(shell, shsurf); show_screensaver(shell, shsurf);
if (!wl_list_empty(&shell->screensaver.surfaces)) { if (!wl_list_empty(&shell->screensaver.surfaces)) {
shell->compositor->idle_time = shell->screensaver.duration;
wlsc_compositor_wake(shell->compositor); wlsc_compositor_wake(shell->compositor);
shell->compositor->state = WLSC_COMPOSITOR_IDLE; shell->compositor->state = WLSC_COMPOSITOR_IDLE;
} }
@ -1025,6 +1034,7 @@ map(struct wlsc_shell *base,
/* If locked, show it. */ /* If locked, show it. */
if (shell->locked) { if (shell->locked) {
show_screensaver(shell, shsurf); show_screensaver(shell, shsurf);
compositor->idle_time = shell->screensaver.duration;
wlsc_compositor_wake(compositor); wlsc_compositor_wake(compositor);
if (!shell->lock_surface) if (!shell->lock_surface)
compositor->state = WLSC_COMPOSITOR_IDLE; compositor->state = WLSC_COMPOSITOR_IDLE;

@ -21,4 +21,5 @@ path=./clients/flower
[screensaver] [screensaver]
#path=./clients/wscreensaver #path=./clients/wscreensaver
duration=600

Loading…
Cancel
Save