Browse Source

Keep track of mouse cursor show/hide on OSX as it stacks like on Windows.

Lasse Öörni 14 years ago
parent
commit
80a2fe0f30
2 changed files with 22 additions and 8 deletions
  1. 11 6
      Engine/Input/Input.cpp
  2. 11 2
      ThirdParty/GLFW/src/cocoa_window.m

+ 11 - 6
Engine/Input/Input.cpp

@@ -147,16 +147,21 @@ void Input::Update()
     glfwPollEvents();
     
     // In fullscreen mode or after a screen mode change, activate input automatically
-    if ((graphics_->GetFullscreen() && !active_) || screenModeSet_ && glfwGetWindowParam(graphics_->GetWindowHandle(),
-        GLFW_ACTIVE))
+    if (glfwGetWindowParam(graphics_->GetWindowHandle(), GLFW_ACTIVE))
     {
-        activated_ = true;
-        screenModeSet_ = false;
+        if (screenModeSet_ || (!active_ && graphics_->GetFullscreen()))
+        {
+            activated_ = true;
+            screenModeSet_ = false;
+        }
     }
     
     // Check for input inactivation
-    if (active_ && !glfwGetWindowParam(graphics_->GetWindowHandle(), GLFW_ACTIVE))
-        MakeInactive();
+    if (!glfwGetWindowParam(graphics_->GetWindowHandle(), GLFW_ACTIVE))
+    {
+        if (active_)
+            MakeInactive();
+    }
     #endif
     
     // Activate input now if necessary

+ 11 - 2
ThirdParty/GLFW/src/cocoa_window.m

@@ -34,6 +34,7 @@
 // Needed for _NSGetProgname
 #include <crt_externs.h>
 
+static GLboolean mouseCursorVisible = GL_TRUE;
 
 //========================================================================
 // Delegate for window related notifications
@@ -1182,13 +1183,21 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
     switch (mode)
     {
         case GLFW_CURSOR_NORMAL:
-            [NSCursor unhide];
+            if (!mouseCursorVisible)
+            {
+                [NSCursor unhide];
+                mouseCursorVisible = GL_TRUE;
+            }
             CGAssociateMouseAndMouseCursorPosition(true);
             break;
         case GLFW_CURSOR_HIDDEN:
             break;
         case GLFW_CURSOR_CAPTURED:
-            [NSCursor hide];
+            if (mouseCursorVisible)
+            {
+                [NSCursor hide];
+                mouseCursorVisible = GL_FALSE;
+            }
             CGAssociateMouseAndMouseCursorPosition(false);
             break;
     }