From e046d0696b6f2760101cebd35ae20e7cb29646b8 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 9 Nov 2015 23:32:35 +0100 Subject: [PATCH] Add glfwGetGLXWindow --- README.md | 1 + include/GLFW/glfw3native.h | 15 +++++++++++++++ src/glx_context.c | 14 ++++++++++++++ 3 files changed, 30 insertions(+) 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; +} +