From 068591e395a9743b88e976634000e4cf9457fdc6 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 26 Dec 2011 21:30:37 +0100 Subject: [PATCH] output: add helper to check whether output is awake If we have only an output but not the related compositor we currently cannot figure out whether this output is awake. This adds such a helper function. Signed-off-by: David Herrmann --- src/output.c | 11 +++++++++++ src/output.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/output.c b/src/output.c index 857792f..a19adba 100644 --- a/src/output.c +++ b/src/output.c @@ -489,6 +489,17 @@ static int kmscon_output_connect(struct kmscon_output *output, drmModeRes *res, return 0; } +/* + * Returns true if the output is active and the related compositor is awake. + */ +bool kmscon_output_is_awake(struct kmscon_output *output) +{ + if (!output) + return NULL; + + return output->active && !kmscon_compositor_is_asleep(output->comp); +} + /* * Returns the next output in the list. If there is no next output or the * output is not bound to any compositor, then it returns NULL. diff --git a/src/output.h b/src/output.h index e2b89e9..31dd0f1 100644 --- a/src/output.h +++ b/src/output.h @@ -81,6 +81,7 @@ int kmscon_output_new(struct kmscon_output **out); void kmscon_output_ref(struct kmscon_output *output); void kmscon_output_unref(struct kmscon_output *output); +bool kmscon_output_is_awake(struct kmscon_output *output); struct kmscon_output *kmscon_output_next(struct kmscon_output *output); struct kmscon_mode *kmscon_output_get_modes(struct kmscon_output *output); struct kmscon_mode *kmscon_output_get_current(struct kmscon_output *output);