Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Feb 2002 23:40:13 +0100
From:      Simon Barner <barner@in.tum.de>
To:        multimedia@freebsd.org
Subject:   fxtv - Patches to turn off screen saver while in full screen mode
Message-ID:  <20020224234013.A5689@simonbarner.myfqdn.de>

next in thread | raw e-mail | index | archive | help

--fdj2RfSjLxBAspz7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

first of all, thank you a lot for fxtv :-)

I have added support to turn off the screen saver of the X window system. This
works also with dpms (you can turn off dpms support in the Makefile, I have
added a switch there).

The code was taken from the graphics/mplayer port (GPL).

Regards,
 Simon

--fdj2RfSjLxBAspz7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-Makefile

--- Makefile.orig	Sun Feb 24 23:29:26 2002
+++ Makefile	Sun Feb 24 23:29:44 2002
@@ -4,6 +4,10 @@
 
 HAVE_XFREE86 = YES
 
+# Do we have DPMS support?
+# Turn off in full screen mode (Simon Barner <barner@in.tum.de)
+HAVE_DPMS = YES
+
 ifneq ($(X11PREFIX),)                      # NetBSD
 X11BASE      ?= $(X11PREFIX)
 else
@@ -68,6 +72,9 @@
 override CFLAGS           += $(C_WARN_FLAG) $(INC) $(CF_VERS)
 ifeq ($(HAVE_XFREE86),YES)
 override CFLAGS           += -DHAVE_XFREE86
+endif
+ifeq ($(HAVE_DPMS),YES)
+override CFLAGS           += -DHAVE_XDPMS
 endif
 
 override CFLAGS           += $(C_WARN_FLAG) -DX11BASE=\"$(X11BASEINST)\"

--fdj2RfSjLxBAspz7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-tvscreen.c"

--- tvscreen.c.orig	Sun Feb 24 23:29:34 2002
+++ tvscreen.c	Sun Feb 24 23:29:41 2002
@@ -45,6 +45,19 @@
 #  include <X11/extensions/xf86dgastr.h>
 #  include <X11/extensions/xf86vmstr.h>
 #endif
+
+/*
+	24.02.2002 Simon Barner <barner@in.tum.de>
+	
+	Undefine HAVE_XDPMS in the Makefile if your X-Installation does not support
+	DPMS video blanking.
+	
+	Needed to turn of the screen saver while in fullscreen mode.
+*/
+#ifdef HAVE_XDPMS
+#include <X11/extensions/dpms.h>
+#endif
+
 #include <X11/extensions/XShm.h>
 #include <X11/StringDefs.h>
 #include <X11/Intrinsic.h>
@@ -89,6 +102,108 @@
 
 /**@BEGINFUNC**************************************************************
 
+    Prototype  : void saver_on (Display *display)
+
+    Purpose    : Turn on X screen saver (used when coming back from 
+					full screen mode)
+
+    Programmer : 24-Feb-02  Simon Barner <barner@in.tum.de>
+
+    Parameters : Display *display
+
+    Returns    : void
+
+    Globals    : timeout_save, dpms_disabled;
+				 (shared with saver_off to keep screen saver settings
+ **@ENDFUNC*****************************************************************/
+static int timeout_save=0,
+			dpms_disabled=0;
+			
+void saver_on(Display *display) {
+#ifdef HAVE_XDPMS
+	int nothing;
+	if (dpms_disabled) {
+		if (DPMSQueryExtension(display, &nothing, &nothing)) {
+			if (!DPMSEnable(display)) {
+				// restoring power saving settings
+				//printf("DPMS not available?\n");
+			} else {
+				// DPMS does not seem to be enabled unless we call DPMSInfo
+				BOOL onoff;
+				CARD16 state;
+				DPMSInfo(display, &state, &onoff);
+				
+				
+				if (onoff) {
+					printf ("Successfully enabled DPMS\n");
+				} else {
+					printf ("Could not enable DPMS\n");
+				}
+				
+			
+			}
+		}
+	}
+#endif
+
+	if (timeout_save) {
+		int dummy,
+			interval,
+			prefer_blank,
+			allow_exp;
+		
+		XGetScreenSaver(display, &dummy, &interval, &prefer_blank, &allow_exp);
+		XSetScreenSaver(display, timeout_save, interval, prefer_blank, allow_exp);
+		XGetScreenSaver(display, &timeout_save, &interval, &prefer_blank, &allow_exp);
+	}
+}
+
+/**@BEGINFUNC**************************************************************
+
+    Prototype  : void saver_off (Display *display)
+
+    Purpose    : Turn off X screen saver (used in full screen mode)
+
+    Programmer : 24-Feb-02  Simon Barner <barner@in.tum.de>
+
+    Parameters : Display *display
+
+    Returns    : void
+
+    Globals    : timeout_save, dpms_disabled;
+				 (shared with saver_on to keep screen saver settings
+ **@ENDFUNC*****************************************************************/
+void saver_off(Display *display) {
+	int	interval,
+		prefer_blank,
+		allow_exp,
+		nothing;
+#ifdef HAVE_XDPMS
+
+	
+	if (DPMSQueryExtension(display, &nothing, &nothing)) {
+		BOOL onoff;
+		CARD16 state;
+		DPMSInfo(display, &state, &onoff);
+		if (onoff) {
+			Status stat;
+			// printf ("Disabling DPMS\n");
+			dpms_disabled=1;
+			stat = DPMSDisable(display);  // monitor powersave off
+			// printf ("stat: %d\n", stat);
+		}
+	}
+#endif
+
+	XGetScreenSaver(display, &timeout_save, &interval, &prefer_blank, &allow_exp);
+	if (timeout_save) {
+		XSetScreenSaver(display, 0, interval, prefer_blank, allow_exp);
+	// turning off screensaver
+	}
+}
+
+/**@BEGINFUNC**************************************************************
+
     Prototype  : static INT32 TVSCREENGetCurVidMode(
                       TV_XSCREEN *s )
 
@@ -379,8 +494,9 @@
 
 static void TVSCREENAtExit()
 {
-    if ( !G_in_x_error )
+    if ( !G_in_x_error ) {
         TVSCREENSetZoomState( FALSE, FALSE );
+	}
 }
 
 
@@ -2256,6 +2372,9 @@
 
         if ( zoom_on ) {
             if ( full_screen ) {
+				// turn off screen saver while in full screen mode
+				saver_off (TVDISPLAY);
+				
                 XRaiseWindow( TVDISPLAY, XtWindow(d->shell_wgt) );
 
                 /*  Lock out the mouse so user can't move off the TV.       */
@@ -2290,6 +2409,13 @@
             }
         }
         else {
+			/*  Turn the screen saver on again
+				
+				We do not check for fullscreen because on exit this function
+				is called with (FALSE, FALSE) Arguments
+			*/
+			saver_on (TVDISPLAY);
+
             if ( d->unzoomed.mode >= 0 ) {
                 if ( cur_vm != d->unzoomed.mode ) {
                     new_vm = d->unzoomed.mode;

--fdj2RfSjLxBAspz7--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020224234013.A5689>