[PATCH weston] compositor: add WESTON_COMPOSITOR_OFFSCREEN state

Kristian Høgsberg hoegsberg at gmail.com
Fri Mar 29 11:30:23 PDT 2013


On Fri, Mar 29, 2013 at 01:01:56PM +0100, Philipp Brüschweiler wrote:
> This state is used when the user switches the vt. It turns of rendering
> and frame events, but doesn't set the DPMS state to off.
> 
> As a part of this change, also turn off the idle timer when entering
> the SLEEPING or OFFSCREEN states, which fixes
> https://bugs.freedesktop.org/show_bug.cgi?id=61910 (rpi backend
> untested).

That great, I like that approach.  Commited.  I tested this with

  $ (sleep 20; pkill -x weston) & weston-launch -- -i2

(using -x to not kill weston-launch, which hangs the system in a
different way).  I noticed that if weston is killed while in sleep
mode, we don't set dpms back on on ther recovery path.  If you launch
from X, X will do that when we switch back, but if you launch from the
terminal, nothing does that and we're stuck with a turned off screen.
Something for another patch :)

Kristian

>  src/compositor-drm.c   |  4 ++--
>  src/compositor-fbdev.c |  4 ++--
>  src/compositor-rpi.c   |  4 ++--
>  src/compositor.c       | 22 ++++++++++++++++++++--
>  src/compositor.h       |  6 +++++-
>  5 files changed, 31 insertions(+), 9 deletions(-)
> 
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 3d200dd..6e0a126 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -2020,12 +2020,12 @@ vt_func(struct weston_compositor *compositor, int event)
>  
>  		compositor->focus = 0;
>  		ec->prev_state = compositor->state;
> -		compositor->state = WESTON_COMPOSITOR_SLEEPING;
> +		weston_compositor_offscreen(compositor);
>  
>  		/* If we have a repaint scheduled (either from a
>  		 * pending pageflip or the idle handler), make sure we
>  		 * cancel that so we don't try to pageflip when we're
> -		 * vt switched away.  The SLEEPING state will prevent
> +		 * vt switched away.  The OFFSCREEN state will prevent
>  		 * further attemps at repainting.  When we switch
>  		 * back, we schedule a repaint, which will process
>  		 * pending frame callbacks. */
> diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
> index 070d187..61cacc7 100644
> --- a/src/compositor-fbdev.c
> +++ b/src/compositor-fbdev.c
> @@ -791,11 +791,11 @@ vt_func(struct weston_compositor *base, int event)
>  
>  		compositor->base.focus = 0;
>  		compositor->prev_state = compositor->base.state;
> -		compositor->base.state = WESTON_COMPOSITOR_SLEEPING;
> +		weston_compositor_offscreen(&compositor->base);
>  
>  		/* If we have a repaint scheduled (from the idle handler), make
>  		 * sure we cancel that so we don't try to pageflip when we're
> -		 * vt switched away.  The SLEEPING state will prevent
> +		 * vt switched away.  The OFFSCREEN state will prevent
>  		 * further attemps at repainting.  When we switch
>  		 * back, we schedule a repaint, which will process
>  		 * pending frame callbacks. */
> diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
> index 30bbcea..cae6f7b 100644
> --- a/src/compositor-rpi.c
> +++ b/src/compositor-rpi.c
> @@ -1381,12 +1381,12 @@ vt_func(struct weston_compositor *base, int event)
>  
>  		compositor->base.focus = 0;
>  		compositor->prev_state = compositor->base.state;
> -		compositor->base.state = WESTON_COMPOSITOR_SLEEPING;
> +		weston_compositor_offscreen(&compositor->base);
>  
>  		/* If we have a repaint scheduled (either from a
>  		 * pending pageflip or the idle handler), make sure we
>  		 * cancel that so we don't try to pageflip when we're
> -		 * vt switched away.  The SLEEPING state will prevent
> +		 * vt switched away.  The OFFSCREEN state will prevent
>  		 * further attemps at repainting.  When we switch
>  		 * back, we schedule a repaint, which will process
>  		 * pending frame callbacks. */
> diff --git a/src/compositor.c b/src/compositor.c
> index 52d6f90..1617d96 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -1325,7 +1325,8 @@ weston_output_schedule_repaint(struct weston_output *output)
>  	struct weston_compositor *compositor = output->compositor;
>  	struct wl_event_loop *loop;
>  
> -	if (compositor->state == WESTON_COMPOSITOR_SLEEPING)
> +	if (compositor->state == WESTON_COMPOSITOR_SLEEPING ||
> +	    compositor->state == WESTON_COMPOSITOR_OFFSCREEN)
>  		return;
>  
>  	loop = wl_display_get_event_loop(compositor->wl_display);
> @@ -1670,6 +1671,7 @@ weston_compositor_wake(struct weston_compositor *compositor)
>  		weston_compositor_dpms(compositor, WESTON_DPMS_ON);
>  		/* fall through */
>  	case WESTON_COMPOSITOR_IDLE:
> +	case WESTON_COMPOSITOR_OFFSCREEN:
>  		wl_signal_emit(&compositor->wake_signal, compositor);
>  		/* fall through */
>  	default:
> @@ -1680,11 +1682,27 @@ weston_compositor_wake(struct weston_compositor *compositor)
>  }
>  
>  WL_EXPORT void
> +weston_compositor_offscreen(struct weston_compositor *compositor)
> +{
> +	switch (compositor->state) {
> +	case WESTON_COMPOSITOR_OFFSCREEN:
> +		return;
> +	case WESTON_COMPOSITOR_SLEEPING:
> +		weston_compositor_dpms(compositor, WESTON_DPMS_ON);
> +		/* fall through */
> +	default:
> +		compositor->state = WESTON_COMPOSITOR_OFFSCREEN;
> +		wl_event_source_timer_update(compositor->idle_source, 0);
> +	}
> +}
> +
> +WL_EXPORT void
>  weston_compositor_sleep(struct weston_compositor *compositor)
>  {
>  	if (compositor->state == WESTON_COMPOSITOR_SLEEPING)
>  		return;
>  
> +	wl_event_source_timer_update(compositor->idle_source, 0);
>  	compositor->state = WESTON_COMPOSITOR_SLEEPING;
>  	weston_compositor_dpms(compositor, WESTON_DPMS_OFF);
>  }
> @@ -3619,7 +3637,7 @@ int main(int argc, char *argv[])
>  
>   out:
>  	/* prevent further rendering while shutting down */
> -	ec->state = WESTON_COMPOSITOR_SLEEPING;
> +	ec->state = WESTON_COMPOSITOR_OFFSCREEN;
>  
>  	wl_signal_emit(&ec->destroy_signal, ec);
>  
> diff --git a/src/compositor.h b/src/compositor.h
> index 0ad60ef..7d1d68e 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -262,7 +262,9 @@ struct weston_seat {
>  enum {
>  	WESTON_COMPOSITOR_ACTIVE,
>  	WESTON_COMPOSITOR_IDLE,		/* shell->unlock called on activity */
> -	WESTON_COMPOSITOR_SLEEPING	/* no rendering, no frame events */
> +	WESTON_COMPOSITOR_OFFSCREEN,	/* no rendering, no frame events */
> +	WESTON_COMPOSITOR_SLEEPING	/* same as offscreen, but also set dmps
> +                                         * to off */
>  };
>  
>  struct weston_layer {
> @@ -621,6 +623,8 @@ weston_compositor_unlock(struct weston_compositor *compositor);
>  void
>  weston_compositor_wake(struct weston_compositor *compositor);
>  void
> +weston_compositor_offscreen(struct weston_compositor *compositor);
> +void
>  weston_compositor_sleep(struct weston_compositor *compositor);
>  void
>  weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);
> -- 
> 1.8.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list