From 6fc6c93223f22f3426699cb982b8fe11cefac483 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 22 Oct 2012 00:05:55 +0200 Subject: [PATCH] Implemented RandR monitor mode retrieval. --- src/x11_monitor.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 860fe1ea..9426fa02 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -612,13 +612,49 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) { + if (_glfwLibrary.X11.RandR.available) + { +#if defined (_GLFW_HAS_XRANDR) + XRRScreenResources* sr; + XRRCrtcInfo* ci; + + sr = XRRGetScreenResources(_glfwLibrary.X11.display, + _glfwLibrary.X11.root); + if (!sr) + { + _glfwSetError(GLFW_PLATFORM_ERROR, + "X11: Failed to retrieve RandR screen resources"); + return; + } + + ci = XRRGetCrtcInfo(_glfwLibrary.X11.display, + sr, monitor->X11.output->crtc); + if (!ci) + { + XRRFreeScreenResources(sr); + + _glfwSetError(GLFW_PLATFORM_ERROR, + "X11: Failed to retrieve RandR crtc info"); + return; + } + + mode->width = ci->width; + mode->height = ci->height; + + XRRFreeCrtcInfo(ci); + XRRFreeScreenResources(sr); +#endif /*_GLFW_HAS_XRANDR*/ + } + else + { + mode->width = DisplayWidth(_glfwLibrary.X11.display, + _glfwLibrary.X11.screen); + mode->height = DisplayHeight(_glfwLibrary.X11.display, + _glfwLibrary.X11.screen); + } + _glfwSplitBPP(DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen), &mode->redBits, &mode->greenBits, &mode->blueBits); - - mode->width = DisplayWidth(_glfwLibrary.X11.display, - _glfwLibrary.X11.screen); - mode->height = DisplayHeight(_glfwLibrary.X11.display, - _glfwLibrary.X11.screen); }