[PATCH 04/10] compositor: If the output is inhibited, don't idle it off
Bryce Harrington
bryce at osg.samsung.com
Sat Mar 5 00:18:41 UTC 2016
Adds a helper routine weston_output_inhibited_outputs() which returns a
mask of outputs that should inhibit screen idling.
Use this routine to check for inhibiting outputs for handling of idle
behaviors in core: In sleep mode, only halt repainting outputs that
don't have valid inhibits. Don't send these monitors DPMS off commands
either, if the system would otherwise be powering them down.
Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
src/compositor.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-------
src/compositor.h | 2 ++
2 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 574a0b8..4dfc0eb 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2389,15 +2389,48 @@ weston_output_schedule_repaint_reset(struct weston_output *output)
weston_compositor_read_input, compositor);
}
+/** Retrieves a mask of outputs that should inhibit screensaving
+ *
+ * \param compositor The compositor instance.
+ * \return An output mask indicating the ids of all inhibiting outputs
+ *
+ * Checks for surfaces whose clients have requested that they
+ * disable the screenserver and display powersaving while they are
+ * 'active' (as defined by the particular shell being used). Note
+ * the output ids for these surfaces.
+ *
+ */
+WL_EXPORT uint32_t
+weston_output_inhibited_outputs(struct weston_compositor *compositor)
+{
+ struct weston_view *view;
+ uint32_t inhibited_outputs_mask = 0;
+
+ wl_list_for_each(view, &compositor->view_list, link) {
+ /* Only look at views whose surfaces are considered "active" by the shell */
+ if (!view->surface->active)
+ continue;
+
+ /* Does the view's surface inhibit this output? */
+ if (!view->surface->inhibit_screensaving)
+ continue;
+
+ inhibited_outputs_mask |= view->output_mask;
+ }
+ return inhibited_outputs_mask;
+}
+
static int
output_repaint_timer_handler(void *data)
{
struct weston_output *output = data;
struct weston_compositor *compositor = output->compositor;
+ uint32_t inhibited_outputs_mask = weston_output_inhibited_outputs(compositor);
if (output->repaint_needed &&
- compositor->state != WESTON_COMPOSITOR_SLEEPING &&
compositor->state != WESTON_COMPOSITOR_OFFSCREEN &&
+ (compositor->state != WESTON_COMPOSITOR_SLEEPING
+ || inhibited_outputs_mask & (1 << output->id)) &&
weston_output_repaint(output) == 0)
return 0;
@@ -2519,9 +2552,15 @@ weston_output_schedule_repaint(struct weston_output *output)
{
struct weston_compositor *compositor = output->compositor;
struct wl_event_loop *loop;
+ uint32_t inhibited_outputs_mask = weston_output_inhibited_outputs(compositor);
- if (compositor->state == WESTON_COMPOSITOR_SLEEPING ||
- compositor->state == WESTON_COMPOSITOR_OFFSCREEN)
+ /* If we're offscreen, or if we're sleeping and the monitor
+ * isn't currently being inhibited by an active surface, then
+ * skip repainting.
+ */
+ if (compositor->state == WESTON_COMPOSITOR_OFFSCREEN ||
+ (compositor->state == WESTON_COMPOSITOR_SLEEPING &&
+ !(inhibited_outputs_mask & (1 << output->id))))
return;
if (!output->repaint_needed)
@@ -3864,11 +3903,20 @@ static void
weston_compositor_dpms(struct weston_compositor *compositor,
enum dpms_enum state)
{
- struct weston_output *output;
+ struct weston_output *output;
+ struct weston_view *view;
+ uint32_t inhibited_outputs_mask = weston_output_inhibited_outputs(compositor);
- wl_list_for_each(output, &compositor->output_list, link)
- if (output->set_dpms)
- output->set_dpms(output, state);
+ wl_list_for_each(output, &compositor->output_list, link) {
+ if (!output->set_dpms)
+ continue;
+
+ /* If output is inhibited, don't do DPMS. */
+ if (inhibited_outputs_mask & (1 << output->id))
+ continue;
+
+ output->set_dpms(output, state);
+ }
}
WL_EXPORT void
diff --git a/src/compositor.h b/src/compositor.h
index 9a9ab1a..f9068c2 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1207,6 +1207,8 @@ void
weston_output_finish_frame(struct weston_output *output,
const struct timespec *stamp,
uint32_t presented_flags);
+uint32_t
+weston_output_inhibited_outputs(struct weston_compositor *compositor);
void
weston_output_schedule_repaint(struct weston_output *output);
void
--
1.9.1
More information about the wayland-devel
mailing list