[gnome-settings-daemon] power: When disabling the backlight, also suspend on tablets



commit 983c54c46791ab91cb064db3f607a045749e27ca
Author: Bastien Nocera <hadess hadess net>
Date:   Sun Jan 25 08:20:08 2015 +0100

    power: When disabling the backlight, also suspend on tablets
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=743455 for
    details the full reasoning.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743456

 plugins/power/gpm-common.c        |   13 +++++++++++++
 plugins/power/gpm-common.h        |    1 +
 plugins/power/gsd-power-manager.c |    9 ++++++++-
 3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index b3eeeac..3cca737 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -191,6 +191,19 @@ out:
         return ret;
 }
 
+gboolean
+gsd_power_is_hardware_a_tablet (void)
+{
+        char *type;
+        gboolean ret = FALSE;
+
+        type = gnome_settings_get_chassis_type ();
+        ret = (g_strcmp0 (type, "tablet") == 0);
+        g_free (type);
+
+        return ret;
+}
+
 /* This timer goes off every few minutes, whether the user is idle or not,
    to try and clean up anything that has gone wrong.
 
diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h
index 481c358..381e7dd 100644
--- a/plugins/power/gpm-common.h
+++ b/plugins/power/gpm-common.h
@@ -32,6 +32,7 @@ gchar           *gpm_get_timestring                     (guint           time);
 
 /* Power helpers */
 gboolean         gsd_power_is_hardware_a_vm             (void);
+gboolean         gsd_power_is_hardware_a_tablet         (void);
 guint            gsd_power_enable_screensaver_watchdog  (void);
 void             reset_idletime                         (void);
 
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 83adbef..1ebc24d 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -168,6 +168,7 @@ struct GsdPowerManagerPrivate
         gboolean                 inhibit_suspend_taken;
         guint                    inhibit_lid_switch_timer_id;
         gboolean                 is_virtual_machine;
+        gboolean                 is_tablet;
 
         /* Idles */
         GnomeIdleMonitor        *idle_monitor;
@@ -1008,7 +1009,10 @@ backlight_disable (GsdPowerManager *manager)
                 g_error_free (error);
         }
 
-        screen_devices_disable (manager);
+        if (manager->priv->is_tablet)
+                action_suspend (manager);
+        else
+                screen_devices_disable (manager);
 
         g_debug ("TESTSUITE: Blanked screen");
 }
@@ -2409,6 +2413,9 @@ on_rr_screen_acquired (GObject      *object,
         /* don't blank inside a VM */
         manager->priv->is_virtual_machine = gsd_power_is_hardware_a_vm ();
 
+        /* Suspend when the screen is turned off on tablets */
+        manager->priv->is_tablet = gsd_power_is_hardware_a_tablet ();
+
         /* queue a signal in case the proxy from gnome-shell was created before we got here
            (likely, considering that to get here we need a reply from gnome-shell)
         */


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