소스 검색

Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks, Eric!).

Fixes Bugzilla #2718.
Ryan C. Gordon 10 년 전
부모
커밋
80916e01f3
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      src/video/cocoa/SDL_cocoawindow.m

+ 5 - 3
src/video/cocoa/SDL_cocoawindow.m

@@ -531,13 +531,15 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
 {
     SDL_Window *window = _data->window;
     SDL_Mouse *mouse = SDL_GetMouse();
-    if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) {
-        mouse->SetRelativeMouseMode(SDL_TRUE);
-    }
 
     /* We're going to get keyboard events, since we're key. */
+    /* This needs to be done before restoring the relative mouse mode. */
     SDL_SetKeyboardFocus(window);
 
+    if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) {
+        mouse->SetRelativeMouseMode(SDL_TRUE);
+    }
+
     /* If we just gained focus we need the updated mouse position */
     if (!mouse->relative_mode) {
         NSPoint point;