diff options
author | Bastien Nocera <hadess@hadess.net> | 2012-05-29 14:18:52 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2012-05-30 11:47:59 +0100 |
commit | 59d9596ab8e8235c3c7600b788c256301c467a88 (patch) | |
tree | 6b1160863c2a322ac16eda4bfb19296c2df56e12 | |
parent | 7e87d46ade351e6f59de38923f266e79d5d92db0 (diff) | |
download | gnome-settings-daemon-59d9596ab8e8235c3c7600b788c256301c467a88.tar.gz |
power: Simplify non_laptop_outputs_are_all_off()
By not using an intermediary GnomeRRConfig.
https://bugzilla.gnome.org/show_bug.cgi?id=677033
-rw-r--r-- | 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 d9318613..f9daeb54 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 |