From 16eb97dbc319aa904d901086b375549f98593713 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 13 Jan 2014 20:02:43 +0100 Subject: [PATCH] Added native monitor handle access to native API. --- README.md | 1 + include/GLFW/glfw3native.h | 15 +++++++++++++++ src/cocoa_monitor.m | 12 ++++++++++++ src/win32_monitor.c | 12 ++++++++++++ src/x11_monitor.c | 12 ++++++++++++ 5 files changed, 52 insertions(+) diff --git a/README.md b/README.md index d9fb1c52..abc4ccea 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ The following dependencies are needed by the examples and test programs: ## Changelog +- Added native monitor handle access to native API - [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen recorders to fail diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index d570f587..6bc07722 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -102,6 +102,11 @@ extern "C" { *************************************************************************/ #if defined(GLFW_EXPOSE_NATIVE_WIN32) +/*! @brief Returns the device name of the specified monitor. + * @return The the device name of the specified monitor. + * @ingroup native + */ +GLFWAPI const WCHAR* glfwGetWin32Monitor(GLFWmonitor* monitor); /*! @brief Returns the `HWND` of the specified window. * @return The `HWND` of the specified window. * @ingroup native @@ -118,6 +123,11 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); #endif #if defined(GLFW_EXPOSE_NATIVE_COCOA) +/*! @brief Returns the `CGDirectDisplayID` of the specified monitor. + * @return The the `CGDirectDisplayID` of the specified monitor. + * @ingroup native + */ +GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); /*! @brief Returns the `NSWindow` of the specified window. * @return The `NSWindow` of the specified window. * @ingroup native @@ -139,6 +149,11 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); * @ingroup native */ GLFWAPI Display* glfwGetX11Display(void); +/*! @brief Returns the `RRCrtc` of the specified monitor. + * @return The the `RRCrtc` of the specified monitor. + * @ingroup native + */ +GLFWAPI RRCrtc glfwGetX11Monitor(GLFWmonitor* monitor); /*! @brief Returns the `Window` of the specified window. * @return The `Window` of the specified window. * @ingroup native diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index caddde40..77ff59dc 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -386,3 +386,15 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode) CVDisplayLinkRelease(link); } + +////////////////////////////////////////////////////////////////////////// +////// GLFW native API ////// +////////////////////////////////////////////////////////////////////////// + +GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) +{ + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(0); + return monitor->ns.displayID; +} + diff --git a/src/win32_monitor.c b/src/win32_monitor.c index c7ec314e..fb62cc60 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -282,3 +282,15 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) &mode->blueBits); } + +////////////////////////////////////////////////////////////////////////// +////// GLFW native API ////// +////////////////////////////////////////////////////////////////////////// + +GLFWAPI const WCHAR* glfwGetWin32Monitor(GLFWmonitor* handle) +{ + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return monitor->win32.name; +} + diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 48d47b4a..052b3c09 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -402,3 +402,15 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) &mode->redBits, &mode->greenBits, &mode->blueBits); } + +////////////////////////////////////////////////////////////////////////// +////// GLFW native API ////// +////////////////////////////////////////////////////////////////////////// + +GLFWAPI RRCrtc glfwGetX11Monitor(GLFWmonitor* handle) +{ + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(None); + return monitor->x11.crtc; +} +