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. */
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. */
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. */
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);
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:
}
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);
}
out:
/* prevent further rendering while shutting down */
- ec->state = WESTON_COMPOSITOR_SLEEPING;
+ ec->state = WESTON_COMPOSITOR_OFFSCREEN;
wl_signal_emit(&ec->destroy_signal, ec);
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 {
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);