[gnome-settings-daemon] power: Add hack to reset IDLETIME counter



commit d14cc2ed60b671d2b1709e9fa12c78f2f0783541
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Jan 19 01:56:32 2013 +0100

    power: Add hack to reset IDLETIME counter

 configure.ac               |    2 +-
 plugins/power/gpm-common.c |   11 +++++++++++
 plugins/power/gpm-common.h |    1 +
 3 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d33ace0..dcf5983 100644
--- a/configure.ac
+++ b/configure.ac
@@ -234,7 +234,7 @@ PKG_CHECK_MODULES(SOUND, [libpulse >= $PA_REQUIRED_VERSION $GUDEV_PKG libpulse-m
 # ---------------------------------------------------------------------------
 # Power
 # ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(POWER, upower-glib >= $UPOWER_REQUIRED_VERSION gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION libcanberra-gtk3 libnotify x11 xext)
+PKG_CHECK_MODULES(POWER, upower-glib >= $UPOWER_REQUIRED_VERSION gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION libcanberra-gtk3 libnotify x11 xext xtst)
 
 if test x$have_gudev != xno; then
 	PKG_CHECK_MODULES(BACKLIGHT_HELPER,
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c
index 7360942..3bd8dc3 100644
--- a/plugins/power/gpm-common.c
+++ b/plugins/power/gpm-common.c
@@ -28,6 +28,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gdk/gdkx.h>
+#include <X11/extensions/XTest.h>
 
 #define GNOME_DESKTOP_USE_UNSTABLE_API
 #include <libgnome-desktop/gnome-rr.h>
@@ -1577,3 +1578,13 @@ backlight_set_abs (GnomeRRScreen *rr_screen,
 
         return ret;
 }
+
+void
+reset_idletime (void)
+{
+        gdk_error_trap_push ();
+        /* send a left shift key; first press, then release */
+        XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Shift_L, True, 0);
+        XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Shift_L, False, 0);
+        gdk_error_trap_pop_ignored ();
+}
diff --git a/plugins/power/gpm-common.h b/plugins/power/gpm-common.h
index d90424e..b949404 100644
--- a/plugins/power/gpm-common.h
+++ b/plugins/power/gpm-common.h
@@ -43,6 +43,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);
+void             reset_idletime                         (void);
 
 /* Backlight helpers */
 



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