comparison src/video/win32/SDL_win32window.c @ 2875:91a7e08cd238

* Implemented X11 fullscreen input grab * Progress towards being able to toggle in and out of fullscreen mode
author Sam Lantinga <slouken@libsdl.org>
date Wed, 17 Dec 2008 07:17:54 +0000
parents 09adf4854163
children 3fcb0d447bcd
comparison
equal deleted inserted replaced
2874:36e312e0fac0 2875:91a7e08cd238
157 RECT rect; 157 RECT rect;
158 DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN); 158 DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
159 int x, y; 159 int x, y;
160 int w, h; 160 int w, h;
161 161
162 if (window->flags & SDL_WINDOW_BORDERLESS) { 162 if (window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN)) {
163 style |= WS_POPUP; 163 style |= WS_POPUP;
164 } else { 164 } else {
165 style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX); 165 style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
166 } 166 }
167 if (window->flags & SDL_WINDOW_RESIZABLE) { 167 if ((window->flags & SDL_WINDOW_RESIZABLE) && !(window->flags & SDL_WINDOW_FULLSCREEN)) {
168 style |= (WS_THICKFRAME | WS_MAXIMIZEBOX); 168 style |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
169 } 169 }
170 170
171 /* Figure out what the window area will be */ 171 /* Figure out what the window area will be */
172 if (window->flags & SDL_WINDOW_FULLSCREEN) { 172 if (window->flags & SDL_WINDOW_FULLSCREEN) {
180 rect.bottom = window->h; 180 rect.bottom = window->h;
181 AdjustWindowRectEx(&rect, style, FALSE, 0); 181 AdjustWindowRectEx(&rect, style, FALSE, 0);
182 w = (rect.right - rect.left); 182 w = (rect.right - rect.left);
183 h = (rect.bottom - rect.top); 183 h = (rect.bottom - rect.top);
184 184
185 if (window->x == SDL_WINDOWPOS_CENTERED) { 185 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->x == SDL_WINDOWPOS_CENTERED) {
186 x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; 186 x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
187 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { 187 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
188 x = CW_USEDEFAULT; 188 x = CW_USEDEFAULT;
189 } else { 189 } else {
190 x = window->x + rect.left; 190 x = window->x + rect.left;
191 } 191 }
192 if (window->y == SDL_WINDOWPOS_CENTERED) { 192 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->y == SDL_WINDOWPOS_CENTERED) {
193 y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; 193 y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
194 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { 194 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
195 y = CW_USEDEFAULT; 195 y = CW_USEDEFAULT;
196 } else { 196 } else {
197 y = window->y + rect.top; 197 y = window->y + rect.top;
329 rect.right = window->w; 329 rect.right = window->w;
330 rect.bottom = window->h; 330 rect.bottom = window->h;
331 AdjustWindowRectEx(&rect, style, 331 AdjustWindowRectEx(&rect, style,
332 (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != 332 (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) !=
333 NULL), 0); 333 NULL), 0);
334 x = window->x + rect.left; 334
335 y = window->y + rect.top; 335 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->x == SDL_WINDOWPOS_CENTERED) {
336 x = (GetSystemMetrics(SM_CXSCREEN) - window->w) / 2;
337 } else {
338 x = window->x + rect.left;
339 }
340 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->y == SDL_WINDOWPOS_CENTERED) {
341 y = (GetSystemMetrics(SM_CYSCREEN) - window->h) / 2;
342 } else {
343 y = window->y + rect.top;
344 }
336 345
337 SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE)); 346 SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
338 } 347 }
339 348
340 void 349 void
423 void 432 void
424 WIN_SetWindowGrab(_THIS, SDL_Window * window) 433 WIN_SetWindowGrab(_THIS, SDL_Window * window)
425 { 434 {
426 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; 435 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
427 436
428 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && 437 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED|SDL_WINDOW_FULLSCREEN)) &&
429 (window->flags & SDL_WINDOW_INPUT_FOCUS)) { 438 (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
430 RECT rect; 439 RECT rect;
431 GetClientRect(hwnd, &rect); 440 GetClientRect(hwnd, &rect);
432 ClientToScreen(hwnd, (LPPOINT) & rect); 441 ClientToScreen(hwnd, (LPPOINT) & rect);
433 ClientToScreen(hwnd, (LPPOINT) & rect + 1); 442 ClientToScreen(hwnd, (LPPOINT) & rect + 1);