updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / mplayer-hunarch / MPlayer-1.0rc1-gnome-screensaver.patch
blob79deb935263ce4c084090f6c4a7a010260ac54b1
1 diff -Nur MPlayer-1.0rc1.orig/configure MPlayer-1.0rc1/configure
2 --- MPlayer-1.0rc1.orig/configure 2006-10-23 00:32:31.000000000 +0200
3 +++ MPlayer-1.0rc1/configure 2006-11-11 14:02:38.000000000 +0100
4 @@ -257,6 +257,7 @@
5 --disable-ftp Disable ftp support [enabled]
6 --disable-vstream Disable tivo vstream client support [autodetect]
7 --disable-pthreads Disable Posix threads support [autodetect]
8 + --disable-dbus-glib Disable D-BUS GLib interface (required for GNOME screensaver support) [autodetect]
9 --disable-ass Disable internal SSA/ASS subtitles support [autodetect]
10 --enable-rpath Enable runtime linker path for extra libs [disabled]
12 @@ -1721,6 +1722,7 @@
13 _musepack=auto
14 _vstream=auto
15 _pthreads=auto
16 +_dbus_glib=auto
17 _ass=auto
18 _rpath=no
19 _asmalign_pot=auto
20 @@ -2033,6 +2035,8 @@
21 --disable-vstream) _vstream=no ;;
22 --enable-pthreads) _pthreads=yes ;;
23 --disable-pthreads) _pthreads=no ;;
24 + --enable-dbus-glib) _dbus_glib=yes ;;
25 + --disable-dbus-glib) _dbus_glib=no ;;
26 --enable-ass) _ass=yes ;;
27 --disable-ass) _ass=no ;;
28 --enable-rpath) _rpath=yes ;;
29 @@ -7029,6 +7033,19 @@
31 echores "$_gethostbyname2"
33 +echocheck "D-BUS GLib interface"
34 +if test "$_dbus_glib" = auto && pkg-config --exists dbus-glib-1; then
35 + _dbus_glib=yes
36 + _inc_dbus_glib=`pkg-config --cflags dbus-glib-1 2>/dev/null`
37 + _ld_dbus_glib=`pkg-config --libs dbus-glib-1 2>/dev/null`
38 +fi
40 +if test "$_dbus_glib" = yes; then
41 + _def_dbus_glib='#define HAVE_DBUS_GLIB 1'
42 +else
43 + _def_dbus_glib='#undef HAVE_DBUS_GLIB'
44 +fi
45 +echores "$_dbus_glib"
47 # --------------- GUI specific tests begin -------------------
48 echocheck "GUI"
49 @@ -7521,6 +7538,10 @@
50 VESA_LIB = $_ld_vesa
51 AA_LIB = $_ld_aa
52 CACA_LIB = $_ld_caca
53 +DBUS_GLIB_INC = $_inc_dbus_glib
54 +DBUS_GLIB_LIB = $_ld_dbus_glib
55 +DBUS_GLIB = $_dbus_glib
58 # audio output
59 OSS = $_ossaudio
60 @@ -8378,6 +8399,7 @@
61 $_def_tga
62 $_def_toolame
63 $_def_twolame
64 +$_def_dbus_glib
66 /* used by GUI: */
67 $_def_xshape
68 diff -Nur MPlayer-1.0rc1.orig/help/help_mp-en.h MPlayer-1.0rc1/help/help_mp-en.h
69 --- MPlayer-1.0rc1.orig/help/help_mp-en.h 2006-10-23 00:32:29.000000000 +0200
70 +++ MPlayer-1.0rc1/help/help_mp-en.h 2006-11-11 14:02:38.000000000 +0100
71 @@ -679,6 +679,13 @@
72 #define MSGTR_InsertingAfVolume "[Mixer] No hardware mixing, inserting volume filter.\n"
73 #define MSGTR_NoVolume "[Mixer] No volume control available.\n"
75 +// gnome_screensaver.c
76 +#define MSGTR_OpenBusConnectionError "%s: Failed to open connection to bus: %s\n"
77 +#define MSGTR_RemoteMethodException "%s: Caught remote method exception %s: %s\n"
78 +#define MSGTR_GError "%s: Error: %s\n"
79 +#define MSGTR_GNOMEScreensaverEnabled "GNOME screensaver enabled\n"
80 +#define MSGTR_GNOMEScreensaverDisabled "GNOME screensaver disabled\n"
82 // ====================== GUI messages/buttons ========================
84 #ifdef HAVE_NEW_GUI
85 diff -Nur MPlayer-1.0rc1.orig/libvo/gnome_screensaver.c MPlayer-1.0rc1/libvo/gnome_screensaver.c
86 --- MPlayer-1.0rc1.orig/libvo/gnome_screensaver.c 1970-01-01 01:00:00.000000000 +0100
87 +++ MPlayer-1.0rc1/libvo/gnome_screensaver.c 2006-11-11 14:02:38.000000000 +0100
88 @@ -0,0 +1,120 @@
89 +/*
90 + * gnome_screensaver.c v0.0.7
91 + *
92 + * Enable/Disable the GNOME screensaver
93 + * Supports GNOME screensaver API 2.14 and 2.15
94 + *
95 + * Call gnome_screensaver_control(1) to enable and
96 + * gnome_screensaver_control(0) to disable
97 + *
98 + */
100 +#include <stdlib.h>
101 +#include <unistd.h>
102 +#include <dbus/dbus-glib.h>
104 +#include "gnome_screensaver.h"
105 +#include "mp_msg.h"
106 +#include "help_mp.h"
108 +#define GS_SERVICE "org.gnome.ScreenSaver"
109 +#define GS_PATH "/org/gnome/ScreenSaver"
110 +#define GS_INTERFACE "org.gnome.ScreenSaver"
112 +#define GS_APPLICATION_NAME "MPlayer"
113 +#define GS_REASON_FOR_INHIBIT "Playing a movie"
115 +static guint32 cookie;
117 +void gnome_screensaver_control(int enable)
119 + DBusGConnection *connection;
120 + GError *error;
121 + DBusGProxy *proxy;
122 + gboolean ret;
123 + char *funcname = "gnome_screensaver_control()";
125 + g_type_init();
127 + /* Get a connection to the session bus */
128 + error = NULL;
129 + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
130 + if (connection == NULL) {
131 + mp_msg(MSGT_VO, MSGL_ERR,
132 + funcname, MSGTR_OpenBusConnectionError, error->message);
133 + g_error_free(error);
134 + return;
137 + /* Create a proxy object */
138 + proxy = dbus_g_proxy_new_for_name(connection,
139 + GS_SERVICE, GS_PATH, GS_INTERFACE);
141 + /* Enable the screensaver */
142 + if (enable) {
143 + /* First call the GNOME screensaver 2.15 API method */
144 + error = NULL;
145 + ret =
146 + dbus_g_proxy_call(proxy, "UnInhibit", &error, G_TYPE_UINT,
147 + cookie, G_TYPE_INVALID);
149 + /* If this fails, try the GNOME screensaver 2.14 API */
150 + if (!ret && error->domain == DBUS_GERROR
151 + && error->code == DBUS_GERROR_UNKNOWN_METHOD) {
152 + mp_msg(MSGT_VO, MSGL_V,
153 + "%s: GNOME screensaver 2.15 API failed, trying 2.14 API\n",
154 + funcname);
155 + g_error_free(error);
156 + error = NULL;
157 + ret =
158 + dbus_g_proxy_call(proxy, "AllowActivation", &error,
159 + G_TYPE_INVALID, G_TYPE_INVALID);
162 + /* Disable the screensaver */
163 + else {
164 + /* First call the GNOME screensaver 2.15 API method */
165 + error = NULL;
166 + ret =
167 + dbus_g_proxy_call(proxy, "Inhibit", &error, G_TYPE_STRING,
168 + GS_APPLICATION_NAME, G_TYPE_STRING,
169 + GS_REASON_FOR_INHIBIT, G_TYPE_INVALID,
170 + G_TYPE_UINT, cookie, G_TYPE_INVALID);
172 + /* If this fails, try the GNOME screensaver 2.14 API */
173 + if (!ret && error->domain == DBUS_GERROR
174 + && error->code == DBUS_GERROR_UNKNOWN_METHOD) {
175 + mp_msg(MSGT_VO, MSGL_V,
176 + "%s: GNOME screensaver 2.15 API failed, trying 2.14 API\n",
177 + funcname);
178 + g_error_free(error);
179 + error = NULL;
180 + ret =
181 + dbus_g_proxy_call(proxy, "InhibitActivation", &error,
182 + G_TYPE_STRING, GS_REASON_FOR_INHIBIT,
183 + G_TYPE_INVALID, G_TYPE_INVALID);
187 + if (!ret) {
188 + /* Check if it's a remote exception or a regular GError */
189 + if (error->domain == DBUS_GERROR
190 + && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
191 + mp_msg(MSGT_VO, MSGL_ERR,
192 + funcname, MSGTR_RemoteMethodException,
193 + dbus_g_error_get_name(error), error->message);
195 + else {
196 + mp_msg(MSGT_VO, MSGL_ERR,
197 + funcname, MSGTR_GError, error->message);
199 + g_error_free(error);
201 + else {
202 + mp_msg(MSGT_VO, MSGL_INFO,
203 + enable ? MSGTR_GNOMEScreensaverEnabled :
204 + MSGTR_GNOMEScreensaverDisabled);
207 + g_object_unref(proxy);
209 diff -Nur MPlayer-1.0rc1.orig/libvo/gnome_screensaver.h MPlayer-1.0rc1/libvo/gnome_screensaver.h
210 --- MPlayer-1.0rc1.orig/libvo/gnome_screensaver.h 1970-01-01 01:00:00.000000000 +0100
211 +++ MPlayer-1.0rc1/libvo/gnome_screensaver.h 2006-11-11 14:02:38.000000000 +0100
212 @@ -0,0 +1,6 @@
213 +#ifndef _GNOME_SCREENSAVER_H
214 +#define _GNOME_SCREENSAVER_H
216 +extern void gnome_screensaver_control(int enable);
218 +#endif /* !_GNOME_SCREENSAVER_H */
219 diff -Nur MPlayer-1.0rc1.orig/libvo/Makefile MPlayer-1.0rc1/libvo/Makefile
220 --- MPlayer-1.0rc1.orig/libvo/Makefile 2006-10-23 00:32:26.000000000 +0200
221 +++ MPlayer-1.0rc1/libvo/Makefile 2006-11-11 14:02:38.000000000 +0100
222 @@ -39,6 +39,11 @@
223 SRCS += vosub_vidix.c
224 endif
226 +ifeq ($(DBUS_GLIB),yes)
227 +SRCS += gnome_screensaver.c
228 +LIBAV_INC += $(DBUS_GLIB_INC)
229 +endif
231 INCLUDE = -I. -I.. -I../osdep $(LIBAV_INC)
232 CFLAGS = $(INCLUDE) $(OPTFLAGS) -DMPG12PLAY
234 diff -Nur MPlayer-1.0rc1.orig/libvo/x11_common.c MPlayer-1.0rc1/libvo/x11_common.c
235 --- MPlayer-1.0rc1.orig/libvo/x11_common.c 2006-10-23 00:32:26.000000000 +0200
236 +++ MPlayer-1.0rc1/libvo/x11_common.c 2006-11-11 14:02:38.000000000 +0100
237 @@ -58,6 +58,10 @@
238 #include "mplayer.h"
239 #endif
241 +#ifdef HAVE_DBUS_GLIB
242 +#include "gnome_screensaver.h"
243 +#endif
245 #define WIN_LAYER_ONBOTTOM 2
246 #define WIN_LAYER_NORMAL 4
247 #define WIN_LAYER_ONTOP 6
248 @@ -1701,8 +1705,12 @@
249 timeout_save = 0;
252 - if (stop_xscreensaver)
253 + if (stop_xscreensaver) {
254 xscreensaver_enable();
255 +#ifdef HAVE_DBUS_GLIB
256 + gnome_screensaver_control(1);
257 +#endif
259 if (kdescreensaver_was_running && stop_xscreensaver)
261 system
262 @@ -1747,8 +1755,12 @@
263 allow_exp);
265 // turning off screensaver
266 - if (stop_xscreensaver)
267 + if (stop_xscreensaver) {
268 xscreensaver_disable(mDisplay);
269 +#ifdef HAVE_DBUS_GLIB
270 + gnome_screensaver_control(0);
271 +#endif
273 if (stop_xscreensaver && !kdescreensaver_was_running)
275 kdescreensaver_was_running =
276 diff -Nur MPlayer-1.0rc1.orig/Makefile MPlayer-1.0rc1/Makefile
277 --- MPlayer-1.0rc1.orig/Makefile 2006-10-23 00:32:31.000000000 +0200
278 +++ MPlayer-1.0rc1/Makefile 2006-11-11 14:02:38.000000000 +0100
279 @@ -75,6 +75,7 @@
280 $(DIRECTFB_LIB) \
281 $(CACA_LIB) \
282 $(VESA_LIB) \
283 + $(DBUS_GLIB_LIB) \
285 ifeq ($(VIDIX),yes)
286 VO_LIBS += vidix/libvidix.a