Subject: [Nel] Linux fullscreen patches

From: Leighton Haynes <[email-masked]>
Date: Wed, 28 Feb 2001 20:16:17 +0800

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)
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
> 
> 
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
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
<

---

From: Yan Babilliot <[email-masked]>
Date: 28 Feb 2001 15:16:03 +0100

putain quand je vois ca ca mfout les nerfs d'informaticien. Zauraaient
du vous acheter des pots de yaourt avec des ficelles s'aurait ete moins
cher ...

---

From: Yan Babilliot <[email-masked]>
Date: 28 Feb 2001 15:38:32 +0100

oops sorry ;)   
[email-masked] wasn't the destination of this mail ..... a goofy click
:(

> On 28 Feb 2001 15:16:03 +0100, Yan Babilliot wrote:

> _______________________________________________
> Nel mailing list
> [email-masked]
> /mailman/listinfo.cgi/nel

---

From: Vincent Archer <[email-masked]>
Date: Wed, 28 Feb 2001 16:05:17 +0100

> [email-masked] wasn't the destination of this mail ..... a goofy click

Too much network destroys the network.

I'm rather fond of smoke signals myself. A lot better than can'n string
for long range transmission, but the bandwidth sucks :)

-- 
Vincent Archer                                         Email: [email-masked]

Nevrax France.                              Off on the yellow brick road we go!

---

From: Valignat Cedric <[email-masked]>
Date: Wed, 28 Feb 2001 17:23:20 +0100

Hi Leighton,

Leighton Haynes wrote:
> [...]

Nice ! :-)))

Give some time to apply and test your patches, and it will be "integrated" ;-)

Thanks,

Cedric.