summaryrefslogtreecommitdiff
path: root/patches/src680/vcl-gnome-screensaver-poke.diff
blob: f7e97a4fe488319626c2563b51caf7665191c478 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
--- vcl/unx/gtk/a11y/makefile.mk.orig	2006-05-26 12:26:01.000000000 +0200
+++ vcl/unx/gtk/a11y/makefile.mk	2006-05-26 12:26:30.000000000 +0200
@@ -59,7 +59,11 @@ dummy:
 
 .IF "$(ENABLE_GTK)" != ""
 
-PKGCONFIG_MODULES=gtk+-2.0
+.IF "$(ENABLE_DBUS)" == "YES"
+CDEFS+= -DENABLE_DBUS
+.ENDIF
+
+PKGCONFIG_MODULES=gtk+-2.0 $(DBUS_PACKAGE)
 .INCLUDE : pkg_config.mk
 
 CFLAGS+=-DVERSION=\"$(UPD)$(LAST_MINOR)\"
diff -rup ../src680-m165-orig/vcl/unx/gtk/app/makefile.mk vcl/unx/gtk/app/makefile.mk
--- ../src680-m165-orig/vcl/unx/gtk/app/makefile.mk	2005-09-09 14:36:54.000000000 +0200
+++ vcl/unx/gtk/app/makefile.mk	2006-05-25 09:22:07.000000000 +0200
@@ -58,7 +58,11 @@ dummy:
 
 .IF "$(ENABLE_GTK)" != ""
 
-PKGCONFIG_MODULES=gtk+-2.0
+.IF "$(ENABLE_DBUS)" == "YES"
+CDEFS+= -DENABLE_DBUS
+.ENDIF
+
+PKGCONFIG_MODULES=gtk+-2.0 $(DBUS_PACKAGE)
 .INCLUDE : pkg_config.mk
 
 SLOFILES=\
diff -rup ../src680-m165-orig/vcl/unx/gtk/gdi/makefile.mk vcl/unx/gtk/gdi/makefile.mk
--- ../src680-m165-orig/vcl/unx/gtk/gdi/makefile.mk	2005-09-09 14:37:10.000000000 +0200
+++ vcl/unx/gtk/gdi/makefile.mk	2006-05-25 09:22:07.000000000 +0200
@@ -55,7 +55,11 @@ dummy:
 
 .IF "$(ENABLE_GTK)" != ""
 
-PKGCONFIG_MODULES=gtk+-2.0
+.IF "$(ENABLE_DBUS)" == "YES"
+CDEFS+= -DENABLE_DBUS
+.ENDIF
+
+PKGCONFIG_MODULES=gtk+-2.0 $(DBUS_PACKAGE)
 .INCLUDE : pkg_config.mk
 
 SLOFILES=\
diff -rup ../src680-m165-orig/vcl/unx/gtk/window/gtkframe.cxx vcl/unx/gtk/window/gtkframe.cxx
--- ../src680-m165-orig/vcl/unx/gtk/window/gtkframe.cxx	2006-05-25 10:55:26.000000000 +0200
+++ vcl/unx/gtk/window/gtkframe.cxx	2006-05-25 10:38:25.000000000 +0200
@@ -66,6 +66,10 @@
 
 using namespace com::sun::star;
 
+#ifdef ENABLE_DBUS
+#include <dbus/dbus-glib-lowlevel.h>
+#endif
+
 int GtkSalFrame::m_nFloats = 0;
 
 static USHORT GetKeyModCode( guint state )
@@ -491,6 +493,10 @@ void GtkSalFrame::InitCommon()
     m_hBackgroundPixmap = None;
     m_nSavedScreenSaverTimeout = 0;
     m_nExtStyle         = 0;
+#ifdef ENABLE_DBUS
+	m_nGnomeScreenSaverPokeTimeoutId = 0;
+	m_pDBusConnection   = NULL;
+#endif
 
     gtk_widget_set_app_paintable( GTK_WIDGET(m_pWindow), TRUE );
     gtk_widget_set_double_buffered( GTK_WIDGET(m_pWindow), FALSE );
@@ -1559,6 +1563,44 @@ void GtkSalFrame::setAutoLock( bool bLoc
 					 sizeof( nMessage ) );
 }
 
