summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2023-04-01 15:18:59 +0200
committerCarlos Garnacho <carlosg@gnome.org>2023-04-17 21:37:32 +0000
commite2b4264d84693a7869125ee99296b2324d1b7ec3 (patch)
treebbd3bb76f55967c2d5bb7b3df41dc073e12a481f
parente5b52d51d301bf19efc4211f2fa9f256f64a2a29 (diff)
downloadgnome-settings-daemon-e2b4264d84693a7869125ee99296b2324d1b7ec3.tar.gz
gsd-power-manager: Connect to light sensor async
Claiming the light sensor can take a noticeable amount of time when the sensor is being polled constantly (e.g. via monitor-sensor). Due to the function being invoked in backlight_enable this can lead to a noticeable delay when unblanking via key press. Fix this by claiming the sensor async. Fixes: https://gitlab.gnome.org/World/Phosh/phosh/-/issues/915
-rw-r--r--plugins/power/gsd-power-manager.c61
1 files changed, 47 insertions, 14 deletions
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 0263e9f6..dbdb6ab3 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -1186,10 +1186,48 @@ action_hibernate (GsdPowerManager *manager)
"Error calling Hibernate");
}
+
+static void
+light_claimed_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GsdPowerManager *manager = user_data;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GVariant) result = NULL;
+
+ result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
+ res,
+ &error);
+ if (result == NULL) {
+ g_warning ("Claiming light sensor failed: %s", error->message);
+ return;
+ }
+ iio_proxy_changed (manager);
+}
+
+
+static void
+light_released_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GVariant) result = NULL;
+
+ result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
+ res,
+ &error);
+ if (result == NULL) {
+ g_warning ("Release of light sensors failed: %s", error->message);
+ return;
+ }
+}
+
+
static void
iio_proxy_claim_light (GsdPowerManager *manager, gboolean active)
{
- GError *error = NULL;
if (manager->iio_proxy == NULL)
return;
if (!manager->backlight)
@@ -1211,19 +1249,14 @@ iio_proxy_claim_light (GsdPowerManager *manager, gboolean active)
g_signal_connect (manager->iio_proxy, "g-properties-changed",
G_CALLBACK (iio_proxy_changed_cb), manager);
- if (!g_dbus_proxy_call_sync (manager->iio_proxy,
- active ? "ClaimLight" : "ReleaseLight",
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error)) {
- g_warning ("Call to iio-proxy failed: %s", error->message);
- g_error_free (error);
- }
-
- if (active)
- iio_proxy_changed (manager);
+ g_dbus_proxy_call (manager->iio_proxy,
+ active ? "ClaimLight" : "ReleaseLight",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ manager->cancellable,
+ active ? light_claimed_cb : light_released_cb,
+ manager);
}
static void