Fixed part of bug #926883 (Video mode matching code, memory leaks,

fullscreen), i.e. issue warnings when XF86VidModeFOO fails.


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@559 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
spanne 2005-01-03 17:11:33 +00:00
parent c70e6634ff
commit 1aa0b5ccf6
2 changed files with 53 additions and 32 deletions

View File

@ -902,3 +902,6 @@ refresh rate if none could be found. This way the X11 part and the WinDoze
behave similarly. NOTE: We still don't behave like GLUT, because it has a behave similarly. NOTE: We still don't behave like GLUT, because it has a
wider notion of "best" match. We have to refactor and extend freeglut quite wider notion of "best" match. We have to refactor and extend freeglut quite
a bit to do that. a bit to do that.
(235) Fixed part of bug #926883 (Video mode matching code, memory leaks,
fullscreen), i.e. issue warnings when XF86VidModeFOO fails.

View File

@ -59,12 +59,12 @@ static void fghRememberState( void )
* Remember the current ViewPort location of the screen to be able to * Remember the current ViewPort location of the screen to be able to
* restore the ViewPort on LeaveGameMode(): * restore the ViewPort on LeaveGameMode():
*/ */
XF86VidModeGetViewPort( if( !XF86VidModeGetViewPort(
fgDisplay.Display, fgDisplay.Display,
fgDisplay.Screen, fgDisplay.Screen,
&fgDisplay.DisplayViewPortX, &fgDisplay.DisplayViewPortX,
&fgDisplay.DisplayViewPortY &fgDisplay.DisplayViewPortY ) )
); fgWarning( "XF86VidModeGetViewPort failed" );
/* /*
* Remember the current pointer location before going fullscreen * Remember the current pointer location before going fullscreen
@ -92,7 +92,7 @@ static void fghRememberState( void )
); );
if( !fgDisplay.DisplayModeValid ) if( !fgDisplay.DisplayModeValid )
fgWarning( "Runtime use of XF86VidModeGetModeLine failed." ); fgWarning( "XF86VidModeGetModeLine failed" );
# else # else
/* /*
@ -144,12 +144,16 @@ static void fghRestoreState( void )
XF86VidModeModeInfo** displayModes; XF86VidModeModeInfo** displayModes;
int i, displayModesCount; int i, displayModesCount;
XF86VidModeGetAllModeLines( if( !XF86VidModeGetAllModeLines(
fgDisplay.Display, fgDisplay.Display,
fgDisplay.Screen, fgDisplay.Screen,
&displayModesCount, &displayModesCount,
&displayModes &displayModes ) )
); {
fgWarning( "XF86VidModeGetAllModeLines failed" );
return;
}
/* /*
* Check every of the modes looking for one that matches our demands. * Check every of the modes looking for one that matches our demands.
@ -161,17 +165,22 @@ static void fghRestoreState( void )
displayModes[ i ]->vdisplay == fgDisplay.DisplayMode.vdisplay && displayModes[ i ]->vdisplay == fgDisplay.DisplayMode.vdisplay &&
displayModes[ i ]->dotclock == fgDisplay.DisplayModeClock ) displayModes[ i ]->dotclock == fgDisplay.DisplayModeClock )
{ {
XF86VidModeSwitchToMode( if( !XF86VidModeSwitchToMode(
fgDisplay.Display, fgDisplay.Display,
fgDisplay.Screen, fgDisplay.Screen,
displayModes[ i ] displayModes[ i ] ) )
); {
XF86VidModeSetViewPort( fgWarning( "XF86VidModeSwitchToMode failed" );
fgDisplay.Display, break;
fgDisplay.Screen, }
fgDisplay.DisplayViewPortX,
fgDisplay.DisplayViewPortY if( !XF86VidModeSetViewPort(
); fgDisplay.Display,
fgDisplay.Screen,
fgDisplay.DisplayViewPortX,
fgDisplay.DisplayViewPortY ) )
fgWarning( "XF86VidModeSetViewPort failed" );
/* /*
* For the case this would be the last X11 call the application * For the case this would be the last X11 call the application
@ -236,12 +245,16 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest )
XF86VidModeModeInfo** displayModes; XF86VidModeModeInfo** displayModes;
int i, ignoreRefreshRate, displayModesCount; int i, ignoreRefreshRate, displayModesCount;
XF86VidModeGetAllModeLines( if( !XF86VidModeGetAllModeLines(
fgDisplay.Display, fgDisplay.Display,
fgDisplay.Screen, fgDisplay.Screen,
&displayModesCount, &displayModesCount,
&displayModes &displayModes ) )
); {
fgWarning( "XF86VidModeGetAllModeLines failed" );
return success;
}
/* /*
* Check every of the modes looking for one that matches our demands, * Check every of the modes looking for one that matches our demands,
@ -267,7 +280,11 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest )
} }
if( !haveToTest && success ) { if( !haveToTest && success ) {
XF86VidModeSwitchToMode( fgDisplay.Display, fgDisplay.Screen, displayModes[ i ] ); if( !XF86VidModeSwitchToMode(
fgDisplay.Display,
fgDisplay.Screen,
displayModes[ i ] ) )
fgWarning( "XF86VidModeSwitchToMode failed" );
} }
XFree( displayModes ); XFree( displayModes );
@ -473,7 +490,8 @@ int FGAPIENTRY glutEnterGameMode( void )
Window child; Window child;
/* Change to viewport to the window topleft edge: */ /* Change to viewport to the window topleft edge: */
XF86VidModeSetViewPort( fgDisplay.Display, fgDisplay.Screen, 0, 0 ); if( !XF86VidModeSetViewPort( fgDisplay.Display, fgDisplay.Screen, 0, 0 ) )
fgWarning( "XF86VidModeSetViewPort failed" );
/* /*
* Final window repositioning: It could be avoided using an undecorated * Final window repositioning: It could be avoided using an undecorated