Mercurial > sdl-ios-xcode
comparison src/video/win32/SDL_win32window.c @ 3530:e96be66e3673
The window position is display relative, at least for now...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 06 Dec 2009 08:39:01 +0000 |
parents | 59ff7a2beb57 |
children | 07c8339c95c6 |
comparison
equal
deleted
inserted
replaced
3529:09155ec3e291 | 3530:e96be66e3673 |
---|---|
84 | 84 |
85 static int | 85 static int |
86 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) | 86 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) |
87 { | 87 { |
88 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; | 88 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
89 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
89 SDL_WindowData *data; | 90 SDL_WindowData *data; |
90 | 91 |
91 /* Allocate the window data */ | 92 /* Allocate the window data */ |
92 data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); | 93 data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); |
93 if (!data) { | 94 if (!data) { |
121 { | 122 { |
122 POINT point; | 123 POINT point; |
123 point.x = 0; | 124 point.x = 0; |
124 point.y = 0; | 125 point.y = 0; |
125 if (ClientToScreen(hwnd, &point)) { | 126 if (ClientToScreen(hwnd, &point)) { |
126 window->x = point.x; | 127 SDL_Rect bounds; |
127 window->y = point.y; | 128 WIN_GetDisplayBounds(_this, display, &bounds); |
129 window->x = point.x - bounds.x; | |
130 window->y = point.y - bounds.y; | |
128 } | 131 } |
129 } | 132 } |
130 { | 133 { |
131 RECT rect; | 134 RECT rect; |
132 if (GetClientRect(hwnd, &rect)) { | 135 if (GetClientRect(hwnd, &rect)) { |
230 x = CW_USEDEFAULT; | 233 x = CW_USEDEFAULT; |
231 } else { | 234 } else { |
232 x = bounds.x; | 235 x = bounds.x; |
233 } | 236 } |
234 } else { | 237 } else { |
235 x = window->x + rect.left; | 238 x = bounds.x + window->x + rect.left; |
236 } | 239 } |
237 if ((window->flags & SDL_WINDOW_FULLSCREEN) | 240 if ((window->flags & SDL_WINDOW_FULLSCREEN) |
238 || window->y == SDL_WINDOWPOS_CENTERED) { | 241 || window->y == SDL_WINDOWPOS_CENTERED) { |
239 y = bounds.y + (bounds.h - window->h) / 2; | 242 y = bounds.y + (bounds.h - window->h) / 2; |
240 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { | 243 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { |
242 y = CW_USEDEFAULT; | 245 y = CW_USEDEFAULT; |
243 } else { | 246 } else { |
244 y = bounds.y; | 247 y = bounds.y; |
245 } | 248 } |
246 } else { | 249 } else { |
247 y = window->y + rect.top; | 250 y = bounds.y + window->y + rect.top; |
248 } | 251 } |
249 | 252 |
250 hwnd = | 253 hwnd = |
251 CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL, | 254 CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL, |
252 SDL_Instance, NULL); | 255 SDL_Instance, NULL); |
457 WIN_GetDisplayBounds(_this, display, &bounds); | 460 WIN_GetDisplayBounds(_this, display, &bounds); |
458 if ((window->flags & SDL_WINDOW_FULLSCREEN) | 461 if ((window->flags & SDL_WINDOW_FULLSCREEN) |
459 || window->x == SDL_WINDOWPOS_CENTERED) { | 462 || window->x == SDL_WINDOWPOS_CENTERED) { |
460 x = bounds.x + (bounds.w - window->w) / 2; | 463 x = bounds.x + (bounds.w - window->w) / 2; |
461 } else { | 464 } else { |
462 x = window->x + rect.left; | 465 x = bounds.x + window->x + rect.left; |
463 } | 466 } |
464 if ((window->flags & SDL_WINDOW_FULLSCREEN) | 467 if ((window->flags & SDL_WINDOW_FULLSCREEN) |
465 || window->y == SDL_WINDOWPOS_CENTERED) { | 468 || window->y == SDL_WINDOWPOS_CENTERED) { |
466 y = bounds.y + (bounds.h - window->h) / 2; | 469 y = bounds.y + (bounds.h - window->h) / 2; |
467 } else { | 470 } else { |
468 y = window->y + rect.top; | 471 y = bounds.y + window->y + rect.top; |
469 } | 472 } |
470 | 473 |
471 SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE)); | 474 SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE)); |
472 } | 475 } |
473 | 476 |