gnome-power-manager r3031 - in trunk: . src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r3031 - in trunk: . src
- Date: Wed, 22 Oct 2008 10:40:05 +0000 (UTC)
Author: rhughes
Date: Wed Oct 22 10:40:05 2008
New Revision: 3031
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3031&view=rev
Log:
2008-10-22 Richard Hughes <richard hughsie com>
* src/Makefile.am:
* src/gpm-info.c: (gpm_info_init), (gpm_info_finalize):
* src/gpm-manager.c: (update_dpms_throttle), (update_ac_throttle),
(update_lid_throttle), (button_pressed_cb),
(ac_adapter_changed_cb), (screensaver_auth_request_cb),
(dpms_mode_changed_cb), (gpm_manager_init), (gpm_manager_finalize):
* src/gpm-srv-screensaver.c:
* src/gpm-srv-screensaver.h:
Remove the state setting parts of GpmScreensaver into GpmManager.
Removed:
trunk/src/gpm-srv-screensaver.c
trunk/src/gpm-srv-screensaver.h
Modified:
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/gpm-info.c
trunk/src/gpm-manager.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Oct 22 10:40:05 2008
@@ -163,8 +163,6 @@
gpm-backlight.c \
gpm-prefs-server.h \
gpm-prefs-server.c \
- gpm-srv-screensaver.h \
- gpm-srv-screensaver.c \
gpm-idle.h \
gpm-idle.c \
gpm-load.h \
Modified: trunk/src/gpm-info.c
==============================================================================
--- trunk/src/gpm-info.c (original)
+++ trunk/src/gpm-info.c Wed Oct 22 10:40:05 2008
@@ -34,7 +34,6 @@
#include "gpm-control.h"
#include "gpm-common.h"
#include "egg-debug.h"
-#include "gpm-dpms.h"
#include "gpm-info.h"
#include "gpm-profile.h"
#include "gpm-array.h"
@@ -65,7 +64,6 @@
struct GpmInfoPrivate
{
GpmControl *control;
- GpmDpms *dpms;
GpmProfile *profile;
GpmEngineCollection *collection;
@@ -624,28 +622,6 @@
}
/**
- * dpms_mode_changed_cb:
- * @mode: The DPMS mode, e.g. GPM_DPMS_MODE_OFF
- * @info: This class instance
- *
- * Log when the DPMS mode is changed.
- **/
-static void
-dpms_mode_changed_cb (GpmDpms *dpms, GpmDpmsMode mode, GpmInfo *info)
-{
- egg_debug ("DPMS mode changed: %d", mode);
-
- if (mode == GPM_DPMS_MODE_ON)
- gpm_info_event_log (info, GPM_EVENT_DPMS_ON, _("dpms on"));
- else if (mode == GPM_DPMS_MODE_STANDBY)
- gpm_info_event_log (info, GPM_EVENT_DPMS_STANDBY, _("dpms standby"));
- else if (mode == GPM_DPMS_MODE_SUSPEND)
- gpm_info_event_log (info, GPM_EVENT_DPMS_SUSPEND, _("dpms suspend"));
- else if (mode == GPM_DPMS_MODE_OFF)
- gpm_info_event_log (info, GPM_EVENT_DPMS_OFF, _("dpms off"));
-}
-
-/**
* control_resume_cb:
* @control: The control class instance
* @info: This class instance
@@ -694,10 +670,6 @@
/* set default, we have to set these from the manager */
info->priv->profile = gpm_profile_new ();
- /* watch for dpms mode changes */
- info->priv->dpms = gpm_dpms_new ();
- g_signal_connect (info->priv->dpms, "mode-changed", G_CALLBACK (dpms_mode_changed_cb), info);
-
/* set to a blank list */
info->priv->events = gpm_array_new ();
if (info->priv->is_laptop) {
@@ -753,8 +725,6 @@
g_object_unref (info->priv->time_data);
if (info->priv->voltage_data)
g_object_unref (info->priv->voltage_data);
- if (info->priv->dpms != NULL)
- g_object_unref (info->priv->dpms);
if (info->priv->control != NULL)
g_object_unref (info->priv->control);
g_object_unref (info->priv->events);
Modified: trunk/src/gpm-manager.c
==============================================================================
--- trunk/src/gpm-manager.c (original)
+++ trunk/src/gpm-manager.c Wed Oct 22 10:40:05 2008
@@ -60,7 +60,7 @@
#include "gpm-screensaver.h"
#include "gpm-backlight.h"
#include "gpm-brightness-kbd.h"
-#include "gpm-srv-screensaver.h"
+#include "gpm-screensaver.h"
#include "gpm-stock-icons.h"
#include "gpm-prefs-server.h"
#include "gpm-tray-icon.h"
@@ -97,10 +97,10 @@
gboolean low_power;
GpmBrightnessKbd *brightness_kbd;
GpmFeedback *feedback_kbd;
-
- /* interactive services */
GpmBacklight *backlight;
- GpmSrvScreensaver *srv_screensaver;
+ guint32 screensaver_ac_throttle_id;
+ guint32 screensaver_dpms_throttle_id;
+ guint32 screensaver_lid_throttle_id;
};
enum {
@@ -1011,6 +1011,63 @@
_("The lid has been closed on battery power."));
}
+static void
+update_dpms_throttle (GpmManager *manager)
+{
+ GpmDpmsMode mode;
+ gpm_dpms_get_mode_enum (manager->priv->dpms, &mode, NULL);
+
+ /* Throttle the manager when DPMS is active since we can't see it anyway */
+ if (mode == GPM_DPMS_MODE_ON) {
+ if (manager->priv->screensaver_dpms_throttle_id != 0) {
+ gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_dpms_throttle_id);
+ manager->priv->screensaver_dpms_throttle_id = 0;
+ }
+ } else {
+ /* if throttle already exists then remove */
+ if (manager->priv->screensaver_dpms_throttle_id != 0) {
+ gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_dpms_throttle_id);
+ }
+ manager->priv->screensaver_dpms_throttle_id = gpm_screensaver_add_throttle (manager->priv->screensaver, _("Display DPMS activated"));
+ }
+}
+
+static void
+update_ac_throttle (GpmManager *manager, gboolean on_ac)
+{
+ /* Throttle the manager when we are not on AC power so we don't
+ waste the battery */
+ if (on_ac) {
+ if (manager->priv->screensaver_ac_throttle_id != 0) {
+ gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_ac_throttle_id);
+ manager->priv->screensaver_ac_throttle_id = 0;
+ }
+ } else {
+ /* if throttle already exists then remove */
+ if (manager->priv->screensaver_ac_throttle_id != 0)
+ gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_ac_throttle_id);
+ manager->priv->screensaver_ac_throttle_id = gpm_screensaver_add_throttle (manager->priv->screensaver, _("On battery power"));
+ }
+}
+
+static void
+update_lid_throttle (GpmManager *manager, gboolean lid_is_closed)
+{
+ /* Throttle the screensaver when the lid is close since we can't see it anyway
+ and it may overheat the laptop */
+ if (lid_is_closed == FALSE) {
+ if (manager->priv->screensaver_lid_throttle_id != 0) {
+ gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_lid_throttle_id);
+ manager->priv->screensaver_lid_throttle_id = 0;
+ }
+ } else {
+ /* if throttle already exists then remove */
+ if (manager->priv->screensaver_lid_throttle_id != 0)
+ gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_lid_throttle_id);
+ manager->priv->screensaver_lid_throttle_id = gpm_screensaver_add_throttle (manager->priv->screensaver, _("Laptop lid is closed"));
+ }
+}
+
/**
* button_pressed_cb:
* @power: The power class instance
@@ -1043,6 +1100,16 @@
else if (strcmp (type, GPM_BUTTON_BATTERY) == 0)
battery_button_pressed (manager);
+ /* really belongs in gnome-manager */
+ if (strcmp (type, GPM_BUTTON_LOCK) == 0)
+ gpm_screensaver_lock (manager->priv->screensaver);
+ /* Disable or enable the fancy manager, as we don't want
+ * this starting when the lid is shut */
+ if (strcmp (type, GPM_BUTTON_LID_CLOSED) == 0)
+ update_lid_throttle (manager, TRUE);
+ else if (strcmp (type, GPM_BUTTON_LID_OPEN) == 0)
+ update_lid_throttle (manager, FALSE);
+
if ((strcmp (type, GPM_BUTTON_KBD_BRIGHT_UP) == 0))
gpm_brightness_kbd_up (manager->priv->brightness_kbd);
else if ((strcmp (type, GPM_BUTTON_KBD_BRIGHT_DOWN) == 0))
@@ -1081,6 +1148,12 @@
gpm_manager_sync_policy_sleep (manager);
+ update_ac_throttle (manager, on_ac);
+
+ /* simulate user input, but only when the lid is open */
+ if (gpm_button_is_lid_closed (manager->priv->button) == FALSE)
+ gpm_screensaver_poke (manager->priv->screensaver);
+
if (on_ac)
gpm_manager_play (manager, GPM_MANAGER_SOUND_POWER_PLUG, FALSE);
else
@@ -1289,7 +1362,7 @@
GError *error;
gboolean ret;
/* only clear errors if we have finished the authentication */
- if (auth_begin == FALSE) {
+ if (!auth_begin) {
error = NULL;
ret = hal_device_power_clear_suspend_error (manager->priv->hal_device_power, &error);
if (!ret) {
@@ -1303,6 +1376,23 @@
g_error_free (error);
}
}
+
+ if (auth_begin) {
+ GError *error = NULL;
+
+ /* TODO: This may be a bid of a bodge, as we will have multiple
+ resume requests -- maybe this need a logic cleanup */
+ gpm_brightness_kbd_undim (manager->priv->brightness_kbd);
+
+ /* We turn on the monitor unconditionally, as we may be using
+ * a smartcard to authenticate and DPMS might still be on.
+ * See #350291 for more details */
+ gpm_dpms_set_mode_enum (manager->priv->dpms, GPM_DPMS_MODE_ON, &error);
+ if (error != NULL) {
+ egg_warning ("Failed to turn on DPMS: %s", error->message);
+ g_error_free (error);
+ }
+ }
}
/**
@@ -1742,6 +1832,30 @@
}
/**
+ * dpms_mode_changed_cb:
+ * @mode: The DPMS mode, e.g. GPM_DPMS_MODE_OFF
+ * @info: This class instance
+ *
+ * Log when the DPMS mode is changed.
+ **/
+static void
+dpms_mode_changed_cb (GpmDpms *dpms, GpmDpmsMode mode, GpmManager *manager)
+{
+ egg_debug ("DPMS mode changed: %d", mode);
+
+ if (mode == GPM_DPMS_MODE_ON)
+ gpm_info_event_log (manager->priv->info, GPM_EVENT_DPMS_ON, _("dpms on"));
+ else if (mode == GPM_DPMS_MODE_STANDBY)
+ gpm_info_event_log (manager->priv->info, GPM_EVENT_DPMS_STANDBY, _("dpms standby"));
+ else if (mode == GPM_DPMS_MODE_SUSPEND)
+ gpm_info_event_log (manager->priv->info, GPM_EVENT_DPMS_SUSPEND, _("dpms suspend"));
+ else if (mode == GPM_DPMS_MODE_OFF)
+ gpm_info_event_log (manager->priv->info, GPM_EVENT_DPMS_OFF, _("dpms off"));
+
+ update_dpms_throttle (manager);
+}
+
+/**
* gpm_manager_init:
* @manager: This class instance
**/
@@ -1758,6 +1872,11 @@
manager->priv = GPM_MANAGER_GET_PRIVATE (manager);
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ /* init to unthrottled */
+ manager->priv->screensaver_ac_throttle_id = 0;
+ manager->priv->screensaver_dpms_throttle_id = 0;
+ manager->priv->screensaver_lid_throttle_id = 0;
+
/* do some actions even when killed */
g_atexit (gpm_manager_at_exit);
@@ -1809,7 +1928,6 @@
manager->priv->screensaver = gpm_screensaver_new ();
g_signal_connect (manager->priv->screensaver, "auth-request",
G_CALLBACK (screensaver_auth_request_cb), manager);
- manager->priv->srv_screensaver = gpm_srv_screensaver_new ();
/* try an start an interactive service */
manager->priv->backlight = gpm_backlight_new ();
@@ -1838,6 +1956,8 @@
gpm_idle_set_check_cpu (manager->priv->idle, check_type_cpu);
manager->priv->dpms = gpm_dpms_new ();
+ g_signal_connect (manager->priv->dpms, "mode-changed",
+ G_CALLBACK (dpms_mode_changed_cb), manager);
/* use a class to handle the complex stuff */
egg_debug ("creating new inhibit instance");
@@ -1899,6 +2019,10 @@
gpm_engine_start (manager->priv->engine);
+ /* update ac throttle */
+ on_ac = gpm_ac_adapter_is_present (manager->priv->ac_adapter);
+ update_ac_throttle (manager, on_ac);
+
collection = gpm_engine_get_collection (manager->priv->engine);
gpm_tray_icon_set_collection_data (manager->priv->tray_icon, collection);
gpm_info_set_collection_data (manager->priv->info, collection);
@@ -1933,7 +2057,6 @@
g_object_unref (manager->priv->inhibit);
g_object_unref (manager->priv->screensaver);
g_object_unref (manager->priv->notify);
- g_object_unref (manager->priv->srv_screensaver);
g_object_unref (manager->priv->prefs_server);
g_object_unref (manager->priv->control);
g_object_unref (manager->priv->feedback_kbd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]