[gnome-settings-daemon] power: Simplify non_laptop_outputs_are_all_off()



commit 59d9596ab8e8235c3c7600b788c256301c467a88
Author: Bastien Nocera <hadess hadess net>
Date:   Tue May 29 14:18:52 2012 +0100

    power: Simplify non_laptop_outputs_are_all_off()
    
    By not using an intermediary GnomeRRConfig.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677033

 plugins/power/gsd-power-manager.c |   35 ++++++++++++-----------------------
 1 files changed, 12 insertions(+), 23 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index d931861..f9daeb5 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -2248,43 +2248,32 @@ do_lid_open_action (GsdPowerManager *manager)
 }
 
 static gboolean
-is_laptop (GnomeRRScreen *screen, GnomeRROutputInfo *output)
+is_on (GnomeRROutput *output)
 {
-        GnomeRROutput *rr_output;
+	GnomeRRCrtc *crtc;
 
-        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);
+	crtc = gnome_rr_output_get_crtc (output);
+	if (!crtc)
+		return FALSE;
+	return gnome_rr_crtc_get_current_mode (crtc) != NULL;
 }
 
 static gboolean
 non_laptop_outputs_are_all_off (GnomeRRScreen *screen)
 {
-        GnomeRRConfig *config;
-        GnomeRROutputInfo **outputs;
+        GnomeRROutput **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);
+        outputs = gnome_rr_screen_list_outputs (screen);
         for (i = 0; outputs[i] != NULL; i++) {
-                if (is_laptop (screen, outputs[i]))
+                if (gnome_rr_output_is_laptop (outputs[i]))
                         continue;
 
-                if (gnome_rr_output_info_is_active (outputs[i])) {
-                        all_off = FALSE;
-                        goto out;
-                }
+                if (is_on (outputs[i]))
+                        return FALSE;
         }
 
-        all_off = TRUE;
-
-out:
-        g_object_unref (config);
-        return all_off;
+        return TRUE;
 }
 
 static void



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