]> git.sesse.net Git - vlc/commitdiff
* ./modules/misc/screensaver.c: screen saver disabling plugin; runs a thread
authorSam Hocevar <sam@videolan.org>
Thu, 6 Feb 2003 03:22:08 +0000 (03:22 +0000)
committerSam Hocevar <sam@videolan.org>
Thu, 6 Feb 2003 03:22:08 +0000 (03:22 +0000)
    in the background to disable xscreensaver the jwz way (Closes: #58).

    It's an interface plugin, trigger with "--extraintf screensaver".

configure.ac.in
modules/misc/Modules.am
modules/misc/screensaver.c [new file with mode: 0644]

index 534dc5d86e21c4d83f5a7595e3dda55d43e5b0b1..65378874d4917c45b8891b6b05810a6363a76ce9 100644 (file)
@@ -754,7 +754,7 @@ PLUGINS="${PLUGINS} i420_rgb i420_yuy2 i422_yuy2 i420_ymga"
 PLUGINS="${PLUGINS} id3 m3u"
 PLUGINS="${PLUGINS} wav araw demuxdump demuxsub adpcm a52sys"
 PLUGINS="${PLUGINS} access_udp access_http ipv4 access_mms access_ftp"
-PLUGINS="${PLUGINS} sap"
+PLUGINS="${PLUGINS} sap screensaver"
 
 dnl
 dnl  Accelerated modules
index 8e499538be4dad3b935fa716db578fd48cdd5e0b..e1fd98fd0f3732f2cab5cd26ef3103ade7568a71 100644 (file)
@@ -1,4 +1,5 @@
 SOURCES_gtk_main = modules/misc/gtk_main.c
 SOURCES_gnome_main = modules/misc/gtk_main.c
 SOURCES_sap = modules/misc/sap.c
+SOURCES_screensaver = modules/misc/screensaver.c
 SOURCES_qte_main = modules/misc/qte_main.cpp
diff --git a/modules/misc/screensaver.c b/modules/misc/screensaver.c
new file mode 100644 (file)
index 0000000..05771ba
--- /dev/null
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * screensaver.c : disable screen savers when VLC is playing
+ *****************************************************************************
+ * Copyright (C) 2003 VideoLAN
+ * $Id: screensaver.c,v 1.1 2003/02/06 03:22:08 sam Exp $
+ *
+ * Authors: Sam Hocevar <sam@zoy.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include <stdlib.h>
+
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+#include <vlc/aout.h>
+#include <vlc/vout.h>
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int  Activate     ( vlc_object_t * );
+static void Run          ( intf_thread_t *p_intf );
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+vlc_module_begin();
+    set_description( _("screensaver disabling module") );
+    set_capability( "interface", 0 );
+    set_callbacks( Activate, NULL );
+vlc_module_end();
+
+/*****************************************************************************
+ * Activate: initialize and create stuff
+ *****************************************************************************/
+static int Activate( vlc_object_t *p_this )
+{
+    intf_thread_t *p_intf = (intf_thread_t*)p_this;
+
+    p_intf->pf_run = Run;
+
+    return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * Run: main thread
+ *****************************************************************************
+ * This part of the module is in a separate thread so that we do not have
+ * too much system() overhead.
+ *****************************************************************************/
+static void Run( intf_thread_t *p_intf )
+{
+    int i_lastcall = 0;
+
+    while( !p_intf->b_die )
+    {
+        msleep( 100000 );
+
+        /* Check screensaver every 30 seconds */
+        if( ++i_lastcall > 300 )
+        {
+            vlc_object_t *p_vout;
+            p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+            /* If there is a video output, disable xscreensaver */
+            if( p_vout )
+            {
+                vlc_object_release( p_vout );
+
+                /* http://www.jwz.org/xscreensaver/faq.html#dvd */
+                system( "xscreensaver-command -deactivate >&- 2>&- &" );
+
+                /* FIXME: add support for other screensavers */
+            }
+        }
+    }
+}
+