Merge remote-tracking branch 'svn/trunk' into git_master
This commit is contained in:
commit
2204e280c8
@ -29,17 +29,53 @@
|
||||
#include <GL/freeglut.h>
|
||||
#include "../fg_internal.h"
|
||||
|
||||
/* we'll try to use XR&R if it's available at compile-time, and at runtime, and the user
|
||||
* hasn't explicitly disabled it by setting the FREEGLUT_NO_XRANDR env-var.
|
||||
*/
|
||||
static int use_xrandr(void)
|
||||
{
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
int event_base, error_base;
|
||||
if(!XRRQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
|
||||
return 0;
|
||||
}
|
||||
if(getenv("FREEGLUT_NO_XRANDR")) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
#else
|
||||
return 0; /* no compile-time support */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* we'll try to use XF86VidMode if it's available at compile-time, and at runtime, and the
|
||||
* user hasn't explicitly disabled it by setting the FREEGLUT_NO_XF86VM env-var.
|
||||
*/
|
||||
static int use_xf86vm(void)
|
||||
{
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
int event_base, error_base;
|
||||
if(!XF86VidModeQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
|
||||
return 0;
|
||||
}
|
||||
if(getenv("FREEGLUT_NO_XF86VM")) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
#else
|
||||
return 0; /* no compile-time support */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
static int xrandr_resize(int xsz, int ysz, int rate, int just_checking)
|
||||
{
|
||||
int event_base, error_base, ver_major, ver_minor, use_rate;
|
||||
int ver_major, ver_minor, use_rate;
|
||||
XRRScreenConfiguration *xrr_config = 0;
|
||||
Status result = -1;
|
||||
|
||||
/* must check at runtime for the availability of the extension */
|
||||
if(!XRRQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
|
||||
return -1;
|
||||
}
|
||||
/* NOTE: we have already determined that XR&R is availble and enabled before calling this */
|
||||
|
||||
XRRQueryVersion(fgDisplay.pDisplay.Display, &ver_major, &ver_minor);
|
||||
|
||||
@ -147,10 +183,6 @@ static int xrandr_resize(int xsz, int ysz, int rate, int just_checking)
|
||||
*/
|
||||
void fgPlatformRememberState( void )
|
||||
{
|
||||
# if defined(HAVE_X11_EXTENSIONS_XRANDR_H) | defined(HAVE_X11_EXTENSIONS_XF86VMODE_H)
|
||||
int event_base, error_base;
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Remember the current pointer location before going fullscreen
|
||||
* for restoring it later:
|
||||
@ -164,7 +196,7 @@ void fgPlatformRememberState( void )
|
||||
&fgDisplay.pDisplay.DisplayPointerX, &fgDisplay.pDisplay.DisplayPointerY, &junk_mask);
|
||||
|
||||
# ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
if(XRRQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
|
||||
if(use_xrandr()) {
|
||||
XRRScreenConfiguration *xrr_config;
|
||||
XRRScreenSize *ssizes;
|
||||
Rotation rot;
|
||||
@ -189,17 +221,14 @@ void fgPlatformRememberState( void )
|
||||
XRRFreeScreenConfigInfo(xrr_config);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
|
||||
|
||||
/*
|
||||
* This highly depends on the XFree86 extensions,
|
||||
* not approved as X Consortium standards
|
||||
*/
|
||||
# ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
if(!XF86VidModeQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(use_xf86vm()) {
|
||||
/*
|
||||
* Remember the current ViewPort location of the screen to be able to
|
||||
* restore the ViewPort on LeaveGameMode():
|
||||
@ -223,6 +252,7 @@ void fgPlatformRememberState( void )
|
||||
|
||||
if( !fgDisplay.pDisplay.DisplayModeValid )
|
||||
fgWarning( "XF86VidModeGetModeLine failed" );
|
||||
}
|
||||
# endif
|
||||
|
||||
}
|
||||
@ -238,18 +268,19 @@ void fgPlatformRestoreState( void )
|
||||
fgDisplay.pDisplay.DisplayPointerX, fgDisplay.pDisplay.DisplayPointerY
|
||||
);
|
||||
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
if(use_xrandr()) {
|
||||
if(fgDisplay.pDisplay.prev_size_valid) {
|
||||
if(xrandr_resize(fgDisplay.pDisplay.prev_xsz, fgDisplay.pDisplay.prev_ysz, fgDisplay.pDisplay.prev_refresh, 0) != -1) {
|
||||
fgDisplay.pDisplay.prev_size_valid = 0;
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
fgDisplay.pDisplay.DisplayModeValid = 0;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
return; /* don't fall back to XF86VidMode if we have XR&R */
|
||||
}
|
||||
#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
|
||||
|
||||
|
||||
|
||||
@ -258,6 +289,7 @@ void fgPlatformRestoreState( void )
|
||||
* This highly depends on the XFree86 extensions,
|
||||
* not approved as X Consortium standards
|
||||
*/
|
||||
if(use_xf86vm()) {
|
||||
|
||||
if( fgDisplay.pDisplay.DisplayModeValid )
|
||||
{
|
||||
@ -313,15 +345,13 @@ void fgPlatformRestoreState( void )
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
fgDisplay.pDisplay.prev_size_valid = 0;
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
XFree( displayModes );
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
}
|
||||
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
|
||||
}
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
@ -378,13 +408,15 @@ static int fghCheckDisplayModes( GLboolean exactMatch, int displayModesCount, XF
|
||||
GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
{
|
||||
GLboolean success = GL_FALSE;
|
||||
/* first try to use XRandR, then fallback to XF86VidMode */
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
if(use_xrandr()) {
|
||||
if(xrandr_resize(fgState.GameModeSize.X, fgState.GameModeSize.Y,
|
||||
fgState.GameModeRefresh, haveToTest) != -1) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
# endif
|
||||
return GL_FALSE; /* don't fall back to XF86VidMode */
|
||||
}
|
||||
#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
|
||||
|
||||
|
||||
/*
|
||||
@ -392,7 +424,7 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
* not approved as X Consortium standards
|
||||
*/
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
|
||||
if(use_xf86vm()) {
|
||||
/*
|
||||
* This is also used by applications which check modes by calling
|
||||
* glutGameModeGet(GLUT_GAME_MODE_POSSIBLE), so allow the check:
|
||||
@ -469,8 +501,9 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
|
||||
XFree( displayModes );
|
||||
}
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -522,6 +555,7 @@ void fgPlatformEnterGameMode( void )
|
||||
);
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
if(use_xf86vm()) {
|
||||
|
||||
if( fgDisplay.pDisplay.DisplayModeValid )
|
||||
{
|
||||
@ -551,8 +585,9 @@ void fgPlatformEnterGameMode( void )
|
||||
XMoveWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
|
||||
-x, -y);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
|
||||
|
||||
/* Grab the keyboard, too */
|
||||
XGrabKeyboard(
|
||||
|
Reference in New Issue
Block a user