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

Pekka Paalanen ppaalanen at gmail.com
Tue Nov 15 03:34:49 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 +++++++
 compositor/tablet-shell.c |    4 ++++
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/compositor/compositor.c b/compositor/compositor.c
index 5f30893..144e329 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -1326,9 +1326,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;
 
@@ -1336,10 +1333,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++;
 }
 
@@ -1347,7 +1354,7 @@ static void
 wlsc_compositor_idle_release(struct wlsc_compositor *compositor)
 {
 	compositor->idle_inhibit--;
-	wlsc_compositor_wake(compositor);
+	wlsc_compositor_activity(compositor);
 }
 
 static int
@@ -1376,7 +1383,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 0d4483d..e9c00e8 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 f2ade4b..f3e2220 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -833,6 +833,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
@@ -843,6 +848,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 = {
@@ -956,6 +962,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 21786a2..c82b5b5 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
-- 
1.7.3.4



More information about the wayland-devel mailing list