diff --git a/README.md b/README.md index e71125c9..9bc4bbbb 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Windows created after the first were not cascaded (#195) - [EGL] Added support for `EGL_KHR_get_all_proc_addresses` (#871) - [EGL] Bugfix: The test for `EGL_RGB_BUFFER` was invalid +- Added 'GLFW_CENTER_CURSOR' window hint for controlling cursor centering ## Contact @@ -307,6 +308,7 @@ skills. - Santi Zupancic - Jonas Ådahl - Lasse Öörni + - Liam Middlebrook - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/docs/window.dox b/docs/window.dox index b4d5d2b8..0ef338fa 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -428,6 +428,7 @@ GLFW_FOCUSED | `GLFW_TRUE` | `GLFW_TRUE` or `GL GLFW_AUTO_ICONIFY | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_FLOATING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_MAXIMIZED | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` +GLFW_CENTER_CURSOR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_RED_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` GLFW_GREEN_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` GLFW_BLUE_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` @@ -1041,6 +1042,10 @@ __GLFW_MAXIMIZED__ indicates whether the specified window is maximized. See __GLFW_VISIBLE__ indicates whether the specified window is visible. See @ref window_hide for details. +`GLFW_CENTER_CURSOR` indicates whether the cursor should be moved to the center +of the full screen window during creation. This is ignored for windowed mode +windows. + @anchor GLFW_RESIZABLE_attrib __GLFW_RESIZABLE__ indicates whether the specified window is resizable _by the user_. This can be set before creation with the diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index ca5fa37e..33e4b7dd 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -686,6 +686,7 @@ extern "C" { * [window attribute](@ref GLFW_MAXIMIZED_attrib). */ #define GLFW_MAXIMIZED 0x00020008 +#define GLFW_CENTER_CURSOR 0x00020009 /*! @brief Framebuffer bit depth hint. * diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 62697333..added97e 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1096,7 +1096,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!acquireMonitor(window)) return GLFW_FALSE; - centerCursor(window); + if (wndconfig->centerCursor) + centerCursor(window); } return GLFW_TRUE; diff --git a/src/internal.h b/src/internal.h index f231df71..e1bab46b 100644 --- a/src/internal.h +++ b/src/internal.h @@ -277,6 +277,7 @@ struct _GLFWwndconfig GLFWbool autoIconify; GLFWbool floating; GLFWbool maximized; + GLFWbool centerCursor; struct { GLFWbool retina; GLFWbool frame; diff --git a/src/win32_window.c b/src/win32_window.c index 5c357102..81fde042 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1037,7 +1037,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!acquireMonitor(window)) return GLFW_FALSE; - centerCursor(window); + if (wndconfig->centerCursor) + { + centerCursor(window); + } } return GLFW_TRUE; diff --git a/src/window.c b/src/window.c index 9fdc308f..fba786d3 100644 --- a/src/window.c +++ b/src/window.c @@ -345,6 +345,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_FRAME_AUTOSAVE: _glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE; break; + case GLFW_CENTER_CURSOR: + _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE; + break; case GLFW_CLIENT_API: _glfw.hints.context.client = value; break; diff --git a/src/x11_window.c b/src/x11_window.c index 66fc8919..1f4716ff 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1597,7 +1597,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!acquireMonitor(window)) return GLFW_FALSE; - centerCursor(window); + if(wndconfig->centerCursor) + { + centerCursor(window); + } } XFlush(_glfw.x11.display);