summarylogtreecommitdiffstats
path: root/tvtime-1.0.2-xscreensaver-fix.patch
blob: 49dcf59b0e25d01520e1b869cc809cc208638c73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Based on the patch in
http://sourceforge.net/tracker/?func=detail&aid=2683274&group_id=64301&atid=506989
--- tvtime-1.0.2.orig/configure.ac
+++ tvtime-1.0.2/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
--- tvtime-1.0.2.orig/src/xcommon.c	2005-08-14 19:36:52.000000000 +0200
+++ tvtime-1.0.2/src/xcommon.c	2009-05-31 18:44:18.861410600 +0200
@@ -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"
@@ -67,7 +67,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 +107,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 +244,12 @@ static void x11_wait_mapped( Display *dp
     } 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 +839,7 @@ int xcommon_open_display( const char *us
     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 +923,16 @@ int xcommon_open_display( const char *us
         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 );
@@ -1112,15 +1111,7 @@ void xcommon_ping_screensaver( void )
     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 );
-        }
+        XResetScreenSaver( display );
     }
 }
 
@@ -1715,6 +1706,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 );