[gnome-settings-daemon] power: Move external_monitor_is_connected() to helpers
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Move external_monitor_is_connected() to helpers
- Date: Tue, 22 Jan 2013 15:20:50 +0000 (UTC)
commit 1e29249448f8461b7ab140135be28b2c7447d3dc
Author: Bastien Nocera <hadess hadess net>
Date: Tue Jan 22 14:02:21 2013 +0100
power: Move external_monitor_is_connected() to helpers
Hopefully we can override the detection as well.
plugins/power/gpm-common.c | 28 ++++++++++++++++++++++++++++
plugins/power/gpm-common.h | 4 ++++
plugins/power/gsd-power-manager.c | 29 -----------------------------
3 files changed, 32 insertions(+), 29 deletions(-)
---
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index 3bd8dc3..fc8c0c5 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -1588,3 +1588,31 @@ reset_idletime (void)
XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Shift_L, False, 0);
gdk_error_trap_pop_ignored ();
}
+
+static gboolean
+randr_output_is_on (GnomeRROutput *output)
+{
+ GnomeRRCrtc *crtc;
+
+ crtc = gnome_rr_output_get_crtc (output);
+ if (!crtc)
+ return FALSE;
+ return gnome_rr_crtc_get_current_mode (crtc) != NULL;
+}
+
+gboolean
+external_monitor_is_connected (GnomeRRScreen *screen)
+{
+ GnomeRROutput **outputs;
+ guint i;
+
+ /* see if we have more than one screen plugged in */
+ outputs = gnome_rr_screen_list_outputs (screen);
+ for (i = 0; outputs[i] != NULL; i++) {
+ if (randr_output_is_on (outputs[i]) &&
+ !gnome_rr_output_is_laptop (outputs[i]))
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h
index b949404..b03b5b5 100644
--- a/plugins/power/gpm-common.h
+++ b/plugins/power/gpm-common.h
@@ -66,6 +66,10 @@ int backlight_step_down (GnomeRRScreen *rr_scree
int backlight_set_abs (GnomeRRScreen *rr_screen,
guint value,
GError **error);
+
+/* RandR helpers */
+gboolean external_monitor_is_connected (GnomeRRScreen *screen);
+
G_END_DECLS
#endif /* __GPMCOMMON_H */
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 8e920a1..3347bd3 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -226,7 +226,6 @@ static gdouble engine_get_percentage (GsdPowerManager *manager);
static void do_power_action_type (GsdPowerManager *manager, GsdPowerActionType action_type);
static void do_lid_closed_action (GsdPowerManager *manager);
static void uninhibit_lid_switch (GsdPowerManager *manager);
-static gboolean external_monitor_is_connected (GnomeRRScreen *screen);
static void main_battery_or_ups_low_changed (GsdPowerManager *manager, gboolean is_low);
G_DEFINE_TYPE (GsdPowerManager, gsd_power_manager, G_TYPE_OBJECT)
@@ -3191,34 +3190,6 @@ uninhibit_suspend (GsdPowerManager *manager)
manager->priv->inhibit_suspend_taken = FALSE;
}
-static gboolean
-randr_output_is_on (GnomeRROutput *output)
-{
- GnomeRRCrtc *crtc;
-
- crtc = gnome_rr_output_get_crtc (output);
- if (!crtc)
- return FALSE;
- return gnome_rr_crtc_get_current_mode (crtc) != NULL;
-}
-
-static gboolean
-external_monitor_is_connected (GnomeRRScreen *screen)
-{
- GnomeRROutput **outputs;
- guint i;
-
- /* see if we have more than one screen plugged in */
- outputs = gnome_rr_screen_list_outputs (screen);
- for (i = 0; outputs[i] != NULL; i++) {
- if (randr_output_is_on (outputs[i]) &&
- !gnome_rr_output_is_laptop (outputs[i]))
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
on_randr_event (GnomeRRScreen *screen, gpointer user_data)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]