gnome-power-manager r3185 - in trunk: . src



Author: rhughes
Date: Tue Jan 27 14:23:10 2009
New Revision: 3185
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3185&view=rev

Log:
2009-01-27  Richard Hughes  <richard hughsie com>

* src/gpm-backlight.c: (idle_changed_cb):
* src/gpm-idle.c: (gpm_idle_mode_to_text), (gpm_idle_set_mode),
(gpm_idle_set_check_cpu), (gpm_idle_get_mode),
(gpm_idle_set_timeout_dim), (gpm_idle_set_timeout_blank),
(gpm_idle_set_timeout_sleep), (gpm_idle_dim_cb),
(gpm_idle_blank_cb), (gpm_idle_sleep_cb), (gpm_idle_evaluate),
(gpm_idle_session_idle_changed_cb),
(gpm_idle_session_inhibited_changed_cb), (gpm_idle_finalize),
(gpm_idle_class_init), (gpm_idle_init):
* src/gpm-idle.h:
* src/gpm-manager.c: (gpm_manager_sync_policy_sleep),
(idle_changed_cb):
Rewrite the idle detection to use gnome-session rather than
gnome-screensaver. Completely untested, but it compiles.


Modified:
   trunk/ChangeLog
   trunk/src/gpm-backlight.c
   trunk/src/gpm-idle.c
   trunk/src/gpm-idle.h
   trunk/src/gpm-manager.c

Modified: trunk/src/gpm-backlight.c
==============================================================================
--- trunk/src/gpm-backlight.c	(original)
+++ trunk/src/gpm-backlight.c	Tue Jan 27 14:23:10 2009
@@ -633,12 +633,12 @@
 /**
  * idle_changed_cb:
  * @idle: The idle class instance
- * @mode: The idle mode, e.g. GPM_IDLE_MODE_SESSION
+ * @mode: The idle mode, e.g. GPM_IDLE_MODE_BLANK
  * @manager: This class instance
  *
  * This callback is called when gnome-screensaver detects that the idle state
- * has changed. GPM_IDLE_MODE_SESSION is when the session has become inactive,
- * and GPM_IDLE_MODE_SYSTEM is where the session has become inactive, AND the
+ * has changed. GPM_IDLE_MODE_BLANK is when the session has become inactive,
+ * and GPM_IDLE_MODE_SLEEP is where the session has become inactive, AND the
  * session timeout has elapsed for the idle action.
  **/
 static void
@@ -671,7 +671,7 @@
 		/* sync timeouts */
 		gpm_backlight_sync_policy (backlight);
 
