[Nel] Linux fullscreen patches

Leighton Haynes dayta@ucc.gu.uwa.edu.au
Wed, 28 Feb 2001 20:16:17 +0800


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

Hi Guys,
    Attached to this should be 3 diffs against the current cvs tree
    to enable fullscreen under linux using the XFree86 VidMode
    extensions. The aptches are for the configure.in script, 
    and driver_opengl.{cpp,h}.

    To enable it you need to remake the configure script (./bootstrap)
    and run configure with the --with-xf86vidmode=<position of the 
    Xxf86vm lib> - usually /usr/X11R6/lib. If this option isn't given, 
    it will currently compile without fullscreen support.

    Anyhow, have a play, if anyone finds bugs... erm.. bug me ;)

Leighton...

--

Part-time student. Full-time Programmer. 
Seeking the 36 hour day and the 10 hour working week.
(08) 9272 9058 (Home - like I'm ever there)
0401 335 136 (Mobile - like it's ever on)

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.configure.in"

Index: configure.in
===================================================================
RCS file: /home/cvsroot/code/nel/configure.in,v
retrieving revision 1.23
diff -r1.23 configure.in
232a233,251
> dnl ============================================
> dnl Check for XF86VidMode extension (-lXxf86vm)
> dnl ============================================
> AC_MSG_CHECKING("for XF86VidMode extension")
> AC_ARG_WITH( xf86vidmode,
>     [ --with-xf86vidmode=<path>     path to the XF86VidMode lib.
>                           e.g. /usr/X11R6/lib],
>     [VMLIB_DIR=$with_xf86vidmode
>       AC_MSG_RESULT(using VidMode library located in $with_xf86vidmode.)],
>     AC_MSG_RESULT(Compiling without Xf86VidMode and hence fullscreen support to compile with XF86VidMode support, use --with-xf86vidmode=<pathtolib>)
> )
> 
> if test X"$VMLIB_DIR" != X;
> then
>     LIBS="-L$VMLIB_DIR -lXxf86vm $LIBS";
>     CXXFLAGS="$CXXFLAGS -DXF86VIDMODE";
> fi
> 
> 

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.driver_opengl.cpp"

Index: driver_opengl.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/driver/opengl/driver_opengl.cpp,v
retrieving revision 1.75
diff -r1.75 driver_opengl.cpp
140d139
< 	_FullScreen= false;
144c143,149
< #endif // NL_OS_WINDOWS
---
> #elif defined (NL_OS_UNIX) // NL_OS_WINDOWS
> #ifdef XF86VIDMODE
>     memset(&_OldScreenMode,0,sizeof(_OldScreenMode));// zero the old screen mode
> #endif //XF86VIDMODE
> #endif
> 
> 	_FullScreen= false;
225a231
>         {
226a233
>         }
351c358
< 	  {
---
>     {
353c360
< 	  }
---
>     }
355c362
< 	  {
---
>     {
357c364
< 	  }
---
>     }
364c371,385
< 	attr.override_redirect = False;
---
> #ifdef XF86VIDMODE
>     // If we're going to attempt fullscreen, we need to set redirect to True,
>     // This basically places the window with no borders in the top left 
>     // corner of the screen.
>     if (mode.Windowed)
>     {
>         attr.override_redirect = False;
>     }
>     else
>     {
> 	    attr.override_redirect = True;
>     }
> #else
>     attr.override_redirect = False;
> #endif
409,411c430,507
< //	XEvent event;
< //	XIfEvent(dpy, &event, WaitForNotify, (char *)this);
< 
---
> #ifdef XF86VIDMODE
>     if (!mode.Windowed)
>     {
>     
>         // Set window to the right size, map it to the display, and raise it
>         // to the front
>         XResizeWindow(dpy,win,mode.Width,mode.Height);
>         XMapRaised(dpy,win);
>         XRaiseWindow(dpy, win);
> 
>         // grab the mouse and keyboard on the fullscreen window 
>         if ((XGrabPointer(dpy, win, True, 0,
>                           GrabModeAsync, GrabModeAsync,
>                           win, None, CurrentTime) != GrabSuccess) ||
>             (XGrabKeyboard(dpy, win, True,
>                           GrabModeAsync, GrabModeAsync, CurrentTime) != 0) )
>         {
>             // Until I work out how to deal with this nicely, it just gives
>             // an error and exits the prorgam.
>             nlerror("Unable to grab keyboard and mouse\n");
>         }
>         else
>         {
>             // Save the old screen mode and dotclock
>             memset(&_OldScreenMode, 0, sizeof(_OldScreenMode));
>             XF86VidModeGetModeLine(dpy, 
>                                    DefaultScreen(dpy),
>                                    &_OldDotClock,
>                                    &_OldScreenMode);
>             // Save the old viewport
>             XF86VidModeGetViewPort(dpy, 
>                                    DefaultScreen(dpy),
>                                    &_OldX,
>                                    &_OldY);
>     
>             // get a list of modes, search for an appropriate one.
>             XF86VidModeModeInfo **modes;
>             int nmodes;
>             if (XF86VidModeGetAllModeLines(dpy,
>                                            DefaultScreen(dpy),
>                                            &nmodes,&modes))
>             {
>                 int mode_index = -1; // Gah, magic numbers all bad. 
>                 for (int i = 0; i < nmodes; i++)
>                 {
>                     nldebug("Available mode - %dx%d\n",mode.Width,mode.Height);
>                     if( (modes[i]->hdisplay == mode.Width) &&
>                         (modes[i]->vdisplay == mode.Height))
>                     {
>                         mode_index = i;
>                     }
>                 }
>                 // Switch to the mode
>                 if (mode_index != -1)
>                 {
>                     if(XF86VidModeSwitchToMode(dpy,
>                                                DefaultScreen(dpy), 
>                                                modes[mode_index]))
>                     {
>                         nlinfo("Switching to mode %dx%d,\n",mode.Width, 
>                                                             mode.Height);
>                         XF86VidModeSetViewPort(dpy,DefaultScreen(dpy),0, 0);
>                         _FullScreen = true;
>                     }
>                 }
>                 else
>                 {
>                     // This is a problem, since we've nuked the border from 
>                     // window in the setup stage, until I work out how
>                     // to get it back (recreate window? seems excessive)
>                     nlerror("Couldn't find an appropriate mode %dx%d\n",
>                                                                 mode.Width,
>                                                                 mode.Height);
>                 }
>             }
>         }
>     }
> #endif // XF86VIDMODE
659c755,776
< #endif // NL_OS_WINDOWS
---
> #elif defined (NL_OS_UNIX)// NL_OS_WINDOWS
> 
> #ifdef XF86VIDMODE
>     if(_FullScreen)
>     {
>         XF86VidModeModeInfo info;
>         nlinfo("Switching back to original mode \n");
> 
>         // This is a bit ugly - a quick hack to copy the ModeLine structure 
>         // into the modeInfo structure.
>         memcpy((XF86VidModeModeLine *)((char *)&info + sizeof(info.dotclock)), &_OldScreenMode, sizeof(XF86VidModeModeLine));
>         info.dotclock = _OldDotClock;
> 
>         nlinfo("Mode is %dx%d,\n",info.hdisplay,info.vdisplay);
>         XF86VidModeSwitchToMode(dpy,DefaultScreen(dpy),&info);
>         nlinfo("Switching viewporr to %d,%d,\n",_OldX, _OldY);
>         XF86VidModeSetViewPort(dpy,DefaultScreen(dpy),_OldX,_OldY);
>         // Ungrab the keyboard (probably not necessary);
>         XUngrabKeyboard(dpy, CurrentTime);
>     }
> #endif // XF86VIDMODE
> #endif // NL_OS_UNIX

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.driver_opengl.h"

Index: driver_opengl.h
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/driver/opengl/driver_opengl.h,v
retrieving revision 1.50
diff -r1.50 driver_opengl.h
40a41
> #include <X11/extensions/xf86vmode.h>
219a221
> 	bool						_FullScreen;
230d231
< 	bool						_FullScreen;
238a240,244
> //#ifdef XF86VIDMODE
>     int                         _OldDotClock;   // old dotclock
>     XF86VidModeModeLine         _OldScreenMode; // old modeline
>     int                         _OldX, _OldY;   //Viewport settings
> //#endif //XF86VIDMODE
240d245
< 

--vkogqOf2sHV7VnPd--