glfw/glfw — pull request #103 by shurcooL (2013-07-25 06:36:31+00:00)
Title: Support for getting cursor position after window creation and setting window position, before mouse moves.

Currently, at least on OS X, if the user creates a window and calls `glfwGetCursorPos()` before moving the mouse, the return value will be (0, 0). After moving the mouse even just by 1 pixel, the return value will be an accurate cursor position.

There's no technical reason why the cursor position cannot be reported accurately even before the mouse is moved.

I'm attaching some code for OS X, but it's just to get the ball rolling on this issue (i.e. it's fine if the issue is solved without merging this PR).

The code added to `createWindow()` fixes that use case.

The code added to `_glfwPlatformSetWindowPos()` is to take care of the use case where the user creates a window, then sets its position to somewhere else, and then calls `glfwGetCursorPos()`.

A related but somewhat distinct issue. When the user moves the window programmatically via `glfwSetWindowPos()`, the cursor position callback (if set) should be called with the new cursor position. Since the cursor position is reported relative to the window position, it will have changed. The code below does not implement this because I didn't know how to do it. Calling the callback directly from `_glfwPlatformSetWindowPos()` is not an option because then it breaks the fact that callbacks occur only immediately after a call to `glfwPollEvents()` or similar.