[PATCH 2/4] compositor: let the shell wake up the compositor

Pekka Paalanen ppaalanen at gmail.com
Mon Nov 7 07:12:32 PST 2011


From: Kristian Høgsberg <krh at bitplanet.net>

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 <ppaalanen at gmail.com>
---
 compositor/compositor.c |   19 +++++++++++++------
 compositor/compositor.h |    2 ++
 compositor/shell.c      |    7 +++++++
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/compositor/compositor.c b/compositor/compositor.c
index 43e3040..fd72214 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -1336,9 +1336,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;
 
@@ -1346,10 +1343,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++;
 }
 
@@ -1357,7 +1364,7 @@ static void
 wlsc_compositor_idle_release(struct wlsc_compositor *compositor)
 {
 	compositor->idle_inhibit--;
-	wlsc_compositor_wake(compositor);
+	wlsc_compositor_activity(compositor);
 }
 
 static int
@@ -1386,7 +1393,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 9c5f73d..a84c5e3 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -323,6 +323,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 9c79d35..14dbf9f 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -836,6 +836,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
@@ -846,6 +851,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 = {
@@ -954,6 +960,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;
 	}
 
-- 
1.7.3.4



More information about the wayland-devel mailing list