[gnome-settings-daemon] power: Move screensaver watchdog to gpm-common
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Move screensaver watchdog to gpm-common
- Date: Wed, 16 Jan 2013 13:49:00 +0000 (UTC)
commit d6a4d975ce262ad7643a4d6e456fc42802d7a3c4
Author: Bastien Nocera <hadess hadess net>
Date: Wed Jan 16 13:12:04 2013 +0100
power: Move screensaver watchdog to gpm-common
plugins/power/gpm-common.c | 82 +++++++++++++++++++++++++++++++++++++
plugins/power/gpm-common.h | 1 +
plugins/power/gsd-power-manager.c | 79 +----------------------------------
3 files changed, 85 insertions(+), 77 deletions(-)
---
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index a9d8792..8b73954 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -27,9 +27,12 @@
#include <math.h>
#include <glib.h>
#include <glib/gi18n.h>
+#include <gdk/gdkx.h>
#include "gpm-common.h"
+#define XSCREENSAVER_WATCHDOG_TIMEOUT 120 /* seconds */
+
#define GPM_UP_TIME_PRECISION 5*60
#define GPM_UP_TEXT_MIN_TIME 120
@@ -1052,3 +1055,82 @@ out:
g_variant_unref (variant);
return ret;
}
+
+/* This timer goes off every few minutes, whether the user is idle or not,
+ to try and clean up anything that has gone wrong.
+
+ It calls disable_builtin_screensaver() so that if xset has been used,
+ or some other program (like xlock) has messed with the XSetScreenSaver()
+ settings, they will be set back to sensible values (if a server extension
+ is in use, messing with xlock can cause the screensaver to never get a wakeup
+ event, and could cause monitor power-saving to occur, and all manner of
+ heinousness.)
+
+ This code was originally part of gnome-screensaver, see
+ http://git.gnome.org/browse/gnome-screensaver/tree/src/gs-watcher-x11.c?id=fec00b12ec46c86334cfd36b37771cc4632f0d4d#n530
+ */
+static gboolean
+disable_builtin_screensaver (gpointer unused)
+{
+ int current_server_timeout, current_server_interval;
+ int current_prefer_blank, current_allow_exp;
+ int desired_server_timeout, desired_server_interval;
+ int desired_prefer_blank, desired_allow_exp;
+
+ XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ ¤t_server_timeout,
+ ¤t_server_interval,
+ ¤t_prefer_blank,
+ ¤t_allow_exp);
+
+ desired_server_timeout = current_server_timeout;
+ desired_server_interval = current_server_interval;
+ desired_prefer_blank = current_prefer_blank;
+ desired_allow_exp = current_allow_exp;
+
+ desired_server_interval = 0;
+
+ /* I suspect (but am not sure) that DontAllowExposures might have
+ something to do with powering off the monitor as well, at least
+ on some systems that don't support XDPMS? Who know... */
+ desired_allow_exp = AllowExposures;
+
+ /* When we're not using an extension, set the server-side timeout to 0,
+ so that the server never gets involved with screen blanking, and we
+ do it all ourselves. (However, when we *are* using an extension,
+ we tell the server when to notify us, and rather than blanking the
+ screen, the server will send us an X event telling us to blank.)
+ */
+ desired_server_timeout = 0;
+
+ if (desired_server_timeout != current_server_timeout
+ || desired_server_interval != current_server_interval
+ || desired_prefer_blank != current_prefer_blank
+ || desired_allow_exp != current_allow_exp) {
+
+ g_debug ("disabling server builtin screensaver:"
+ " (xset s %d %d; xset s %s; xset s %s)",
+ desired_server_timeout,
+ desired_server_interval,
+ (desired_prefer_blank ? "blank" : "noblank"),
+ (desired_allow_exp ? "expose" : "noexpose"));
+
+ XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ desired_server_timeout,
+ desired_server_interval,
+ desired_prefer_blank,
+ desired_allow_exp);
+
+ XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), FALSE);
+ }
+
+ return TRUE;
+}
+
+guint
+gsd_power_enable_screensaver_watchdog (void)
+{
+ return g_timeout_add_seconds (XSCREENSAVER_WATCHDOG_TIMEOUT,
+ disable_builtin_screensaver,
+ NULL);
+}
diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h
index 1117308..43223b8 100644
--- a/plugins/power/gpm-common.h
+++ b/plugins/power/gpm-common.h
@@ -42,6 +42,7 @@ gchar *gpm_upower_get_device_description (UpDevice *device)
/* Power helpers */
gboolean gsd_power_is_hardware_a_vm (void);
+guint gsd_power_enable_screensaver_watchdog (void);
G_END_DECLS
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 5d13750..a1ae57f 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -28,7 +28,6 @@
#include <stdio.h>
#include <sys/wait.h>
#include <glib/gi18n.h>
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <libupower-glib/upower.h>
#include <libnotify/notify.h>
@@ -85,8 +84,6 @@
/* Keep this in sync with gnome-shell */
#define SCREENSAVER_FADE_TIME 10 /* seconds */
-#define XSCREENSAVER_WATCHDOG_TIMEOUT 120 /* seconds */
-
static const gchar introspection_xml[] =
"<node>"
"<interface name='org.gnome.SettingsDaemon.Power'>"
@@ -3633,77 +3630,6 @@ engine_session_active_changed_cb (GDBusProxy *session,
idle_set_mode (manager, GSD_POWER_IDLE_MODE_NORMAL);
}
-/* This timer goes off every few minutes, whether the user is idle or not,
- to try and clean up anything that has gone wrong.
-
- It calls disable_builtin_screensaver() so that if xset has been used,
- or some other program (like xlock) has messed with the XSetScreenSaver()
- settings, they will be set back to sensible values (if a server extension
- is in use, messing with xlock can cause the screensaver to never get a wakeup
- event, and could cause monitor power-saving to occur, and all manner of
- heinousness.)
-
- This code was originally part of gnome-screensaver, see
- http://git.gnome.org/browse/gnome-screensaver/tree/src/gs-watcher-x11.c?id=fec00b12ec46c86334cfd36b37771cc4632f0d4d#n530
- */
-static gboolean
-disable_builtin_screensaver (gpointer unused)
-{
- int current_server_timeout, current_server_interval;
- int current_prefer_blank, current_allow_exp;
- int desired_server_timeout, desired_server_interval;
- int desired_prefer_blank, desired_allow_exp;
-
- XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- ¤t_server_timeout,
- ¤t_server_interval,
- ¤t_prefer_blank,
- ¤t_allow_exp);
-
- desired_server_timeout = current_server_timeout;
- desired_server_interval = current_server_interval;
- desired_prefer_blank = current_prefer_blank;
- desired_allow_exp = current_allow_exp;
-
- desired_server_interval = 0;
-
- /* I suspect (but am not sure) that DontAllowExposures might have
- something to do with powering off the monitor as well, at least
- on some systems that don't support XDPMS? Who know... */
- desired_allow_exp = AllowExposures;
-
- /* When we're not using an extension, set the server-side timeout to 0,
- so that the server never gets involved with screen blanking, and we
- do it all ourselves. (However, when we *are* using an extension,
- we tell the server when to notify us, and rather than blanking the
- screen, the server will send us an X event telling us to blank.)
- */
- desired_server_timeout = 0;
-
- if (desired_server_timeout != current_server_timeout
- || desired_server_interval != current_server_interval
- || desired_prefer_blank != current_prefer_blank
- || desired_allow_exp != current_allow_exp) {
-
- g_debug ("disabling server builtin screensaver:"
- " (xset s %d %d; xset s %s; xset s %s)",
- desired_server_timeout,
- desired_server_interval,
- (desired_prefer_blank ? "blank" : "noblank"),
- (desired_allow_exp ? "expose" : "noexpose"));
-
- XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- desired_server_timeout,
- desired_server_interval,
- desired_prefer_blank,
- desired_allow_exp);
-
- XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), FALSE);
- }
-
- return TRUE;
-}
-
static void
inhibit_lid_switch_done (GObject *source,
GAsyncResult *result,
@@ -4147,9 +4073,8 @@ gsd_power_manager_start (GsdPowerManager *manager,
/* set the initial dim time that can adapt for the user */
refresh_idle_dim_settings (manager);
- manager->priv->xscreensaver_watchdog_timer_id = g_timeout_add_seconds (XSCREENSAVER_WATCHDOG_TIMEOUT,
- disable_builtin_screensaver,
- NULL);
+ manager->priv->xscreensaver_watchdog_timer_id = gsd_power_enable_screensaver_watchdog ();
+
/* don't blank inside a VM */
manager->priv->is_virtual_machine = gsd_power_is_hardware_a_vm ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]