[gnome-settings-daemon: 39/39] Merge branch 'docking-stations' - bgo#663126



commit 6e17bc786f55f283f2c721249197e7740174fd43
Merge: 7675bff 7e238f2
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jan 10 18:09:18 2012 -0600

    Merge branch 'docking-stations' - bgo#663126
    
    This lets docking stations work better in the light of plugging external monitors.
    
    It used to be that a docked laptop, with a closed lid, would still keep the
    LCD active, thus making it pretty useless with an external monitor.
    
    Now, we disable the LCD if the laptop's lid is closed, as expected.
    Additionally, to decide when to suspend the laptop, we do so if there
    are no plugged or usable RANDR outputs.  For example, a docked laptop
    with a closed lid and *no* external monitor has no usable outputs, so
    it will get suspended.
    
    This requires gnome-desktop 3.3.4 or later, as the semantics of
    gnome_rr_screen_new() are slightly different there - now it returns a
    singleton instead of a new object every time.

 configure.ac                                   |    2 +-
 gnome-settings-daemon/Makefile.am              |    2 +
 gnome-settings-daemon/gnome-settings-session.c |   15 -
 gnome-settings-daemon/gnome-settings-session.h |    4 -
 plugins/color/gsd-color-manager.c              |    2 +-
 plugins/power/gsd-power-manager.c              |  107 ++++-
 plugins/xrandr/Makefile.am                     |    2 +
 plugins/xrandr/gsd-xrandr-manager.c            |  589 +++++++++++++++---------
 8 files changed, 453 insertions(+), 270 deletions(-)
---
diff --cc configure.ac
index 64f93d5,91f9a3a..895e443
--- a/configure.ac
+++ b/configure.ac
@@@ -45,10 -47,10 +45,10 @@@ dnl -----------------------------------
  
  DBUS_GLIB_REQUIRED_VERSION=0.74
  GLIB_REQUIRED_VERSION=2.29.14
 -GTK_REQUIRED_VERSION=2.99.3
 +GTK_REQUIRED_VERSION=3.3.4
  GCONF_REQUIRED_VERSION=2.6.1
  GIO_REQUIRED_VERSION=2.26.0
- GNOME_DESKTOP_REQUIRED_VERSION=3.3.1
+ GNOME_DESKTOP_REQUIRED_VERSION=3.3.4
  LIBNOTIFY_REQUIRED_VERSION=0.7.3
  UPOWER_GLIB_REQUIRED_VERSION=0.9.1
  PA_REQUIRED_VERSION=0.9.16
diff --cc plugins/power/gsd-power-manager.c
index b51d29d,1909a95..8d12c2c
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@@ -2147,22 -2089,50 +2147,62 @@@ do_lid_open_action (GsdPowerManager *ma
          if (!ret) {
                  g_warning ("failed to turn the panel on after lid open: %s",
                             error->message);
 -                g_error_free (error);
 +                g_clear_error (&error);
          }
 +
 +        /* only toggle keyboard if present and already toggled off */
 +        if (manager->priv->upower_kdb_proxy != NULL &&
 +            manager->priv->kbd_brightness_old != -1) {
 +                ret = upower_kbd_toggle (manager, &error);
 +                if (!ret) {
 +                        g_warning ("failed to turn the kbd backlight on: %s",
 +                                   error->message);
 +                        g_error_free (error);
 +                }
 +        }
 +
  }
  
+ static gboolean
+ is_laptop (GnomeRRScreen *screen, GnomeRROutputInfo *output)
+ {
+         GnomeRROutput *rr_output;
+ 
+         rr_output = gnome_rr_screen_get_output_by_name (screen, gnome_rr_output_info_get_name (output));
+ 
+         return gnome_rr_output_is_laptop (rr_output);
+ }
+ 
+ static gboolean
+ non_laptop_outputs_are_all_off (GnomeRRScreen *screen)
+ {
+         GnomeRRConfig *config;
+         GnomeRROutputInfo **outputs;
+         int i;
+         gboolean all_off;
+ 
+         config = gnome_rr_config_new_current (screen, NULL); /* NULL-GError */
+         if (!config)
+                 return FALSE;
+ 
+         outputs = gnome_rr_config_get_outputs (config);
+         for (i = 0; outputs[i] != NULL; i++) {
+                 if (is_laptop (screen, outputs[i]))
+                         continue;
+ 
+                 if (gnome_rr_output_info_is_active (outputs[i])) {
+                         all_off = FALSE;
+                         goto out;
+                 }
+         }
+ 
+         all_off = TRUE;
+ 
+ out:
+         g_object_unref (config);
+         return all_off;
+ }
+ 
  static void
  do_lid_closed_action (GsdPowerManager *manager)
  {
@@@ -2212,19 -2176,12 +2246,23 @@@
                  g_error_free (error);
          }
  
 +        /* only toggle keyboard if present and not already toggled */
 +        if (manager->priv->upower_kdb_proxy &&
 +            manager->priv->kbd_brightness_old == -1) {
 +                ret = upower_kbd_toggle (manager, &error);
 +                if (!ret) {
 +                        g_warning ("failed to turn the kbd backlight off: %s",
 +                                   error->message);
 +                        g_error_free (error);
 +                }
 +        }
 +
          /* perform policy action */
-         do_power_action_type (manager, action_type);
+         if (non_laptop_outputs_are_all_off (manager->priv->x11_screen)) {
+                 g_debug ("lid is closed; suspending or hibernating");
+                 do_power_action_type (manager, action_type);
+         } else
+                 g_debug ("lid is closed; not suspending nor hibernating since some external monitor outputs are still active");
  }
  
  



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