Description: Manually check lid status in gpm_manager_client_changed_cb. Fixes
 double suspend issue
Author: Chow Loong Jin <hyperair@ubuntu.com>
Forwarded: yes
Bug-Ubuntu: https://bugs.launchpad.net/bugs/492649
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=604362
Index: gnome-power-manager-2.28.1/src/gpm-manager.c
===================================================================
--- gnome-power-manager-2.28.1.orig/src/gpm-manager.c	2010-01-12 16:53:51.565575219 +0800
+++ gnome-power-manager-2.28.1/src/gpm-manager.c	2010-01-12 17:03:36.373093231 +0800
@@ -820,6 +820,11 @@
 	gint timeout;
 	gboolean on_battery;
 
+	/* query lid position ourselves instead of checking GpmBacklight because
+	 * it may not have been updated yet. Fixes LP: #492649 */
+	gboolean lid_is_closed;
+	g_object_get (client, "lid-is-closed", &lid_is_closed, NULL);
+
 	/* get the on-battery state */
 	g_object_get (client,
 		      "on-battery", &on_battery,
@@ -855,7 +860,7 @@
 	gpm_manager_update_ac_throttle (manager);
 
 	/* simulate user input, but only when the lid is open */
-	if (!gpm_button_is_lid_closed (manager->priv->button))
+	if (!lid_is_closed)
 		gpm_screensaver_poke (manager->priv->screensaver);
 
 	if (!on_battery)
@@ -870,7 +875,7 @@
 	/* We keep track of the lid state so we can do the
 	   lid close on battery action if the ac adapter is removed when the laptop
 	   is closed. Fixes #331655 */
-	if (event_when_closed && on_battery && gpm_button_is_lid_closed (manager->priv->button)) {
+	if (event_when_closed && on_battery && lid_is_closed) {
 		gpm_manager_perform_policy (manager, GPM_CONF_BUTTON_LID_BATT,
 					    "The lid has been closed, and the ac adapter "
 					    "removed (and gconf is okay).");
