comparison src/video/win32/SDL_win32events.c @ 1732:fd65f12b6de6 SDL-1.3

Implemented Win32 input grab
author Sam Lantinga <slouken@libsdl.org>
date Sat, 08 Jul 2006 20:55:39 +0000
parents 90a3e0fccb88
children 0b1070f2f94d
comparison
equal deleted inserted replaced
1731:875c3cf1a12c 1732:fd65f12b6de6
439 SDL_SendWindowEvent(data->windowID, 439 SDL_SendWindowEvent(data->windowID,
440 SDL_WINDOWEVENT_MAXIMIZED, 0, 0); 440 SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
441 } 441 }
442 if (keyboard && keyboard->focus != data->windowID) { 442 if (keyboard && keyboard->focus != data->windowID) {
443 SDL_SetKeyboardFocus(index, data->windowID); 443 SDL_SetKeyboardFocus(index, data->windowID);
444
445 if (SDL_GetWindowFlags(data->windowID) &
446 SDL_WINDOW_INPUT_GRABBED) {
447 RECT rect;
448
449 GetClientRect(hwnd, &rect);
450 ClientToScreen(hwnd, (LPPOINT) & rect);
451 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
452 ClipCursor(&rect);
453 }
444 } 454 }
445 /* FIXME: Restore mode state (mode, gamma, grab) */ 455 /* FIXME: Restore mode state (mode, gamma) */
446 /* FIXME: Update keyboard state */ 456 /* FIXME: Update keyboard state */
447 } else { 457 } else {
448 if (keyboard && keyboard->focus == data->windowID) { 458 if (keyboard && keyboard->focus == data->windowID) {
449 SDL_SetKeyboardFocus(index, 0); 459 SDL_SetKeyboardFocus(index, 0);
460
461 if (SDL_GetWindowFlags(data->windowID) &
462 SDL_WINDOW_INPUT_GRABBED) {
463 ClipCursor(NULL);
464 }
450 } 465 }
451 if (minimized) { 466 if (minimized) {
452 SDL_SendWindowEvent(data->windowID, 467 SDL_SendWindowEvent(data->windowID,
453 SDL_WINDOWEVENT_MINIMIZED, 0, 0); 468 SDL_WINDOWEVENT_MINIMIZED, 0, 0);
454 } 469 }
455 /* FIXME: Restore desktop state (mode, gamma, grab) */ 470 /* FIXME: Restore desktop state (mode, gamma) */
456 } 471 }
457 return (0); 472 return (0);
458 } 473 }
459 break; 474 break;
460 475
747 case WM_WINDOWPOSCHANGED: 762 case WM_WINDOWPOSCHANGED:
748 { 763 {
749 RECT rect; 764 RECT rect;
750 int x, y; 765 int x, y;
751 int w, h; 766 int w, h;
767 Uint32 window_flags;
752 768
753 GetClientRect(hwnd, &rect); 769 GetClientRect(hwnd, &rect);
754 ClientToScreen(hwnd, (LPPOINT) & rect); 770 ClientToScreen(hwnd, (LPPOINT) & rect);
755 ClientToScreen(hwnd, (LPPOINT) & rect + 1); 771 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
756 772
757 if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_INPUT_GRABBED) { 773 window_flags = SDL_GetWindowFlags(data->windowID);
774 if ((window_flags & SDL_WINDOW_INPUT_GRABBED) &&
775 (window_flags & SDL_WINDOW_KEYBOARD_FOCUS)) {
758 ClipCursor(&rect); 776 ClipCursor(&rect);
759 } 777 }
760 778
761 x = rect.left; 779 x = rect.left;
762 y = rect.top; 780 y = rect.top;