From f3b65445dccf884c56b59668e2cc3516da983e9b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 18 Jun 2014 17:10:26 +0200 Subject: [PATCH] Fixed cursor outside new full screen windows. The cursor was not positioned over newly created full screen windows, leading to confusing behavior like invisible cursor or window iconification. This fix is a stop-gap until the direct cursor position work is merged. Fixes #111. --- README.md | 1 + src/window.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d02b96fb..3f5cc1f1 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ GLFW bundles a number of dependencies in the `deps/` directory. - Bugfix: The debug context attribute was set from `GL_ARB_debug_output` even when a debug context had not been requested - Bugfix: The particles example was not linked against the threading library + - Bugfix: The cursor was not positioned over newly created full screen windows - [Cocoa] Added `_GLFW_USE_RETINA` to control whether windows will use the full resolution on Retina displays - [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen diff --git a/src/window.c b/src/window.c index 717dfb0e..448cf362 100644 --- a/src/window.c +++ b/src/window.c @@ -246,8 +246,21 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, // Restore the previously current context (or NULL) _glfwPlatformMakeContextCurrent(previous); - if (wndconfig.monitor == NULL && wndconfig.visible) - _glfwPlatformShowWindow(window); + if (wndconfig.monitor) + { + int width, height; + _glfwPlatformGetWindowSize(window, &width, &height); + + window->cursorPosX = width / 2; + window->cursorPosY = height / 2; + + _glfwPlatformSetCursorPos(window, window->cursorPosX, window->cursorPosY); + } + else + { + if (wndconfig.visible) + _glfwPlatformShowWindow(window); + } return (GLFWwindow*) window; }