[gnome-flashback] monitor-manager: implement ChangeBacklight
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] monitor-manager: implement ChangeBacklight
- Date: Thu, 21 Sep 2017 00:09:24 +0000 (UTC)
commit 42a4173ed6f2338e8a81b64690b98a612f260e47
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Sep 21 02:28:11 2017 +0300
monitor-manager: implement ChangeBacklight
backends/gf-monitor-manager.c | 49 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 46 insertions(+), 3 deletions(-)
---
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index 61d8047..a7b3a31 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -775,9 +775,52 @@ gf_monitor_manager_handle_change_backlight (GfDBusDisplayConfig *skeleton,
guint output_index,
gint value)
{
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
- G_DBUS_ERROR_FAILED,
- "Not implemented");
+ GfMonitorManager *manager;
+ GfMonitorManagerClass *manager_class;
+ GfOutput *output;
+
+ manager = GF_MONITOR_MANAGER (skeleton);
+ manager_class = GF_MONITOR_MANAGER_GET_CLASS (skeleton);
+
+ if (serial != manager->serial)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_ACCESS_DENIED,
+ "The requested configuration is based on stale information");
+ return TRUE;
+ }
+
+ if (output_index >= manager->n_outputs)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_INVALID_ARGS,
+ "Invalid output id");
+ return TRUE;
+ }
+
+ output = &manager->outputs[output_index];
+
+ if (value < 0 || value > 100)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_INVALID_ARGS,
+ "Invalid backlight value");
+ return TRUE;
+ }
+
+ if (output->backlight == -1 ||
+ (output->backlight_min == 0 && output->backlight_max == 0))
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_INVALID_ARGS,
+ "Output does not support changing backlight");
+ return TRUE;
+ }
+
+ manager_class->change_backlight (manager, output, value);
+
+ gf_dbus_display_config_complete_change_backlight (skeleton, invocation,
+ output->backlight);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]