[gnome-settings-daemon/benzea/brightness: 1/3] power: Wait for systemd SetBrightness call to complete
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/brightness: 1/3] power: Wait for systemd SetBrightness call to complete
- Date: Tue, 22 Mar 2022 16:06:58 +0000 (UTC)
commit 0e528aaa6b1dda5cb1c8c86bd7451c9808229c1b
Author: Benjamin Berg <bberg redhat com>
Date: Tue Mar 22 16:39:16 2022 +0100
power: Wait for systemd SetBrightness call to complete
This isn't really needed, but allows the test-suite to run without races
and needing explicit sleeps.
plugins/power/gsd-backlight.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/plugins/power/gsd-backlight.c b/plugins/power/gsd-backlight.c
index ca5f2723..8aca2c6c 100644
--- a/plugins/power/gsd-backlight.c
+++ b/plugins/power/gsd-backlight.c
@@ -459,6 +459,30 @@ gsd_backlight_get_brightness (GsdBacklight *backlight, gint *target)
return ABS_TO_PERCENTAGE (backlight->brightness_min, backlight->brightness_max,
backlight->brightness_val);
}
+#ifdef __linux__
+static void
+logind_set_brightness_cb (GObject *obj, GAsyncResult *res, gpointer user_data)
+{
+ GsdBacklight *backlight;
+ g_autoptr(GTask) task = user_data;
+ g_autoptr(GVariant) r = NULL;
+ g_autoptr(GError) error = NULL;
+ gint percent;
+
+ r = g_dbus_proxy_call_finish (G_DBUS_PROXY (obj), res, &error);
+
+ backlight = g_task_get_source_object (task);
+ percent = ABS_TO_PERCENTAGE (backlight->brightness_min,
+ backlight->brightness_max,
+ backlight->brightness_target);
+
+ if (error)
+ g_task_return_error (task, error);
+ else
+ g_task_return_int (task, percent);
+}
+#endif
+
static void
gsd_backlight_set_brightness_val_async (GsdBacklight *backlight,
int value,
@@ -491,7 +515,7 @@ gsd_backlight_set_brightness_val_async (GsdBacklight *backlight,
backlight->brightness_target),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL,
- NULL, NULL);
+ logind_set_brightness_cb, g_steal_pointer (&task));
percent = ABS_TO_PERCENTAGE (backlight->brightness_min,
backlight->brightness_max,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]