src/video/windx5/SDL_dx5video.c
changeset 1290 c4a5a772c5d9
parent 1288 ea3888b472bf
child 1291 31331c444ea2
     1.1 --- a/src/video/windx5/SDL_dx5video.c	Sun Jan 29 09:19:55 2006 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5video.c	Sun Jan 29 18:17:35 2006 +0000
     1.3 @@ -1003,7 +1003,6 @@
     1.4  			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
     1.5  	const DWORD resizestyle =
     1.6  			(WS_THICKFRAME|WS_MAXIMIZEBOX);
     1.7 -	int windowX, windowY;
     1.8  	DDSURFACEDESC ddsd;
     1.9  	LPDIRECTDRAWSURFACE  dd_surface1;
    1.10  	LPDIRECTDRAWSURFACE3 dd_surface3;
    1.11 @@ -1036,8 +1035,6 @@
    1.12  
    1.13  	/* If we are setting a GL mode, use GDI, not DirectX (yuck) */
    1.14  	if ( flags & SDL_OPENGL ) {
    1.15 -		RECT bounds;
    1.16 -		int x, y;
    1.17  		Uint32 Rmask, Gmask, Bmask;
    1.18  
    1.19  		/* Recalculate the bitmasks if necessary */
    1.20 @@ -1137,13 +1134,17 @@
    1.21  			SetWindowLong(SDL_Window, GWL_STYLE, style);
    1.22  
    1.23  		/* Resize the window (copied from SDL WinDIB driver) */
    1.24 -		if ( !SDL_windowid ) {
    1.25 +		if ( !SDL_windowid && !IsZoomed(SDL_Window) ) {
    1.26 +			RECT bounds;
    1.27 +			int x, y;
    1.28  			HWND top;
    1.29  			UINT swp_flags;
    1.30 -			const char *window = getenv("SDL_VIDEO_WINDOW_POS");
    1.31 -			const char *center = getenv("SDL_VIDEO_CENTERED");
    1.32 +			const char *window = NULL;
    1.33 +			const char *center = NULL;
    1.34  
    1.35  			if ( !SDL_windowX && !SDL_windowY ) {
    1.36 +				window = getenv("SDL_VIDEO_WINDOW_POS");
    1.37 +				center = getenv("SDL_VIDEO_CENTERED");
    1.38  				if ( window ) {
    1.39  					if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
    1.40  						SDL_windowX = x;
    1.41 @@ -1151,7 +1152,6 @@
    1.42  					}
    1.43  					if ( strcmp(window, "center") == 0 ) {
    1.44  						center = window;
    1.45 -						window = NULL;
    1.46  					}
    1.47  				}
    1.48  			}
    1.49 @@ -1178,9 +1178,6 @@
    1.50  				x = y = -1;
    1.51  				swp_flags |= SWP_NOMOVE;
    1.52  			}
    1.53 -			if ( y < 0 ) { /* Cover up title bar for more client area */
    1.54 -				y -= GetSystemMetrics(SM_CYCAPTION)/2;
    1.55 -			}
    1.56  			if ( flags & SDL_FULLSCREEN ) {
    1.57  				top = HWND_TOPMOST;
    1.58  			} else {
    1.59 @@ -1200,8 +1197,6 @@
    1.60  	}
    1.61  
    1.62  	/* Set the appropriate window style */
    1.63 -	windowX = SDL_windowX;
    1.64 -	windowY = SDL_windowY;
    1.65  	style = GetWindowLong(SDL_Window, GWL_STYLE);
    1.66  	style &= ~(resizestyle|WS_MAXIMIZE);
    1.67  	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
    1.68 @@ -1237,8 +1232,6 @@
    1.69  		SetDDerror("DirectDraw2::SetCooperativeLevel", result);
    1.70  		return(NULL);
    1.71  	}
    1.72 -	SDL_windowX = windowX;
    1.73 -	SDL_windowY = windowY;
    1.74  
    1.75  	/* Set the display mode, if we are in fullscreen mode */
    1.76  	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
    1.77 @@ -1513,12 +1506,6 @@
    1.78  
    1.79  	/* Make our window the proper size, set the clipper, then show it */
    1.80  	if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
    1.81 -		RECT bounds;
    1.82 -		int  x, y;
    1.83 -		UINT swp_flags;
    1.84 -		const char *window = getenv("SDL_VIDEO_WINDOW_POS");
    1.85 -		const char *center = getenv("SDL_VIDEO_CENTERED");
    1.86 -
    1.87  		/* Create and set a clipper on our primary surface */
    1.88  		if ( SDL_clipper == NULL ) {
    1.89  			result = IDirectDraw2_CreateClipper(ddraw2,
    1.90 @@ -1549,46 +1536,50 @@
    1.91  			return(NULL);
    1.92  		}
    1.93  
    1.94 -		if ( !SDL_windowX && !SDL_windowY ) {
    1.95 -			if ( window ) {
    1.96 -				if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
    1.97 -					SDL_windowX = x;
    1.98 -					SDL_windowY = y;
    1.99 -				}
   1.100 -				if ( strcmp(window, "center") == 0 ) {
   1.101 -					center = window;
   1.102 -					window = NULL;
   1.103 +		/* Resize the window (copied from SDL WinDIB driver) */
   1.104 +		if ( !SDL_windowid && !IsZoomed(SDL_Window) ) {
   1.105 +			RECT bounds;
   1.106 +			int  x, y;
   1.107 +			UINT swp_flags;
   1.108 +			const char *window = NULL;
   1.109 +			const char *center = NULL;
   1.110 +
   1.111 +			if ( !SDL_windowX && !SDL_windowY ) {
   1.112 +				window = getenv("SDL_VIDEO_WINDOW_POS");
   1.113 +				center = getenv("SDL_VIDEO_CENTERED");
   1.114 +				if ( window ) {
   1.115 +					if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
   1.116 +						SDL_windowX = x;
   1.117 +						SDL_windowY = y;
   1.118 +					}
   1.119 +					if ( strcmp(window, "center") == 0 ) {
   1.120 +						center = window;
   1.121 +					}
   1.122  				}
   1.123  			}
   1.124 -		}
   1.125 -		swp_flags = SWP_NOCOPYBITS;
   1.126 +			swp_flags = SWP_NOCOPYBITS;
   1.127  
   1.128 -		SDL_resizing = 1;
   1.129 -		bounds.left = SDL_windowX;
   1.130 -		bounds.top = SDL_windowY;
   1.131 -		bounds.right = SDL_windowX+video->w;
   1.132 -		bounds.bottom = SDL_windowY+video->h;
   1.133 -		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
   1.134 -		width = bounds.right-bounds.left;
   1.135 -		height = bounds.bottom-bounds.top;
   1.136 -		if ( (flags & SDL_FULLSCREEN) ) {
   1.137 -			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
   1.138 -			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
   1.139 -		} else if ( center ) {
   1.140 -			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
   1.141 -			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
   1.142 -		} else if ( SDL_windowX || SDL_windowY || window ) {
   1.143 -			x = bounds.left;
   1.144 -			y = bounds.top;
   1.145 -		} else {
   1.146 -			x = y = -1;
   1.147 -			swp_flags |= SWP_NOMOVE;
   1.148 +			SDL_resizing = 1;
   1.149 +			bounds.left = SDL_windowX;
   1.150 +			bounds.top = SDL_windowY;
   1.151 +			bounds.right = SDL_windowX+video->w;
   1.152 +			bounds.bottom = SDL_windowY+video->h;
   1.153 +			AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
   1.154 +			width = bounds.right-bounds.left;
   1.155 +			height = bounds.bottom-bounds.top;
   1.156 +			if ( center ) {
   1.157 +				x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
   1.158 +				y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
   1.159 +			} else if ( SDL_windowX || SDL_windowY || window ) {
   1.160 +				x = bounds.left;
   1.161 +				y = bounds.top;
   1.162 +			} else {
   1.163 +				x = y = -1;
   1.164 +				swp_flags |= SWP_NOMOVE;
   1.165 +			}
   1.166 +			SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height, swp_flags);
   1.167 +			SDL_resizing = 0;
   1.168  		}
   1.169 -		if ( y < 0 ) { /* Cover up title bar for more client area */
   1.170 -			y -= GetSystemMetrics(SM_CYCAPTION)/2;
   1.171 -		}
   1.172 -		SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height, swp_flags);
   1.173 -		SDL_resizing = 0;
   1.174  
   1.175  	}
   1.176  	ShowWindow(SDL_Window, SW_SHOW);