src/video/windx5/SDL_dx5video.c
changeset 1295 c3e36ac8a94c
parent 1291 31331c444ea2
child 1312 c9b51268668f
     1.1 --- a/src/video/windx5/SDL_dx5video.c	Sun Jan 29 23:14:04 2006 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5video.c	Mon Jan 30 06:56:10 2006 +0000
     1.3 @@ -656,6 +656,14 @@
     1.4  	int bpp = desc->ddpfPixelFormat.dwRGBBitCount;
     1.5  	int refreshRate = desc->dwRefreshRate;
     1.6  #endif
     1.7 +	int maxRefreshRate;
     1.8 +
     1.9 +	if ( desc->dwWidth <= SDL_desktop_mode.dmPelsWidth &&
    1.10 +	     desc->dwHeight <= SDL_desktop_mode.dmPelsHeight ) {
    1.11 +		maxRefreshRate = SDL_desktop_mode.dmDisplayFrequency;
    1.12 +	} else {
    1.13 +		maxRefreshRate = 85;	/* safe value? */
    1.14 +	}
    1.15  
    1.16  	switch (bpp)  {
    1.17  		case 8:
    1.18 @@ -667,7 +675,7 @@
    1.19  			     enumlists[bpp]->r.w == (Uint16)desc->dwWidth &&
    1.20  			     enumlists[bpp]->r.h == (Uint16)desc->dwHeight ) {
    1.21  				if ( refreshRate > enumlists[bpp]->refreshRate &&
    1.22 -				     refreshRate <= 85 /* safe value? */ ) {
    1.23 +				     refreshRate <= maxRefreshRate ) {
    1.24  					enumlists[bpp]->refreshRate = refreshRate;
    1.25  #ifdef DDRAW_DEBUG
    1.26   fprintf(stderr, "New refresh rate for %d bpp: %dx%d at %d Hz\n", (bpp+1)*8, (int)desc->dwWidth, (int)desc->dwHeight, refreshRate);
    1.27 @@ -926,6 +934,11 @@
    1.28  					GetDeviceCaps(hdc,BITSPIXEL);
    1.29  	ReleaseDC(SDL_Window, hdc);
    1.30  
    1.31 +#ifndef NO_CHANGEDISPLAYSETTINGS
    1.32 +	/* Query for the desktop resolution */
    1.33 +	EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
    1.34 +#endif
    1.35 +
    1.36  	/* Enumerate the available fullscreen modes */
    1.37  	for ( i=0; i<NUM_MODELISTS; ++i )
    1.38  		enumlists[i] = NULL;
    1.39 @@ -1093,6 +1106,7 @@
    1.40  		 */
    1.41  		if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
    1.42  			DEVMODE settings;
    1.43 +			BOOL changed;
    1.44  
    1.45  			memset(&settings, 0, sizeof(DEVMODE));
    1.46  			settings.dmSize = sizeof(DEVMODE);
    1.47 @@ -1100,7 +1114,16 @@
    1.48  			settings.dmPelsWidth = width;
    1.49  			settings.dmPelsHeight = height;
    1.50  			settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
    1.51 -			if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
    1.52 +			if ( width <= SDL_desktop_mode.dmPelsWidth && height <= SDL_desktop_mode.dmPelsHeight ) {
    1.53 +				settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency;
    1.54 +				settings.dmFields |= DM_DISPLAYFREQUENCY;
    1.55 +			}
    1.56 +			changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);
    1.57 +			if ( ! changed && (settings.dmFields & DM_DISPLAYFREQUENCY) ) {
    1.58 +				settings.dmFields &= ~DM_DISPLAYFREQUENCY;
    1.59 +				changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);
    1.60 +			}
    1.61 +			if ( changed ) {
    1.62  				video->flags |= SDL_FULLSCREEN;
    1.63  				SDL_fullscreen_mode = settings;
    1.64  			}