Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Simplified Windows window creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Feb 22, 2011
1 parent 83a95b2 commit 8ea0b21
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions src/video/windows/SDL_windowswindow.c
Expand Up @@ -194,46 +194,23 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
HWND hwnd;
RECT rect;
SDL_Rect bounds;
DWORD style = STYLE_BASIC;
int x, y;
int w, h;

style |= GetWindowStyle(window);

/* Figure out what the window area will be */
rect.left = 0;
rect.top = 0;
rect.right = window->w;
rect.bottom = window->h;
rect.left = window->x;
rect.top = window->y;
rect.right = window->x + window->w;
rect.bottom = window->y + window->h;
AdjustWindowRectEx(&rect, style, FALSE, 0);
x = rect.left;
y = rect.top;
w = (rect.right - rect.left);
h = (rect.bottom - rect.top);

WIN_GetDisplayBounds(_this, display, &bounds);
if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
x = bounds.x + (bounds.w - w) / 2;
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
if (bounds.x == 0) {
x = CW_USEDEFAULT;
} else {
x = bounds.x;
}
} else {
x = window->x + rect.left;
}
if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
y = bounds.y + (bounds.h - h) / 2;
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
if (bounds.x == 0) {
y = CW_USEDEFAULT;
} else {
y = bounds.y;
}
} else {
y = window->y + rect.top;
}

hwnd =
CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
SDL_Instance, NULL);
Expand Down

0 comments on commit 8ea0b21

Please sign in to comment.