diff 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
line wrap: on
line diff
--- a/src/video/win32/SDL_win32events.c	Sat Jul 08 20:07:08 2006 +0000
+++ b/src/video/win32/SDL_win32events.c	Sat Jul 08 20:55:39 2006 +0000
@@ -441,18 +441,33 @@
                 }
                 if (keyboard && keyboard->focus != data->windowID) {
                     SDL_SetKeyboardFocus(index, data->windowID);
+
+                    if (SDL_GetWindowFlags(data->windowID) &
+                        SDL_WINDOW_INPUT_GRABBED) {
+                        RECT rect;
+
+                        GetClientRect(hwnd, &rect);
+                        ClientToScreen(hwnd, (LPPOINT) & rect);
+                        ClientToScreen(hwnd, (LPPOINT) & rect + 1);
+                        ClipCursor(&rect);
+                    }
                 }
-                /* FIXME: Restore mode state (mode, gamma, grab) */
+                /* FIXME: Restore mode state (mode, gamma) */
                 /* FIXME: Update keyboard state */
             } else {
                 if (keyboard && keyboard->focus == data->windowID) {
                     SDL_SetKeyboardFocus(index, 0);
+
+                    if (SDL_GetWindowFlags(data->windowID) &
+                        SDL_WINDOW_INPUT_GRABBED) {
+                        ClipCursor(NULL);
+                    }
                 }
                 if (minimized) {
                     SDL_SendWindowEvent(data->windowID,
                                         SDL_WINDOWEVENT_MINIMIZED, 0, 0);
                 }
-                /* FIXME: Restore desktop state (mode, gamma, grab) */
+                /* FIXME: Restore desktop state (mode, gamma) */
             }
             return (0);
         }
@@ -749,12 +764,15 @@
             RECT rect;
             int x, y;
             int w, h;
+            Uint32 window_flags;
 
             GetClientRect(hwnd, &rect);
             ClientToScreen(hwnd, (LPPOINT) & rect);
             ClientToScreen(hwnd, (LPPOINT) & rect + 1);
 
-            if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_INPUT_GRABBED) {
+            window_flags = SDL_GetWindowFlags(data->windowID);
+            if ((window_flags & SDL_WINDOW_INPUT_GRABBED) &&
+                (window_flags & SDL_WINDOW_KEYBOARD_FOCUS)) {
                 ClipCursor(&rect);
             }