-	} else if (mode == GPM_IDLE_MODE_SESSION) {
+	} else if (mode == GPM_IDLE_MODE_BLANK) {
 		/* activate display power management */
 		if (backlight->priv->can_dpms) {
 			error = NULL;
@@ -689,7 +689,7 @@
 		/* sync timeouts */
 		gpm_backlight_sync_policy (backlight);
 
-	} else if (mode == GPM_IDLE_MODE_POWERSAVE) {
+	} else if (mode == GPM_IDLE_MODE_DIM) {
 
 		/* sync lcd brightness */
 		gpm_backlight_notify_system_idle_changed (backlight, TRUE);

Modified: trunk/src/gpm-idle.c
==============================================================================
--- trunk/src/gpm-idle.c	(original)
+++ trunk/src/gpm-idle.c	Tue Jan 27 14:23:10 2009
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
  * Copyright (C) 2005 William Jon McCann <mccann jhu edu>
- * Copyright (C) 2005-2007 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2005-2009 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -39,34 +39,26 @@
 #include "gpm-idle.h"
 #include "gpm-load.h"
 #include "egg-debug.h"
-#include "gpm-screensaver.h"
-
-static void	gpm_idle_reset (GpmIdle *idle);
+#include "gpm-session.h"
 
 #define GPM_IDLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_IDLE, GpmIdlePrivate))
 
-/* How many seconds between polling? */
-#define POLL_FREQUENCY	5
-
 /* Sets the idle percent limit, i.e. how hard the computer can work
    while considered "at idle" */
-#define IDLE_LIMIT	5
+#define GPM_IDLE_CPU_LIMIT	5
 
 struct GpmIdlePrivate
 {
 	GpmLoad		*load;
-	GpmScreensaver	*screensaver;
+	GpmSession	*session;
 	GpmIdleMode	 mode;
-
-	guint		 system_timeout;	/* in seconds */
-	guint		 system_timer_id;
-	guint		 system_idle_timer_id;
-
+	guint		 timeout_dim;		/* in seconds */
+	guint		 timeout_blank;		/* in seconds */
+	guint		 timeout_sleep;		/* in seconds */
+	guint		 timeout_dim_id;
+	guint		 timeout_blank_id;
+	guint		 timeout_sleep_id;
 	gboolean	 check_type_cpu;
-
-	gboolean	 init;
-	long unsigned	 old_idle;
-	long unsigned	 old_total;
 };
 
 enum {
@@ -80,267 +72,254 @@
 G_DEFINE_TYPE (GpmIdle, gpm_idle, G_TYPE_OBJECT)
 
 /**
+ * gpm_idle_mode_to_text:
+ **/
+static const gchar *
+gpm_idle_mode_to_text (GpmIdleMode mode)
+{
+	if (mode == GPM_IDLE_MODE_NORMAL)
+		return "normal";
+	if (mode == GPM_IDLE_MODE_DIM)
+		return "dim";
+	if (mode == GPM_IDLE_MODE_BLANK)
+		return "blank";
+	if (mode == GPM_IDLE_MODE_SLEEP)
+		return "sleep";
+	return "unknown";
+}
+
+/**
  * gpm_idle_set_mode:
  * @idle: This class instance
- * @mode: The new mode, e.g. GPM_IDLE_MODE_SYSTEM
+ * @mode: The new mode, e.g. GPM_IDLE_MODE_SLEEP
  **/
-void
-gpm_idle_set_mode (GpmIdle    *idle,
-		   GpmIdleMode mode)
+static void
+gpm_idle_set_mode (GpmIdle *idle, GpmIdleMode mode)
 {
 	g_return_if_fail (GPM_IS_IDLE (idle));
 
 	if (mode != idle->priv->mode) {
 		idle->priv->mode = mode;
-
-		gpm_idle_reset (idle);
-
-		egg_debug ("Doing a state transition: %d", mode);
-		g_signal_emit (idle,
-			       signals [IDLE_CHANGED],
-			       0,
-			       mode);
+		egg_debug ("Doing a state transition: %s", gpm_idle_mode_to_text (mode));
+		g_signal_emit (idle, signals [IDLE_CHANGED], 0, mode);
 	}
 }
 
 /**
- * gpm_idle_poll_system_timer:
+ * gpm_idle_set_check_cpu:
  * @idle: This class instance
- * Return value: If the current load is low enough for the transition to occur.
+ * @check_type_cpu: If we should check the CPU before mode becomes
+ *		    GPM_IDLE_MODE_SLEEP and the event is done.
  **/
-static gboolean
-gpm_idle_poll_system_timer (GpmIdle *idle)
+void
+gpm_idle_set_check_cpu (GpmIdle *idle, gboolean check_type_cpu)
 {
-	gdouble  load;
-	gboolean do_action = TRUE;
-
-	/* get our computed load value */
-	if (idle->priv->check_type_cpu) {
-
-		load = gpm_load_get_current (idle->priv->load);
-
-		/* FIXME: should this stay below this level for a certain time? */
-		if (load > IDLE_LIMIT) {
-			/* check if system is "idle" enough */
-			egg_debug ("Detected that the CPU is busy");
-			do_action = FALSE;
-		}
-	}
-
-	if (do_action) {
-		gpm_idle_set_mode (idle, GPM_IDLE_MODE_SYSTEM);
-		idle->priv->system_idle_timer_id = 0;
-		return FALSE;
-	}
-
-	return TRUE;
+	g_return_if_fail (GPM_IS_IDLE (idle));
+	egg_debug ("Setting the CPU load check to %i", check_type_cpu);
+	idle->priv->check_type_cpu = check_type_cpu;
 }
 
 /**
- * gpm_idle_add_gpm_idle_poll_system_timer:
+ * gpm_idle_get_mode:
+ * @idle: This class instance
+ * Return value: The current mode, e.g. GPM_IDLE_MODE_SLEEP
  **/
-static void
-gpm_idle_add_gpm_idle_poll_system_timer (GpmIdle *idle,
-		       glong	timeout)
+GpmIdleMode
+gpm_idle_get_mode (GpmIdle *idle)
 {
-	idle->priv->system_idle_timer_id = g_timeout_add_seconds (timeout, (GSourceFunc)gpm_idle_poll_system_timer, idle);
+	return idle->priv->mode;
 }
 
 /**
- * gpm_idle_remove_gpm_idle_poll_system_timer:
+ * gpm_idle_set_timeout_dim:
+ * @idle: This class instance
+ * @timeout: The new timeout we want to set, in seconds
  **/
-static void
-gpm_idle_remove_gpm_idle_poll_system_timer (GpmIdle *idle)
+gboolean
+gpm_idle_set_timeout_dim (GpmIdle *idle, guint timeout)
 {
-	if (idle->priv->system_idle_timer_id != 0) {
-		g_source_remove (idle->priv->system_idle_timer_id);
-		idle->priv->system_idle_timer_id = 0;
+	g_return_val_if_fail (GPM_IS_IDLE (idle), FALSE);
+
+	egg_debug ("Setting dim idle timeout: %ds", timeout);
+	if (idle->priv->timeout_dim != timeout) {
+		idle->priv->timeout_dim = timeout;
+//		gpm_idle_reset (idle);
 	}
+	return TRUE;
 }
 
 /**
- * system_timer:
+ * gpm_idle_set_timeout_blank:
  * @idle: This class instance
- *
- * Instead of doing the state transition directly we wait until the
- * system is quiet
+ * @timeout: The new timeout we want to set, in seconds
  **/
-static gboolean
-system_timer (GpmIdle *idle)
+gboolean
+gpm_idle_set_timeout_blank (GpmIdle *idle, guint timeout)
 {
-	egg_debug ("System idle timeout");
+	g_return_val_if_fail (GPM_IS_IDLE (idle), FALSE);
 
-	gpm_idle_remove_gpm_idle_poll_system_timer (idle);
-	gpm_idle_add_gpm_idle_poll_system_timer (idle, POLL_FREQUENCY);
-
-	idle->priv->system_timer_id = 0;
-	return FALSE;
+	egg_debug ("Setting blank idle timeout: %ds", timeout);
+	if (idle->priv->timeout_blank != timeout) {
+		idle->priv->timeout_blank = timeout;
+//		gpm_idle_reset (idle);
+	}
+	return TRUE;
 }
 
 /**
- * gpm_idle_remove_system_timer:
+ * gpm_idle_set_timeout_sleep:
  * @idle: This class instance
+ * @timeout: The new timeout we want to set, in seconds
  **/
-static void
-gpm_idle_remove_system_timer (GpmIdle *idle)
+gboolean
+gpm_idle_set_timeout_sleep (GpmIdle *idle, guint timeout)
 {
-	if (idle->priv->system_timer_id != 0) {
-		g_source_remove (idle->priv->system_timer_id);
-		idle->priv->system_timer_id = 0;
+	g_return_val_if_fail (GPM_IS_IDLE (idle), FALSE);
+
+	egg_debug ("Setting sleep idle timeout: %ds", timeout);
+	if (idle->priv->timeout_sleep != timeout) {
+		idle->priv->timeout_sleep = timeout;
+//		gpm_idle_reset (idle);
 	}
+	return TRUE;
 }
 
 /**
- * gpm_idle_remove_all_timers:
- * @idle: This class instance
+ * gpm_idle_dim_cb:
  **/
-static void
-gpm_idle_remove_all_timers (GpmIdle *idle)
+static gboolean
+gpm_idle_dim_cb (GpmIdle *idle)
 {
-	gpm_idle_remove_gpm_idle_poll_system_timer (idle);
-	gpm_idle_remove_system_timer (idle);
+	if (idle->priv->mode > GPM_IDLE_MODE_DIM) {
+		egg_debug ("ignoring current mode %s", gpm_idle_mode_to_text (idle->priv->mode));
+		return FALSE;
+	}
+	gpm_idle_set_mode (idle, GPM_IDLE_MODE_DIM);
+	return FALSE;
 }
 
 /**
- * add_system_timer:
- * @idle: This class instance
- *
- * Adds a idle timeout if the value is greater than zero
+ * gpm_idle_blank_cb:
  **/
-static void
-add_system_timer (GpmIdle *idle)
+static gboolean
+gpm_idle_blank_cb (GpmIdle *idle)
 {
-	guint64 secs;
-
-	secs = idle->priv->system_timeout;
-
-	if (idle->priv->system_timeout > 0) {
-		idle->priv->system_timer_id = g_timeout_add_seconds (secs,
-							     (GSourceFunc)system_timer, idle);
-	} else {
-		egg_debug ("System idle disabled");
+	if (idle->priv->mode > GPM_IDLE_MODE_BLANK) {
+		egg_debug ("ignoring current mode %s", gpm_idle_mode_to_text (idle->priv->mode));
+		return FALSE;
 	}
+	gpm_idle_set_mode (idle, GPM_IDLE_MODE_BLANK);
+	return FALSE;
 }
 
 /**
- * gpm_idle_set_check_cpu:
- * @idle: This class instance
- * @check_type_cpu: If we should check the CPU before mode becomes
- *		    GPM_IDLE_MODE_SYSTEM and the event is done.
+ * gpm_idle_sleep_cb:
  **/
-void
-gpm_idle_set_check_cpu (GpmIdle    *idle,
-			gboolean    check_type_cpu)
+static gboolean
+gpm_idle_sleep_cb (GpmIdle *idle)
 {
-	g_return_if_fail (GPM_IS_IDLE (idle));
-	egg_debug ("Setting the CPU load check to %i", check_type_cpu);
-	idle->priv->check_type_cpu = check_type_cpu;
+	gdouble load;
+	gboolean ret = FALSE;
+
+	/* get our computed load value */
+	if (idle->priv->check_type_cpu) {
+		load = gpm_load_get_current (idle->priv->load);
+		/* FIXME: should this stay below this level for a certain time? */
+		if (load > GPM_IDLE_CPU_LIMIT) {
+			/* check if system is "idle" enough */
+			egg_debug ("Detected that the CPU is busy");
+			ret = TRUE;
+			goto out;
+		}
+	}
+	gpm_idle_set_mode (idle, GPM_IDLE_MODE_SLEEP);
+out:
+	return ret;
 }
 
 /**
- * gpm_idle_reset:
- * @idle: This class instance
- *
- * Reset the idle timer.
+ * gpm_idle_evaluate:
  **/
 static void
-gpm_idle_reset (GpmIdle *idle)
+gpm_idle_evaluate (GpmIdle *idle)
 {
-	g_return_if_fail (GPM_IS_IDLE (idle));
+	gboolean is_idle;
+	gboolean is_inhibited;
 
-	gpm_idle_remove_all_timers (idle);
+	is_idle = gpm_session_get_idle (idle->priv->session);
+	is_inhibited = gpm_session_get_inhibited (idle->priv->session);
 
-	if (idle->priv->mode == GPM_IDLE_MODE_NORMAL) {
-		/* do nothing */
-	} else if (idle->priv->mode == GPM_IDLE_MODE_SESSION) {
-		/* restart system idle timer */
-		add_system_timer (idle);
-	} else if (idle->priv->mode == GPM_IDLE_MODE_SYSTEM) {
-		/* do nothing? */
+	/* normal */
+	if (!is_idle || is_inhibited) {
+		if (idle->priv->timeout_dim_id != 0) {
+			g_source_remove (idle->priv->timeout_dim_id);
+			idle->priv->timeout_dim_id = 0;
+		}
+		if (idle->priv->timeout_blank_id != 0) {
+			g_source_remove (idle->priv->timeout_blank_id);
+			idle->priv->timeout_blank_id = 0;
+		}
+		if (idle->priv->timeout_sleep_id != 0) {
+			g_source_remove (idle->priv->timeout_sleep_id);
+			idle->priv->timeout_sleep_id = 0;
+		}
+		gpm_idle_set_mode (idle, GPM_IDLE_MODE_NORMAL);
+		return;
 	}
-}
 
-/**
- * gpm_idle_get_mode:
- * @idle: This class instance
- * Return value: The current mode, e.g. GPM_IDLE_MODE_SYSTEM
- **/
-GpmIdleMode
-gpm_idle_get_mode (GpmIdle *idle)
-{
-	GpmIdleMode mode;
-	mode = idle->priv->mode;
-	return mode;
-}
-
-/**
- * gpm_idle_set_system_timeout:
- * @idle: This class instance
- * @timeout: The new timeout we want to set, in seconds
- **/
-void
-gpm_idle_set_system_timeout (GpmIdle	*idle,
-			     guint	 timeout)
-{
-	g_return_if_fail (GPM_IS_IDLE (idle));
-
-	egg_debug ("Setting system idle timeout: %d", timeout);
-	if (idle->priv->system_timeout != timeout) {
-		idle->priv->system_timeout = timeout;
+	/* setup dim */
+	if (!is_idle && !is_inhibited) {
+		if (idle->priv->timeout_dim_id != 0)
+			idle->priv->timeout_dim_id = g_timeout_add_seconds (idle->priv->timeout_dim, (GSourceFunc) gpm_idle_dim_cb, idle);
+		if (idle->priv->timeout_blank_id != 0) {
+			g_source_remove (idle->priv->timeout_blank_id);
+			idle->priv->timeout_blank_id = 0;
+		}
+		if (idle->priv->timeout_sleep_id != 0) {
+			g_source_remove (idle->priv->timeout_sleep_id);
+			idle->priv->timeout_sleep_id = 0;
+		}
+		return;
+	}
 
-		/* restart the timers if necessary */
-		gpm_idle_reset (idle);
+	/* if there are any inhibits, clear the dim timeout */
+	if (is_idle) {
+		/* normal to dim */
+		if (idle->priv->mode == GPM_IDLE_MODE_NORMAL)
+			gpm_idle_set_mode (idle, GPM_IDLE_MODE_DIM);
+		if (idle->priv->timeout_blank_id != 0)
+			idle->priv->timeout_blank_id = g_timeout_add_seconds (idle->priv->timeout_blank, (GSourceFunc) gpm_idle_blank_cb, idle);
+		if (idle->priv->timeout_sleep_id != 0)
+			idle->priv->timeout_sleep_id = g_timeout_add_seconds (idle->priv->timeout_sleep, (GSourceFunc) gpm_idle_sleep_cb, idle);
 	}
 }
 
 /**
- * session_idle_changed_cb:
+ * gpm_idle_session_idle_changed_cb:
  * @is_idle: If the session is idle
  * @idle: This class instance
  *
- * The SessionIdleChanged callback from gnome-screensaver.
+ * The SessionIdleChanged callback from gnome-session.
  **/
 static void
-session_idle_changed_cb (GpmScreensaver *screensaver,
-			 gboolean	 is_idle,
-			 GpmIdle	*idle)
+gpm_idle_session_idle_changed_cb (GpmSession *session, gboolean is_idle, GpmIdle *idle)
 {
-	GpmIdleMode mode;
-
-	egg_debug ("Received GS session idle changed: %d", is_idle);
-
-	if (is_idle) {
-		mode = GPM_IDLE_MODE_SESSION;
-	} else {
-		mode = GPM_IDLE_MODE_NORMAL;
-	}
-
-	gpm_idle_set_mode (idle, mode);
+	egg_debug ("Received gnome session idle changed: %i", is_idle);
+	gpm_idle_evaluate (idle);
 }
 
 /**
- * powersave_idle_changed_cb:
+ * gpm_idle_session_inhibited_changed_cb:
  * @is_idle: If the session is idle
  * @idle: This class instance
  *
- * The SessionIdleChanged callback from gnome-screensaver.
+ * The SessionIdleChanged callback from gnome-session.
  **/
 static void
-powersave_idle_changed_cb (GpmScreensaver *screensaver,
-			  gboolean	 is_idle,
-			  GpmIdle	*idle)
+gpm_idle_session_inhibited_changed_cb (GpmSession *session, gboolean is_inhibited, GpmIdle *idle)
 {
-	GpmIdleMode mode;
-
-	egg_debug ("Received GS powesave idle changed: %d", is_idle);
-
-	if (is_idle) {
-		mode = GPM_IDLE_MODE_POWERSAVE;
-	} else {
-		mode = GPM_IDLE_MODE_NORMAL;
-	}
-
-	gpm_idle_set_mode (idle, mode);
+	egg_debug ("Received gnome session inhibited changed: %i", is_inhibited);
+	gpm_idle_evaluate (idle);
 }
 
 /**
@@ -359,9 +338,15 @@
 
 	g_return_if_fail (idle->priv != NULL);
 
+	if (idle->priv->timeout_dim_id != 0)
+		g_source_remove (idle->priv->timeout_dim_id);
+	if (idle->priv->timeout_blank_id != 0)
+		g_source_remove (idle->priv->timeout_blank_id);
+	if (idle->priv->timeout_sleep_id != 0)
+		g_source_remove (idle->priv->timeout_sleep_id);
+
 	g_object_unref (idle->priv->load);
-	g_object_unref (idle->priv->screensaver);
-	gpm_idle_remove_all_timers (idle);
+	g_object_unref (idle->priv->session);
 
 	G_OBJECT_CLASS (gpm_idle_parent_class)->finalize (object);
 }
@@ -382,11 +367,8 @@
 			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (GpmIdleClass, idle_changed),
-			      NULL,
-			      NULL,
-			      g_cclosure_marshal_VOID__INT,
-			      G_TYPE_NONE,
-			      1, G_TYPE_INT);
+			      NULL, NULL, g_cclosure_marshal_VOID__INT,
+			      G_TYPE_NONE, 1, G_TYPE_INT);
 
 	g_type_class_add_private (klass, sizeof (GpmIdlePrivate));
 }
@@ -395,7 +377,7 @@
  * gpm_idle_init:
  * @idle: This class instance
  *
- * Gets a DBUS connection, and aquires the screensaver connection so we can
+ * Gets a DBUS connection, and aquires the session connection so we can
  * get session changed events.
  *
  **/
@@ -404,13 +386,17 @@
 {
 	idle->priv = GPM_IDLE_GET_PRIVATE (idle);
 
-	idle->priv->system_timeout = G_MAXUINT;
+	idle->priv->timeout_dim = G_MAXUINT;
+	idle->priv->timeout_blank = G_MAXUINT;
+	idle->priv->timeout_sleep = G_MAXUINT;
+	idle->priv->timeout_dim_id = 0;
+	idle->priv->timeout_blank_id = 0;
+	idle->priv->timeout_sleep_id = 0;
 	idle->priv->load = gpm_load_new ();
-	idle->priv->screensaver = gpm_screensaver_new ();
-	g_signal_connect (idle->priv->screensaver, "session-idle-changed",
-			  G_CALLBACK (session_idle_changed_cb), idle);
-	g_signal_connect (idle->priv->screensaver, "powersave-idle-changed",
-			  G_CALLBACK (powersave_idle_changed_cb), idle);
+	idle->priv->session = gpm_session_new ();
+	g_signal_connect (idle->priv->session, "idle-changed", G_CALLBACK (gpm_idle_session_idle_changed_cb), idle);
+	g_signal_connect (idle->priv->session, "inhibited-changed", G_CALLBACK (gpm_idle_session_inhibited_changed_cb), idle);
+	gpm_idle_evaluate (idle);
 }
 
 /**

Modified: trunk/src/gpm-idle.h
==============================================================================
--- trunk/src/gpm-idle.h	(original)
+++ trunk/src/gpm-idle.h	Tue Jan 27 14:23:10 2009
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
  * Copyright (C) 2005 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2005-2008 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -35,9 +36,9 @@
 
 typedef enum {
 	GPM_IDLE_MODE_NORMAL,
-	GPM_IDLE_MODE_POWERSAVE,
-	GPM_IDLE_MODE_SESSION,
-	GPM_IDLE_MODE_SYSTEM
+	GPM_IDLE_MODE_DIM,
+	GPM_IDLE_MODE_BLANK,
+	GPM_IDLE_MODE_SLEEP
 } GpmIdleMode;
 
 typedef struct GpmIdlePrivate GpmIdlePrivate;
@@ -51,20 +52,20 @@
 typedef struct
 {
 	GObjectClass	parent_class;
-
 	void		(* idle_changed)		(GpmIdle	*idle,
 							 GpmIdleMode	 mode);
 } GpmIdleClass;
 
 GType		 gpm_idle_get_type			(void);
 GpmIdle		*gpm_idle_new				(void);
-
 GpmIdleMode	 gpm_idle_get_mode			(GpmIdle	*idle);
-void		 gpm_idle_set_mode			(GpmIdle	*idle,
-							 GpmIdleMode	 mode);
 void		 gpm_idle_set_check_cpu			(GpmIdle	*idle,
 							 gboolean	 check_type_cpu);
-void		 gpm_idle_set_system_timeout		(GpmIdle	*idle,
+gboolean	 gpm_idle_set_timeout_dim		(GpmIdle	*idle,
+							 guint		 timeout);
+gboolean	 gpm_idle_set_timeout_blank		(GpmIdle	*idle,
+							 guint		 timeout);
+gboolean	 gpm_idle_set_timeout_sleep		(GpmIdle	*idle,
 							 guint		 timeout);
 
 G_END_DECLS

Modified: trunk/src/gpm-manager.c
==============================================================================
--- trunk/src/gpm-manager.c	(original)
+++ trunk/src/gpm-manager.c	Tue Jan 27 14:23:10 2009
@@ -309,7 +309,9 @@
 	}
 
 	/* set the new sleep (inactivity) value */
-	gpm_idle_set_system_timeout (manager->priv->idle, sleep_computer);
+	gpm_idle_set_timeout_dim (manager->priv->idle, 5);
+	gpm_idle_set_timeout_blank (manager->priv->idle, sleep_display);
+	gpm_idle_set_timeout_sleep (manager->priv->idle, sleep_computer);
 }
 
 /**
@@ -700,12 +702,12 @@
 /**
  * idle_changed_cb:
  * @idle: The idle class instance
- * @mode: The idle mode, e.g. GPM_IDLE_MODE_SESSION
+ * @mode: The idle mode, e.g. GPM_IDLE_MODE_BLANK
  * @manager: This class instance
  *
  * This callback is called when gnome-screensaver detects that the idle state
- * has changed. GPM_IDLE_MODE_SESSION is when the session has become inactive,
- * and GPM_IDLE_MODE_SYSTEM is where the session has become inactive, AND the
+ * has changed. GPM_IDLE_MODE_BLANK is when the session has become inactive,
+ * and GPM_IDLE_MODE_SLEEP is where the session has become inactive, AND the
  * session timeout has elapsed for the idle action.
  **/
 static void
@@ -730,10 +732,10 @@
 	if (mode == GPM_IDLE_MODE_NORMAL) {
 		egg_debug ("Idle state changed: NORMAL");
 		gpm_brightness_kbd_undim (manager->priv->brightness_kbd);
-	} else if (mode == GPM_IDLE_MODE_SESSION) {
+	} else if (mode == GPM_IDLE_MODE_BLANK) {
 		egg_debug ("Idle state changed: SESSION");
 		gpm_brightness_kbd_dim (manager->priv->brightness_kbd);
-	} else if (mode == GPM_IDLE_MODE_SYSTEM) {
+	} else if (mode == GPM_IDLE_MODE_SLEEP) {
 		egg_debug ("Idle state changed: SYSTEM");
 		if (gpm_manager_is_inhibit_valid (manager, FALSE, "timeout action") == FALSE)
 			return;



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