diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index b3ce7482d..70f5a9cae 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -86,6 +86,8 @@ extern "C" { #elif defined(GLFW_EXPOSE_NATIVE_X11) #include #include +#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND) + #include #else #error "No window API selected" #endif @@ -301,6 +303,23 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window); GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); #endif +#if defined(GLFW_EXPOSE_NATIVE_WAYLAND) +/*! @brief Returns the `struct wl_surface*` of the specified window. + * + * @return The `struct wl_surface*` of the specified window, or `NULL` 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 struct wl_surface* glfwGetWaylandSurface(GLFWwindow* window); +#endif + #if defined(GLFW_EXPOSE_NATIVE_EGL) /*! @brief Returns the `EGLDisplay` used by GLFW. * diff --git a/src/wl_window.c b/src/wl_window.c index 1d292767b..472e3fde6 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -529,3 +529,15 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) return NULL; } + +////////////////////////////////////////////////////////////////////////// +////// GLFW native API ////// +////////////////////////////////////////////////////////////////////////// + +GLFWAPI struct wl_surface* glfwGetWaylandSurface(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return window->wl.surface; +} +