From af867cc2f79a57bec7911352ed7dfc36427632cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 15 Nov 2011 13:34:49 +0200 Subject: [PATCH] compositor: let the shell wake up the compositor When compositor enters SLEEPING state, the shell plugin goes locked. If compositor wakes up itself, it will fade in while the shell may not yet have a lock surface to show. Fix this by assigning wake-up to be called from the shell, if the compositor is SLEEPING. The shell may wait for the lock surface request, and only then wake up the compositor. The compositor will fade in directly to the lock screen. krh: original patch for compositor.c ppaalanen: integration and shell.c changes Signed-off-by: Pekka Paalanen --- compositor/compositor.c | 19 +++++++++++++------ compositor/compositor.h | 2 ++ compositor/shell.c | 7 +++++++ compositor/tablet-shell.c | 4 ++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/compositor/compositor.c b/compositor/compositor.c index bba12e5c..42aff23e 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -1334,9 +1334,6 @@ wlsc_compositor_wake(struct wlsc_compositor *compositor) if (compositor->idle_inhibit) return; - if (compositor->state == WLSC_COMPOSITOR_SLEEPING) - compositor->shell->unlock(compositor->shell); - wlsc_compositor_fade(compositor, 0.0); compositor->state = WLSC_COMPOSITOR_ACTIVE; @@ -1344,10 +1341,20 @@ wlsc_compositor_wake(struct wlsc_compositor *compositor) option_idle_time * 1000); } +WL_EXPORT void +wlsc_compositor_activity(struct wlsc_compositor *compositor) +{ + if (compositor->state != WLSC_COMPOSITOR_SLEEPING) { + wlsc_compositor_wake(compositor); + } else { + compositor->shell->unlock(compositor->shell); + } +} + static void wlsc_compositor_idle_inhibit(struct wlsc_compositor *compositor) { - wlsc_compositor_wake(compositor); + wlsc_compositor_activity(compositor); compositor->idle_inhibit++; } @@ -1355,7 +1362,7 @@ static void wlsc_compositor_idle_release(struct wlsc_compositor *compositor) { compositor->idle_inhibit--; - wlsc_compositor_wake(compositor); + wlsc_compositor_activity(compositor); } static int @@ -1384,7 +1391,7 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y) int x_valid = 0, y_valid = 0; int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; - wlsc_compositor_wake(ec); + wlsc_compositor_activity(ec); wl_list_for_each(output, &ec->output_list, link) { if (output->x <= x && x <= output->x + output->current->width) diff --git a/compositor/compositor.h b/compositor/compositor.h index 12820bf6..166d9920 100644 --- a/compositor/compositor.h +++ b/compositor/compositor.h @@ -326,6 +326,8 @@ void wlsc_compositor_unlock(struct wlsc_compositor *compositor); void wlsc_compositor_wake(struct wlsc_compositor *compositor); +void +wlsc_compositor_activity(struct wlsc_compositor *compositor); struct wlsc_binding; typedef void (*wlsc_binding_handler_t)(struct wl_input_device *device, diff --git a/compositor/shell.c b/compositor/shell.c index 9d22cde3..c25ada21 100644 --- a/compositor/shell.c +++ b/compositor/shell.c @@ -829,6 +829,11 @@ desktop_shell_set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface_resource) { + struct wl_shell *shell = resource->data; + + /* TODO: put the lock surface always on top modal until unlocked */ + + wlsc_compositor_wake(shell->compositor); } static void @@ -839,6 +844,7 @@ desktop_shell_unlock(struct wl_client *client, shell->locked = false; shell->prepare_event_sent = false; + wlsc_compositor_wake(shell->compositor); } static const struct desktop_shell_interface desktop_shell_implementation = { @@ -952,6 +958,7 @@ unlock(struct wlsc_shell *base) /* If desktop-shell client has gone away, unlock immediately. */ if (!shell->child.desktop_shell) { shell->locked = false; + wlsc_compositor_wake(shell->compositor); return; } diff --git a/compositor/tablet-shell.c b/compositor/tablet-shell.c index 21786a2c..c82b5b50 100644 --- a/compositor/tablet-shell.c +++ b/compositor/tablet-shell.c @@ -556,6 +556,10 @@ tablet_shell_lock(struct wlsc_shell *base) static void tablet_shell_unlock(struct wlsc_shell *base) { + struct tablet_shell *shell = + container_of(base, struct tablet_shell, shell); + + wlsc_compositor_wake(shell->compositor); } static void