compositor: add IDLE state
authorPekka Paalanen <ppaalanen@gmail.com>
Fri, 2 Dec 2011 11:07:27 +0000 (13:07 +0200)
committerPekka Paalanen <ppaalanen@gmail.com>
Wed, 14 Dec 2011 11:44:29 +0000 (13:44 +0200)
Add WLSC_COMPOSITOR_IDLE state to the possible compositor internal
states, and fix the drm backend to restore the previous state instead of
forcing ACTIVE.

Normally, the compositor only uses the ACTIVE and SLEEPING states. The
IDLE state is another active state, reserved for the shell, when the
shell wants to have unlock() calls on activity, but the compositor cannot
be SLEEPING.

Use the IDLE state to fix exposing the unlock dialog while a screensaver
is animating. Without this fix, is it impossible to activate the unlock
dialog without waiting for a second idle timeout that really puts the
compositor into SLEEPING.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
compositor/compositor-drm.c
compositor/compositor.c
compositor/compositor.h
compositor/shell.c

index cd342e6..4744a46 100644 (file)
@@ -52,6 +52,8 @@ struct drm_compositor {
        uint32_t crtc_allocator;
        uint32_t connector_allocator;
        struct tty *tty;
+
+       uint32_t prev_state;
 };
 
 struct drm_mode {
@@ -788,11 +790,12 @@ vt_func(struct wlsc_compositor *compositor, int event)
        case TTY_ENTER_VT:
                compositor->focus = 1;
                drmSetMaster(ec->drm.fd);
-               compositor->state = WLSC_COMPOSITOR_ACTIVE;
+               compositor->state = ec->prev_state;
                wlsc_compositor_damage_all(compositor);
                break;
        case TTY_LEAVE_VT:
                compositor->focus = 0;
+               ec->prev_state = compositor->state;
                compositor->state = WLSC_COMPOSITOR_SLEEPING;
 
                wl_list_for_each(output, &ec->base.output_list, link)
@@ -865,6 +868,8 @@ drm_compositor_create(struct wl_display *display,
 
        ec->base.focus = 1;
 
+       ec->prev_state = WLSC_COMPOSITOR_ACTIVE;
+
        glGenFramebuffers(1, &ec->base.fbo);
        glBindFramebuffer(GL_FRAMEBUFFER, ec->base.fbo);
 
index 6ee2298..118d0de 100644 (file)
@@ -1305,7 +1305,7 @@ wlsc_compositor_wake(struct wlsc_compositor *compositor)
 WL_EXPORT void
 wlsc_compositor_activity(struct wlsc_compositor *compositor)
 {
-       if (compositor->state != WLSC_COMPOSITOR_SLEEPING) {
+       if (compositor->state == WLSC_COMPOSITOR_ACTIVE) {
                wlsc_compositor_wake(compositor);
        } else {
                compositor->shell->unlock(compositor->shell);
index 7f1dd74..1584f80 100644 (file)
@@ -183,7 +183,8 @@ struct wlsc_shell {
 
 enum {
        WLSC_COMPOSITOR_ACTIVE,
-       WLSC_COMPOSITOR_SLEEPING
+       WLSC_COMPOSITOR_IDLE,           /* shell->unlock called on activity */
+       WLSC_COMPOSITOR_SLEEPING        /* no rendering, no frame events */
 };
 
 struct wlsc_compositor {
index e32e8bc..3273881 100644 (file)
@@ -865,8 +865,10 @@ lock(struct wlsc_shell *base)
        wl_list_for_each(shsurf, &shell->screensaver.surfaces, link)
                show_screensaver(shell, shsurf);
 
-       if (!wl_list_empty(&shell->screensaver.surfaces))
+       if (!wl_list_empty(&shell->screensaver.surfaces)) {
                wlsc_compositor_wake(shell->compositor);
+               shell->compositor->state = WLSC_COMPOSITOR_IDLE;
+       }
 
        /* reset pointer foci */
        wlsc_compositor_repick(shell->compositor);
@@ -983,6 +985,8 @@ map(struct wlsc_shell *base,
                if (shell->locked) {
                        show_screensaver(shell, shsurf);
                        wlsc_compositor_wake(compositor);
+                       if (!shell->lock_surface)
+                               compositor->state = WLSC_COMPOSITOR_IDLE;
                }
                do_configure = 0;
                break;