[MPlayer-dev-eng] [PATCH] Add support for GNOME screensaver

Piotr Kaczuba pepe at attika.ath.cx
Wed Apr 26 15:50:17 CEST 2006


Hello!

I've wrote a patch to support GNOME screensaver in MPlayer, i.e. to
disable it when playing a movie and reenabling it after that.
The code requires that dbus and dbus-glib is present, as it uses GNOME
screensaver's DBUS API for the task. It's integrated into x11_common.c
and so it's only compiled when X11 is present.
Please comment on it, especially on the changes in configure. Maybe they
can be improved.

Piotr
-------------- next part --------------
? libvo/gnome_screensaver.c
? libvo/gnome_screensaver.h
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.367
diff -u -r1.367 Makefile
--- Makefile	25 Apr 2006 02:01:21 -0000	1.367
+++ Makefile	26 Apr 2006 13:23:57 -0000
@@ -74,6 +74,7 @@
           $(DIRECTFB_LIB) \
           $(CACA_LIB) \
 	  $(VESA_LIB) \
+	  $(DBUS_GLIB_LIB) \
 
 ifeq ($(EXTERNAL_VIDIX),yes)
 VO_LIBS += $(EXTERNAL_VIDIX_LIB)
@@ -307,7 +308,7 @@
 	$(MAKE) -C libmpeg2
 
 libvo/libvo.a:
-	$(MAKE) -C libvo
+	$(MAKE) -C libvo all
 
 libao2/libao2.a:
 	$(MAKE) -C libao2
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.1179
diff -u -r1.1179 configure
--- configure	26 Apr 2006 01:59:05 -0000	1.1179
+++ configure	26 Apr 2006 13:23:57 -0000
@@ -6815,6 +6815,23 @@
 fi
 echores "$_gethostbyname2"
 
+# Check for D-BUS GLib interface
+echocheck "D-BUS GLib interface"
+if pkg-config --exists dbus-glib-1; then
+  _dbus_glib=yes
+  _inc_dbus_glib=`pkg-config --cflags dbus-glib-1 2>/dev/null`
+  _ld_dbus_glib=`pkg-config --libs dbus-glib-1 2>/dev/null`
+  _def_dbus_glib='#define HAVE_DBUS_GLIB 1'
+else
+  _dbus_glib=no
+  _def_dbus_glib='#undef HAVE_DBUS_GLIB'
+fi
+echores "$_dbus_glib"
+
+if test "$_x11" = yes -a "$_dbus_glib" = yes; then
+  _vosrc="$_vosrc gnome_screensaver.c"
+fi
+
 # --------------- GUI specific tests begin -------------------
 echocheck "GUI"
 echo "$_gui"
@@ -7290,6 +7307,8 @@
 AA_LIB = $_ld_aa
 CACA_INC = $_inc_caca
 CACA_LIB = $_ld_caca
+DBUS_GLIB_INC = $_inc_dbus_glib
+DBUS_GLIB_LIB = $_ld_dbus_glib
 
 # audio output
 ALSA_LIB = $_ld_alsa
@@ -8116,6 +8135,14 @@
 OPTIONAL_OBJS = $_voobj
 EOF
 
+if test "$_x11" = yes -a "$_dbus_glib" = yes; then
+  cat >> libvo/config.mak << EOF
+
+gnome_screensaver.o: gnome_screensaver.c
+	\$(CC) -c \$(CFLAGS) \$(DBUS_GLIB_INC) -o \$@ $<
+EOF
+fi
+
 #############################################################################
 
 echo "Creating libao2/config.mak"
Index: libvo/x11_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v
retrieving revision 1.210
diff -u -r1.210 x11_common.c
--- libvo/x11_common.c	25 Apr 2006 21:36:02 -0000	1.210
+++ libvo/x11_common.c	26 Apr 2006 13:23:58 -0000
@@ -58,6 +58,10 @@
 #include "mplayer.h"
 #endif
 
+#ifdef HAVE_DBUS_GLIB
+#include "gnome_screensaver.h"
+#endif
+
 #define WIN_LAYER_ONBOTTOM               2
 #define WIN_LAYER_NORMAL                 4
 #define WIN_LAYER_ONTOP                  6
@@ -1692,8 +1696,12 @@
         timeout_save = 0;
     }
 
-    if (stop_xscreensaver)
+    if (stop_xscreensaver) {
         xscreensaver_enable();
+#ifdef HAVE_DBUS_GLIB
+        gnome_screensaver_enable();
+#endif
+    }
     if (kdescreensaver_was_running && stop_xscreensaver)
     {
         system
@@ -1738,8 +1746,12 @@
                             allow_exp);
     }
     // turning off screensaver
-    if (stop_xscreensaver)
+    if (stop_xscreensaver) {
         xscreensaver_disable(mDisplay);
+#ifdef HAVE_DBUS_GLIB
+        gnome_screensaver_disable();
+#endif
+    }
     if (stop_xscreensaver && !kdescreensaver_was_running)
     {
         kdescreensaver_was_running =


More information about the MPlayer-dev-eng mailing list