diff --git a/README.md b/README.md index 9bc4bbbb..743ffcaf 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ information on what to include when reporting a bug. - Added `glfwSetWindowAttrib` function for changing window attributes (#537) - Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#281,#850) - Added definition of `GLAPIENTRY` to public header +- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering + (#749,#842) - Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint - Added macOS specific `GLFW_COCOA_FRAME_AUTOSAVE` window hint (#195) - Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header @@ -159,7 +161,6 @@ 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 @@ -247,6 +248,7 @@ skills. - Bryce Mehring - Jonathan Mercier - Marcel Metz + - Liam Middlebrook - Jonathan Miller - Kenneth Miller - Bruce Mitchener @@ -308,7 +310,6 @@ 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/news.dox b/docs/news.dox index b262ffee..911c2954 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -25,6 +25,13 @@ GLFW now supports changing the [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), windows with @ref glfwSetWindowAttrib. +@subsection news_33_centercursor Cursor centering window hint + +GLFW now supports controlling whether the cursor is centered over newly created +full screen windows with the [GLFW_CENTER_CURSOR](@ref GLFW_CENTER_CURSOR_hint) +window hint. + + @subsection news_33_moltenvk Support for Vulkan on macOS via MoltenVK GLFW now supports the `VK_MVK_macos_surface` window surface creation extension diff --git a/docs/window.dox b/docs/window.dox index 0ef338fa..544ecd79 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -212,6 +212,11 @@ full screen windows. This hint is ignored for full screen windows. __GLFW_MAXIMIZED__ specifies whether the windowed mode window will be maximized when created. This hint is ignored for full screen windows. +@anchor GLFW_CENTER_CURSOR_hint +__GLFW_CENTER_CURSOR__ specifies whether the cursor should be centered over +newly created full screen windows. This hint is ignored for windowed mode +windows. + @subsubsection window_hints_fb Framebuffer related hints @@ -1042,10 +1047,6 @@ __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 33e4b7dd..1fcd476c 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -686,6 +686,10 @@ extern "C" { * [window attribute](@ref GLFW_MAXIMIZED_attrib). */ #define GLFW_MAXIMIZED 0x00020008 +/*! @brief Cursor centering window hint + * + * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint). + */ #define GLFW_CENTER_CURSOR 0x00020009 /*! @brief Framebuffer bit depth hint. diff --git a/src/cocoa_window.m b/src/cocoa_window.m index added97e..bd803c02 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1096,7 +1096,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!acquireMonitor(window)) return GLFW_FALSE; - if (wndconfig->centerCursor) + if (wndconfig->centerCursor) centerCursor(window); } diff --git a/src/win32_window.c b/src/win32_window.c index 81fde042..c82a3d31 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1038,9 +1038,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, return GLFW_FALSE; if (wndconfig->centerCursor) - { centerCursor(window); - } } return GLFW_TRUE; diff --git a/src/window.c b/src/window.c index fba786d3..3662a4e6 100644 --- a/src/window.c +++ b/src/window.c @@ -345,9 +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_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 1f4716ff..3eff19d3 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1597,10 +1597,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!acquireMonitor(window)) return GLFW_FALSE; - if(wndconfig->centerCursor) - { + if (wndconfig->centerCursor) centerCursor(window); - } } XFlush(_glfw.x11.display);