+#ifdef ENABLE_DBUS
+#define GS_SERVICE   "org.gnome.ScreenSaver"
+#define GS_PATH      "/org/gnome/ScreenSaver"
+#define GS_INTERFACE "org.gnome.ScreenSaver"
+
+static gboolean
+pokeGnomeScreenSaver( gpointer data )
+{
+	DBusConnection *pConnection = (DBusConnection*) data;
+	DBusMessage *pMessage;
+	DBusError    pError;
+
+	g_return_val_if_fail( pConnection != NULL, FALSE );
+
+	dbus_error_init( &pError );
+
+	pMessage = dbus_message_new_method_call (GS_SERVICE, GS_PATH, GS_INTERFACE, "Poke");
+	if( pMessage == NULL ) {
+		OSL_TRACE( "Couldn't allocate the dbus message" );
+		return FALSE;
+	}
+
+	if( !dbus_connection_send( pConnection, pMessage, NULL ) )
+		OSL_TRACE( "could not send dbus message" );
+
+	dbus_connection_flush( pConnection );
+
+	dbus_message_unref( pMessage );
+
+	if( dbus_error_is_set( &pError ) )
+	  dbus_error_free( &pError );
+
+	OSL_TRACE( "Poke message sent" );
+
+	return TRUE;
+}
+#endif
+
 void GtkSalFrame::StartPresentation( BOOL bStart )
 {
 	Display *pDisplay = GDK_DISPLAY_XDISPLAY( getGdkDisplay() );
@@ -1571,6 +1611,7 @@ void GtkSalFrame::StartPresentation( BOO
 					 &bPreferBlanking, &bAllowExposures );
 	if( bStart )
 	{
+		/* disable X server built-in screensaver */
 		if ( nTimeout )
 		{
 			m_nSavedScreenSaverTimeout = nTimeout;
@@ -1578,14 +1619,55 @@ void GtkSalFrame::StartPresentation( BOO
 			XSetScreenSaver( pDisplay, 0, nInterval,
 							 bPreferBlanking, bAllowExposures );
 		}
+
+#ifdef ENABLE_DBUS
+		/* setup 30 seconds timeout to poke gnome-screensaver thru DBus connection */
+		if( !m_pDBusConnection ) {
+			DBusError pDBusError;
+
+			OSL_TRACE( "trying to create dbus connection" );
+
+			dbus_error_init( &pDBusError );
+			m_pDBusConnection = dbus_bus_get( DBUS_BUS_SESSION, &pDBusError );
+			dbus_connection_set_exit_on_disconnect( m_pDBusConnection, FALSE );
+
+			if( dbus_error_is_set( &pDBusError ) )
+			  dbus_error_free( &pDBusError );
+
+			if( m_pDBusConnection ) {
+				dbus_connection_setup_with_g_main( m_pDBusConnection, NULL );
+				OSL_TRACE( "dbus connection created" );
+
+				/* poke the screensaver now so that it doesn't kick in in the first 30 seconds of slideshow */
+				pokeGnomeScreenSaver( m_pDBusConnection );
+			}
+		}
+
+		if( m_pDBusConnection )
+			m_nGnomeScreenSaverPokeTimeoutId = g_timeout_add( 30000, pokeGnomeScreenSaver, m_pDBusConnection );
+#endif
 	}
 	else
 	{
+		/* restore X server built-in screensaver settings */
 		if( m_nSavedScreenSaverTimeout )
 			XSetScreenSaver( pDisplay, m_nSavedScreenSaverTimeout,
 							 nInterval, bPreferBlanking,
 							 bAllowExposures );
 		m_nSavedScreenSaverTimeout = 0;
+
+#ifdef ENABLE_DBUS
+		/* remove timeout for poking gnome-screensaver */
+		if( m_nGnomeScreenSaverPokeTimeoutId ) {
+			g_source_remove( m_nGnomeScreenSaverPokeTimeoutId );
+			m_nGnomeScreenSaverPokeTimeoutId = 0;
+			OSL_TRACE( "screensaver poking timeout removed" );
+
+			dbus_connection_unref( m_pDBusConnection );
+			m_pDBusConnection = NULL;
+			OSL_TRACE( "dbus connection disconnected and unrefed" );
+		}
+#endif
 	}
 }
 
diff -rup ../src680-m165-orig/vcl/unx/gtk/window/makefile.mk vcl/unx/gtk/window/makefile.mk
--- ../src680-m165-orig/vcl/unx/gtk/window/makefile.mk	2005-09-09 14:38:24.000000000 +0200
+++ vcl/unx/gtk/window/makefile.mk	2006-05-25 09:22:07.000000000 +0200
@@ -58,7 +58,11 @@ dummy:
 
 .IF "$(ENABLE_GTK)" != ""
 
-PKGCONFIG_MODULES=gtk+-2.0
+.IF "$(ENABLE_DBUS)" == "YES"
+CDEFS+= -DENABLE_DBUS
+.ENDIF
+
+PKGCONFIG_MODULES=gtk+-2.0 $(DBUS_PACKAGE)
 .INCLUDE : pkg_config.mk
 
 SLOFILES=\
diff -rup ../src680-m165-orig/vcl/unx/inc/plugins/gtk/gtkframe.hxx vcl/unx/inc/plugins/gtk/gtkframe.hxx
--- ../src680-m165-orig/vcl/unx/inc/plugins/gtk/gtkframe.hxx	2006-05-25 10:55:26.000000000 +0200
+++ vcl/unx/inc/plugins/gtk/gtkframe.hxx	2006-05-25 09:22:07.000000000 +0200
@@ -46,6 +46,12 @@
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/accessibility/XAccessible.hdl>
 
+#ifdef ENABLE_DBUS
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#endif
+
 #ifndef _SV_SALFRAME_HXX
 #include <salframe.hxx>
 #endif
@@ -201,6 +205,11 @@ class GtkSalFrame : public SalFrame
     Size                            m_aMaxSize;
     Size                            m_aMinSize;
     Rectangle                       m_aRestorePosSize;    
+
+#ifdef ENABLE_DBUS
+	DBusConnection                 *m_pDBusConnection;
+	guint                           m_nGnomeScreenSaverPokeTimeoutId;
+#endif
     
     void Init( SalFrame* pParent, ULONG nStyle );
     void Init( SystemParentData* pSysData );
diff -rup ../src680-m165-orig/vcl/util/makefile.mk vcl/util/makefile.mk
--- ../src680-m165-orig/vcl/util/makefile.mk	2006-05-25 10:55:26.000000000 +0200
+++ vcl/util/makefile.mk	2006-05-25 09:22:07.000000000 +0200
@@ -352,7 +352,11 @@ SHL3STDLIBS=\
 
 # gtk plugin
 .IF "$(ENABLE_GTK)" != ""
-PKGCONFIG_MODULES=gtk+-2.0 gthread-2.0
+.IF "$(ENABLE_DBUS)" == "YES"
+CDEFS+= -DENABLE_DBUS
+.ENDIF
+
+PKGCONFIG_MODULES=gtk+-2.0 gthread-2.0 $(DBUS_PACKAGE)
 .INCLUDE: pkg_config.mk
 
 LIB4TARGET=$(SLB)$/igtk_plug_