Commit b8df2868 authored by Sam Lantinga's avatar Sam Lantinga

The event code was fine, and calculated the SDL_windowX/Y correctly.

What we really needed to do was avoid doing client rect adjustment on
zoomed windows. :)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401293
parent b49e57ab
...@@ -566,13 +566,13 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -566,13 +566,13 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int w, h; int w, h;
GetClientRect(SDL_Window, &SDL_bounds); GetClientRect(SDL_Window, &SDL_bounds);
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
SDL_windowX = SDL_bounds.left; SDL_windowX = SDL_bounds.left;
SDL_windowY = SDL_bounds.top; SDL_windowY = SDL_bounds.top;
w = SDL_bounds.right-SDL_bounds.left; w = SDL_bounds.right-SDL_bounds.left;
h = SDL_bounds.bottom-SDL_bounds.top; h = SDL_bounds.bottom-SDL_bounds.top;
if ( this->input_grab != SDL_GRAB_OFF ) { if ( this->input_grab != SDL_GRAB_OFF ) {
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
ClipCursor(&SDL_bounds); ClipCursor(&SDL_bounds);
} }
if ( SDL_PublicSurface && if ( SDL_PublicSurface &&
......
...@@ -665,13 +665,15 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -665,13 +665,15 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
} }
/* Resize the window */ /* Resize the window */
if ( !SDL_windowid ) { if ( !SDL_windowid && !IsZoomed(SDL_Window) ) {
HWND top; HWND top;
UINT swp_flags; UINT swp_flags;
const char *window = getenv("SDL_VIDEO_WINDOW_POS"); const char *window = NULL;
const char *center = getenv("SDL_VIDEO_CENTERED"); const char *center = NULL;
if ( !SDL_windowX && !SDL_windowY ) { if ( !SDL_windowX && !SDL_windowY ) {
window = getenv("SDL_VIDEO_WINDOW_POS");
center = getenv("SDL_VIDEO_CENTERED");
if ( window ) { if ( window ) {
if ( sscanf(window, "%d,%d", &x, &y) == 2 ) { if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
SDL_windowX = x; SDL_windowX = x;
...@@ -679,7 +681,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -679,7 +681,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
} }
if ( strcmp(window, "center") == 0 ) { if ( strcmp(window, "center") == 0 ) {
center = window; center = window;
window = NULL;
} }
} }
} }
...@@ -706,9 +707,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -706,9 +707,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
x = y = -1; x = y = -1;
swp_flags |= SWP_NOMOVE; swp_flags |= SWP_NOMOVE;
} }
if ( y < 0 ) { /* Cover up title bar for more client area */
y -= GetSystemMetrics(SM_CYCAPTION)/2;
}
if ( flags & SDL_FULLSCREEN ) { if ( flags & SDL_FULLSCREEN ) {
top = HWND_TOPMOST; top = HWND_TOPMOST;
} else { } else {
......
...@@ -1003,7 +1003,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1003,7 +1003,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
const DWORD resizestyle = const DWORD resizestyle =
(WS_THICKFRAME|WS_MAXIMIZEBOX); (WS_THICKFRAME|WS_MAXIMIZEBOX);
int windowX, windowY;
DDSURFACEDESC ddsd; DDSURFACEDESC ddsd;
LPDIRECTDRAWSURFACE dd_surface1; LPDIRECTDRAWSURFACE dd_surface1;
LPDIRECTDRAWSURFACE3 dd_surface3; LPDIRECTDRAWSURFACE3 dd_surface3;
...@@ -1036,8 +1035,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1036,8 +1035,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
/* If we are setting a GL mode, use GDI, not DirectX (yuck) */ /* If we are setting a GL mode, use GDI, not DirectX (yuck) */
if ( flags & SDL_OPENGL ) { if ( flags & SDL_OPENGL ) {
RECT bounds;
int x, y;
Uint32 Rmask, Gmask, Bmask; Uint32 Rmask, Gmask, Bmask;
/* Recalculate the bitmasks if necessary */ /* Recalculate the bitmasks if necessary */
...@@ -1137,13 +1134,17 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1137,13 +1134,17 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
SetWindowLong(SDL_Window, GWL_STYLE, style); SetWindowLong(SDL_Window, GWL_STYLE, style);
/* Resize the window (copied from SDL WinDIB driver) */ /* Resize the window (copied from SDL WinDIB driver) */
if ( !SDL_windowid ) { if ( !SDL_windowid && !IsZoomed(SDL_Window) ) {
RECT bounds;
int x, y;
HWND top; HWND top;
UINT swp_flags; UINT swp_flags;
const char *window = getenv("SDL_VIDEO_WINDOW_POS"); const char *window = NULL;
const char *center = getenv("SDL_VIDEO_CENTERED"); const char *center = NULL;
if ( !SDL_windowX && !SDL_windowY ) { if ( !SDL_windowX && !SDL_windowY ) {
window = getenv("SDL_VIDEO_WINDOW_POS");
center = getenv("SDL_VIDEO_CENTERED");
if ( window ) { if ( window ) {
if ( sscanf(window, "%d,%d", &x, &y) == 2 ) { if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
SDL_windowX = x; SDL_windowX = x;
...@@ -1151,7 +1152,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1151,7 +1152,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
} }
if ( strcmp(window, "center") == 0 ) { if ( strcmp(window, "center") == 0 ) {
center = window; center = window;
window = NULL;
} }
} }
} }
...@@ -1178,9 +1178,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1178,9 +1178,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
x = y = -1; x = y = -1;
swp_flags |= SWP_NOMOVE; swp_flags |= SWP_NOMOVE;
} }
if ( y < 0 ) { /* Cover up title bar for more client area */
y -= GetSystemMetrics(SM_CYCAPTION)/2;
}
if ( flags & SDL_FULLSCREEN ) { if ( flags & SDL_FULLSCREEN ) {
top = HWND_TOPMOST; top = HWND_TOPMOST;
} else { } else {
...@@ -1200,8 +1197,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1200,8 +1197,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
} }
/* Set the appropriate window style */ /* Set the appropriate window style */
windowX = SDL_windowX;
windowY = SDL_windowY;
style = GetWindowLong(SDL_Window, GWL_STYLE); style = GetWindowLong(SDL_Window, GWL_STYLE);
style &= ~(resizestyle|WS_MAXIMIZE); style &= ~(resizestyle|WS_MAXIMIZE);
if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
...@@ -1237,8 +1232,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1237,8 +1232,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
SetDDerror("DirectDraw2::SetCooperativeLevel", result); SetDDerror("DirectDraw2::SetCooperativeLevel", result);
return(NULL); return(NULL);
} }
SDL_windowX = windowX;
SDL_windowY = windowY;
/* Set the display mode, if we are in fullscreen mode */ /* Set the display mode, if we are in fullscreen mode */
if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
...@@ -1513,12 +1506,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1513,12 +1506,6 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
/* Make our window the proper size, set the clipper, then show it */ /* Make our window the proper size, set the clipper, then show it */
if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) { if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
RECT bounds;
int x, y;
UINT swp_flags;
const char *window = getenv("SDL_VIDEO_WINDOW_POS");
const char *center = getenv("SDL_VIDEO_CENTERED");
/* Create and set a clipper on our primary surface */ /* Create and set a clipper on our primary surface */
if ( SDL_clipper == NULL ) { if ( SDL_clipper == NULL ) {
result = IDirectDraw2_CreateClipper(ddraw2, result = IDirectDraw2_CreateClipper(ddraw2,
...@@ -1549,46 +1536,50 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1549,46 +1536,50 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
return(NULL); return(NULL);
} }
if ( !SDL_windowX && !SDL_windowY ) { /* Resize the window (copied from SDL WinDIB driver) */
if ( window ) { if ( !SDL_windowid && !IsZoomed(SDL_Window) ) {
if ( sscanf(window, "%d,%d", &x, &y) == 2 ) { RECT bounds;
SDL_windowX = x; int x, y;
SDL_windowY = y; UINT swp_flags;
} const char *window = NULL;
if ( strcmp(window, "center") == 0 ) { const char *center = NULL;
center = window;
window = NULL; if ( !SDL_windowX && !SDL_windowY ) {
window = getenv("SDL_VIDEO_WINDOW_POS");
center = getenv("SDL_VIDEO_CENTERED");
if ( window ) {
if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
SDL_windowX = x;
SDL_windowY = y;
}
if ( strcmp(window, "center") == 0 ) {
center = window;
}
} }
} }
} swp_flags = SWP_NOCOPYBITS;
swp_flags = SWP_NOCOPYBITS;
SDL_resizing = 1; SDL_resizing = 1;
bounds.left = SDL_windowX; bounds.left = SDL_windowX;
bounds.top = SDL_windowY; bounds.top = SDL_windowY;
bounds.right = SDL_windowX+video->w; bounds.right = SDL_windowX+video->w;
bounds.bottom = SDL_windowY+video->h; bounds.bottom = SDL_windowY+video->h;
AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
width = bounds.right-bounds.left; width = bounds.right-bounds.left;
height = bounds.bottom-bounds.top; height = bounds.bottom-bounds.top;
if ( (flags & SDL_FULLSCREEN) ) { if ( center ) {
x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
} else if ( center ) { } else if ( SDL_windowX || SDL_windowY || window ) {
x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; x = bounds.left;
y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; y = bounds.top;
} else if ( SDL_windowX || SDL_windowY || window ) { } else {
x = bounds.left; x = y = -1;
y = bounds.top; swp_flags |= SWP_NOMOVE;
} else { }
x = y = -1; SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height, swp_flags);
swp_flags |= SWP_NOMOVE; SDL_resizing = 0;
}
if ( y < 0 ) { /* Cover up title bar for more client area */
y -= GetSystemMetrics(SM_CYCAPTION)/2;
} }
SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height, swp_flags);
SDL_resizing = 0;
} }
ShowWindow(SDL_Window, SW_SHOW); ShowWindow(SDL_Window, SW_SHOW);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment