[PATCH 2/3 v3] compositor: turn off the idle timer when sleeping

Philipp Brüschweiler blei42 at gmail.com
Sun Mar 10 08:08:30 PDT 2013


Also updates the drm, fbdev and rpi backend to use
weston_compositor_set_sleeping() and not set the state manually.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=61910 (rpi backend
untested).

v2: don't set DPMS state when switching VT.
v3: move unrelated enum change into its own commit.
---
 src/compositor-drm.c   |  2 +-
 src/compositor-fbdev.c |  2 +-
 src/compositor-rpi.c   |  2 +-
 src/compositor.c       | 12 +++++++++++-
 src/compositor.h       |  2 ++
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index d933c92..59d5694 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2027,7 +2027,7 @@ vt_func(struct weston_compositor *compositor, int event)
 
 		compositor->focus = 0;
 		ec->prev_state = compositor->state;
-		compositor->state = WESTON_COMPOSITOR_SLEEPING;
+		weston_compositor_set_sleeping(compositor);
 
 		/* If we have a repaint scheduled (either from a
 		 * pending pageflip or the idle handler), make sure we
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 070d187..2a01078 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -791,7 +791,7 @@ 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_set_sleeping(&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
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index d3767b9..9571e85 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -1381,7 +1381,7 @@ 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_set_sleeping(&compositor->base);
 
 		/* If we have a repaint scheduled (either from a
 		 * pending pageflip or the idle handler), make sure we
diff --git a/src/compositor.c b/src/compositor.c
index 7df9658..5041f19 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1619,12 +1619,22 @@ weston_compositor_wake(struct weston_compositor *compositor)
 }
 
 WL_EXPORT void
-weston_compositor_sleep(struct weston_compositor *compositor)
+weston_compositor_set_sleeping(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;
+}
+
+WL_EXPORT void
+weston_compositor_sleep(struct weston_compositor *compositor)
+{
+	if (compositor->state == WESTON_COMPOSITOR_SLEEPING)
+		return;
+
+	weston_compositor_set_sleeping(compositor);
 	weston_compositor_dpms(compositor, WESTON_DPMS_OFF);
 }
 
diff --git a/src/compositor.h b/src/compositor.h
index 5d939ab..0a9eb81 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -592,6 +592,8 @@ weston_compositor_unlock(struct weston_compositor *compositor);
 void
 weston_compositor_wake(struct weston_compositor *compositor);
 void
+weston_compositor_set_sleeping(struct weston_compositor *compositor);
+void
 weston_compositor_sleep(struct weston_compositor *compositor);
 void
 weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);
-- 
1.8.1.5



More information about the wayland-devel mailing list