[gnome-settings-daemon/gnome-3-18] power: Don't claim the light sensor if we're not active



commit 1fef9b74fd1e09e44b2bae7772385457356a3af6
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Apr 11 16:02:06 2016 +0200

    power: Don't claim the light sensor if we're not active
    
    Try not to claim the light sensor when our seat isn't active,
    as this will just throw PolicyKit errors about not being authorised,
    as happens with gdm trying to change the backlight when we're
    logged in.
    
    Also remove the calls to is_session_active() and use the cached variable
    when possible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764896

 plugins/power/gsd-power-manager.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index f657bd8..0e03878 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -141,6 +141,7 @@ struct GsdPowerManagerPrivate
         /* State */
         gboolean                 lid_is_present;
         gboolean                 lid_is_closed;
+        gboolean                 session_is_active;
         UpClient                *up_client;
         GPtrArray               *devices_array;
         UpDevice                *device_composite;
@@ -997,6 +998,8 @@ iio_proxy_claim_light (GsdPowerManager *manager, gboolean active)
                 return;
         if (!manager->priv->backlight_available)
                 return;
+       if (active != manager->priv->session_is_active)
+               return;
 
         if (!g_dbus_proxy_call_sync (manager->priv->iio_proxy,
                                      active ? "ClaimLight" : "ReleaseLight",
@@ -1487,7 +1490,6 @@ idle_set_mode (GsdPowerManager *manager, GsdPowerIdleMode mode)
         GError *error = NULL;
         gint idle_percentage;
         GsdPowerActionType action_type;
-        gboolean is_active = FALSE;
 
         /* Ignore attempts to set "less idle" modes */
         if (mode <= manager->priv->current_idle_mode &&
@@ -1499,8 +1501,7 @@ idle_set_mode (GsdPowerManager *manager, GsdPowerIdleMode mode)
         }
 
         /* ensure we're still on an active console */
-        is_active = is_session_active (manager);
-        if (!is_active) {
+        if (!manager->priv->session_is_active) {
                 g_debug ("ignoring state transition to %s as inactive",
                          idle_mode_to_string (mode));
                 return;
@@ -1674,7 +1675,7 @@ idle_configure (GsdPowerManager *manager)
         }
 
         /* are we inhibited from going idle */
-        if (!is_session_active (manager) || is_idle_inhibited) {
+        if (!manager->priv->session_is_active || is_idle_inhibited) {
                 if (is_idle_inhibited)
                         g_debug ("inhibited, so using normal state");
                 else
@@ -2163,6 +2164,7 @@ engine_session_properties_changed_cb (GDBusProxy      *session,
 
                 active = g_variant_get_boolean (v);
                 g_debug ("Received session is active change: now %s", active ? "active" : "inactive");
+                manager->priv->session_is_active = active;
                 /* when doing the fast-user-switch into a new account,
                  * ensure the new account is undimmed and with the backlight on */
                 if (active) {
@@ -2423,6 +2425,7 @@ on_rr_screen_acquired (GObject      *object,
         g_signal_connect (manager->priv->session, "g-properties-changed",
                           G_CALLBACK (engine_session_properties_changed_cb),
                           manager);
+        manager->priv->session_is_active = is_session_active (manager);
 
         manager->priv->screensaver_proxy = gnome_settings_bus_get_screen_saver_proxy ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]