Bug#458041: [tvtime] patch
tag 458041 + patch
severity 458041 important
thanks
Package: tvtime
Version: 1.0.2-1
This is tvtimes way to disable the screensaver. It is the most stupid and
annoying way to do it (ok, pseudo pressing "tvtime is cool" would be more
annoying). Other programs do that differently (for example kaffeine which I
use for dvb).
I change the severity because it makes the package unusable when doing
anything else then watching tv.
PS: This is just a raw, relative undebianised patch.
--- System information. ---
Architecture: amd64
Kernel: Linux 2.6.26-1-amd64
Debian Release: 5.0
500 unstable ftp.debian.org
500 unstable debian.netcologne.de
1 experimental ftp.debian.org
--- Package information. ---
Depends (Version) | Installed
==============================-+-==============
libc6 (>= 2.7-1) | 2.7-16
libfreetype6 (>= 2.3.5) | 2.3.7-2
libgcc1 (>= 1:4.1.1) | 1:4.3.2-1
libice6 (>= 1:1.0.0) | 2:1.0.4-1
libpng12-0 (>= 1.2.13-4) | 1.2.27-2
libsm6 | 2:1.1.0-1
libstdc++6 (>= 4.1.1) | 4.3.2-1
libx11-6 | 2:1.1.5-2
libxext6 | 2:1.0.4-1
libxinerama1 | 2:1.0.3-2
libxml2 (>= 2.6.27) | 2.6.32.dfsg-5
libxtst6 | 2:1.0.3-1
libxv1 | 2:1.0.4-1
libxxf86vm1 | 1:1.0.2-1
zlib1g (>= 1:1.1.4) | 1:1.2.3.3.dfsg-12
debconf (>= 0.5) | 1.5.24
OR debconf-2.0 |
ttf-freefont | 20080323-3
ucf | 3.0011
makedev | 2.3.1-88
From 5aeb87da2e158ca37dcbf1b7534f29bb7bb4bdd2 Mon Sep 17 00:00:00 2001
From: Resul Cetin <resul-cetin@gmx.net>
Date: Thu, 11 Dec 2008 17:50:28 +0100
Subject: [PATCH] Use XScreenSaverExtension instead of typing text via Xtest
---
config.h.in | 2 +-
configure | 26 ++++++++++----------
configure.ac | 8 +++---
debian/control | 2 +-
src/xcommon.c | 70 +++++++++++++++++--------------------------------------
src/xcommon.h | 1 -
src/xvoutput.c | 1 -
7 files changed, 41 insertions(+), 69 deletions(-)
diff --git a/config.h.in b/config.h.in
index 6180c73..455e380 100644
--- a/config.h.in
+++ b/config.h.in
@@ -296,7 +296,7 @@
#undef HAVE_XINERAMA
/* XTest support */
-#undef HAVE_XTESTEXTENSION
+#undef HAVE_XSSEXTENSION
/* Xv support */
#undef HAVE_XV
diff --git a/configure b/configure
index a6c5138..6c2dd5e 100755
--- a/configure
+++ b/configure
@@ -25906,13 +25906,13 @@ _ACEOF
fi
- echo "$as_me:$LINENO: checking for XTestFakeKeyEvent in -lXtst" >&5
-echo $ECHO_N "checking for XTestFakeKeyEvent in -lXtst... $ECHO_C" >&6
-if test "${ac_cv_lib_Xtst_XTestFakeKeyEvent+set}" = set; then
+ echo "$as_me:$LINENO: checking for XScreenSaverSuspend in -lXss" >&5
+echo $ECHO_N "checking for XScreenSaverSuspend in -lXss... $ECHO_C" >&6
+if test "${ac_cv_lib_Xss_XScreenSaverSuspend+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXtst $X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext $LIBS"
+LIBS="-lXss $X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -25926,11 +25926,11 @@ extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char XTestFakeKeyEvent ();
+char XScreenSaverSuspend ();
int
main ()
{
-XTestFakeKeyEvent ();
+XScreenSaverSuspend ();
;
return 0;
}
@@ -25956,26 +25956,26 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_lib_Xtst_XTestFakeKeyEvent=yes
+ ac_cv_lib_Xss_XScreenSaverSuspend=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-ac_cv_lib_Xtst_XTestFakeKeyEvent=no
+ac_cv_lib_Xss_XScreenSaverSuspend=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_Xtst_XTestFakeKeyEvent" >&5
-echo "${ECHO_T}$ac_cv_lib_Xtst_XTestFakeKeyEvent" >&6
-if test $ac_cv_lib_Xtst_XTestFakeKeyEvent = yes; then
+echo "$as_me:$LINENO: result: $ac_cv_lib_Xss_XScreenSaverSuspend" >&5
+echo "${ECHO_T}$ac_cv_lib_Xss_XScreenSaverSuspend" >&6
+if test $ac_cv_lib_Xss_XScreenSaverSuspend = yes; then
cat >>confdefs.h <<\_ACEOF
-#define HAVE_XTESTEXTENSION
+#define HAVE_XSSEXTENSION
_ACEOF
- X11_LIBS="$X11_LIBS -lXtst"
+ X11_LIBS="$X11_LIBS -lXss"
fi
diff --git a/configure.ac b/configure.ac
index 9692b31..ee240df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,10 +118,10 @@ if test x"$no_x" != x"yes"; then
X11_LIBS="$X11_LIBS -lXinerama"],,
[$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext])
- dnl check for XTest
- AC_CHECK_LIB([Xtst],[XTestFakeKeyEvent],
- [AC_DEFINE([HAVE_XTESTEXTENSION],,[XTest support])
- X11_LIBS="$X11_LIBS -lXtst"],,
+ dnl check for XSs
+ AC_CHECK_LIB([Xss],[XScreenSaverSuspend],
+ [AC_DEFINE([HAVE_XSSEXTENSION],,[XSs support])
+ X11_LIBS="$X11_LIBS -lXss"],,
[$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext])
dnl check for Xvidmode
diff --git a/debian/control b/debian/control
index 2479259..2b38e42 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: x11
Priority: optional
Maintainer: Debian QA Group <packages@qa.debian.org>
Build-Depends: debhelper (>= 7), zlib1g-dev, libpng-dev, libfreetype6-dev, libx11-dev, libxext-dev, libxinerama-dev,
- libxt-dev, libxtst-dev, libxv-dev, libxxf86vm-dev, libxml2-dev, fontforge
+ libxt-dev, libxss-dev, libxv-dev, libxxf86vm-dev, libxml2-dev, fontforge
Standards-Version: 3.6.2
Homepage: http://tvtime.net/
diff --git a/src/xcommon.c b/src/xcommon.c
index 8e3be4c..f030a9b 100644
--- a/src/xcommon.c
+++ b/src/xcommon.c
@@ -45,8 +45,8 @@
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include <X11/extensions/XShm.h>
-#ifdef HAVE_XTESTEXTENSION
-#include <X11/extensions/XTest.h>
+#ifdef HAVE_XSSEXTENSION
+#include <X11/extensions/scrnsaver.h>
#endif
#include "xfullscreen.h"
@@ -54,9 +54,6 @@
#include "utils.h"
#include "xcommon.h"
-/* Every 30 seconds, ping the screensaver. */
-#define SCREENSAVER_PING_TIME (30 * 1000 * 1000)
-
/* Useful. */
#define MIN(x,y)((x)<(y)?(x):(y))
#define MAX(x,y)((x)>(y)?(x):(y))
@@ -67,7 +64,7 @@ static Window wm_window;
static Window fs_window;
static Window output_window;
static GC gc;
-static int have_xtest;
+static int have_xss;
static int output_width, output_height;
static int output_aspect;
static int output_on_root;
@@ -107,10 +104,6 @@ static Atom wm_delete_window;
static Atom xawtv_station;
static Atom xawtv_remote;
-#ifdef HAVE_XTESTEXTENSION
-static KeyCode kc_shift_l; /* Fake key to send. */
-#endif
-
static area_t video_area;
static area_t window_area;
static area_t scale_area;
@@ -248,12 +241,12 @@ static void x11_wait_mapped( Display *dpy, Window win )
} while ( (event.type != MapNotify) || (event.xmap.event != win) );
}
-static int have_xtestextention( void )
+static int have_xssextention( void )
{
-#ifdef HAVE_XTESTEXTENSION
- int dummy1, dummy2, dummy3, dummy4;
+#ifdef HAVE_XSSEXTENSION
+ int dummy1, dummy2;
- return (XTestQueryExtension( display, &dummy1, &dummy2, &dummy3, &dummy4 ) == True);
+ return (XScreenSaverQueryExtension( display, &dummy1, &dummy2 ) == True);
#endif
return 0;
}
@@ -843,7 +836,7 @@ int xcommon_open_display( const char *user_geometry, int aspect, int verbose )
output_aspect = aspect;
output_height = 576;
- have_xtest = 0;
+ have_xss = 0;
output_on_root = 0;
has_ewmh_state_fullscreen = 0;
has_ewmh_state_above = 0;
@@ -927,13 +920,16 @@ int xcommon_open_display( const char *user_geometry, int aspect, int verbose )
xfullscreen_print_summary( xf );
}
-#ifdef HAVE_XTESTEXTENSION
- kc_shift_l = XKeysymToKeycode( display, XK_Shift_L );
-#endif
- have_xtest = have_xtestextention();
- if( have_xtest && xcommon_verbose ) {
- fprintf( stderr, "xcommon: Have XTest, will use it to ping the screensaver.\n" );
+ have_xss = have_xssextention();
+ if( have_xss && xcommon_verbose ) {
+ fprintf( stderr, "xcommon: Have XSS, will use it to disable the screensaver.\n" );
+ }
+
+#ifdef HAVE_XSSEXTENSION
+ if ( have_xss ) {
+ XScreenSaverSuspend( display, True );
}
+#endif
/* Initially, get the best width for our height. */
output_width = xv_get_width_for_height( output_height );
@@ -1097,33 +1093,6 @@ int xcommon_open_display( const char *user_geometry, int aspect, int verbose )
return 1;
}
-static struct timeval last_ping_time;
-static int time_initialized = 0;
-
-void xcommon_ping_screensaver( void )
-{
- struct timeval curtime;
-
- if( !time_initialized ) {
- gettimeofday( &last_ping_time, 0 );
- time_initialized = 1;
- }
-
- gettimeofday( &curtime, 0 );
- if( timediff( &curtime, &last_ping_time ) > SCREENSAVER_PING_TIME ) {
- last_ping_time = curtime;
-#ifdef HAVE_XTESTEXTENSION
- if( have_xtest ) {
- XTestFakeKeyEvent( display, kc_shift_l, True, CurrentTime );
- XTestFakeKeyEvent( display, kc_shift_l, False, CurrentTime );
- } else
-#endif
- {
- XResetScreenSaver( display );
- }
- }
-}
-
void xcommon_frame_drawn( void )
{
if( motion_timeout ) {
@@ -1715,6 +1684,11 @@ void xcommon_poll_events( input_t *in )
void xcommon_close_display( void )
{
+#ifdef HAVE_XSSEXTENSION
+ if ( have_xss ) {
+ XScreenSaverSuspend( display, False );
+ }
+#endif
XDestroyWindow( display, output_window );
XDestroyWindow( display, wm_window );
XDestroyWindow( display, fs_window );
diff --git a/src/xcommon.h b/src/xcommon.h
index 1607310..5bc7e9d 100644
--- a/src/xcommon.h
+++ b/src/xcommon.h
@@ -44,7 +44,6 @@ int xcommon_is_alwaysontop( void );
int xcommon_get_visible_width( void );
int xcommon_get_visible_height( void );
-void xcommon_ping_screensaver( void );
area_t xcommon_get_video_area( void );
area_t xcommon_get_window_area( void );
void xcommon_set_video_scale( area_t scalearea );
diff --git a/src/xvoutput.c b/src/xvoutput.c
index 1fedb96..6f2af28 100644
--- a/src/xvoutput.c
+++ b/src/xvoutput.c
@@ -326,7 +326,6 @@ static int xv_show_frame( int x, int y, int width, int height )
xcommon_set_video_scale( scale_area );
- xcommon_ping_screensaver();
if( use_shm ) {
XvShmPutImage( display, xv_port, output_window, xcommon_get_gc(),
image, x, y, width, height, video_area.x, video_area.y,
--
1.6.0.4
Reply to: