diff --git a/README.md b/README.md index ebcd4865..cfeca311 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ used by the tests and examples and are not required to build the library. - Added `GLFW_NO_API` for creating window without contexts - Added `GLFW_CONTEXT_NO_ERROR` context hint for `GL_KHR_no_error` support - Added `GLFW_TRUE` and `GLFW_FALSE` as client API independent boolean values + - Added `glfwGetGLXWindow` to query the `GLXWindow` of a window - Removed dependency on external OpenGL or OpenGL ES headers - [Win32] Added support for Windows 8.1 per-monitor DPI - [Cocoa] Removed support for OS X 10.6 diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 799effaa..906699b1 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -314,6 +314,21 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window); * @ingroup native */ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); + +/*! @brief Returns the `GLXWindow` of the specified window. + * + * @return The `GLXWindow` of the specified window, or `None` if an + * [error](@ref error_handling) occurred. + * + * @par Thread Safety + * This function may be called from any thread. Access is not synchronized. + * + * @par History + * Added in GLFW 3.2. + * + * @ingroup native + */ +GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); #endif #if defined(GLFW_EXPOSE_NATIVE_WAYLAND) diff --git a/src/glx_context.c b/src/glx_context.c index 79753118..1539fbb5 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -616,3 +616,17 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) return window->context.glx.handle; } +GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(None); + + if (window->context.api == GLFW_NO_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return None; + } + + return window->context.glx.window; +} +