From dd02b96c94446a9101aa79665290407b19311d2d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 22 Jan 2014 16:39:34 +0100 Subject: [PATCH] Added flag for non-functional RandR monitor path. --- README.md | 1 + src/x11_monitor.c | 24 ++++++++++++++---------- src/x11_platform.h | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d5916f58..afbe8052 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ The following dependencies are needed by the examples and test programs: - Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files - [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen recorders to fail + - [X11] Bugfix: The case of finding no usable CRTCs was not detected ## Contact diff --git a/src/x11_monitor.c b/src/x11_monitor.c index b5113ca4..97eaf1ab 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -62,7 +62,7 @@ static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id) // void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) { - if (_glfw.x11.randr.available) + if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { int i, j; XRRScreenResources* sr; @@ -136,7 +136,7 @@ void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) // void _glfwRestoreVideoMode(_GLFWmonitor* monitor) { - if (_glfw.x11.randr.available) + if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { XRRScreenResources* sr; XRRCrtcInfo* ci; @@ -170,13 +170,13 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor) _GLFWmonitor** _glfwPlatformGetMonitors(int* count) { + int i, found = 0; _GLFWmonitor** monitors = NULL; *count = 0; if (_glfw.x11.randr.available) { - int i, found = 0; RROutput primary; XRRScreenResources* sr; @@ -245,13 +245,16 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) if (found == 0) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: RandR monitor support seems broken"); + _glfw.x11.randr.monitorBroken = GL_TRUE; + free(monitors); monitors = NULL; } - - *count = found; } - else + + if (!monitors) { monitors = calloc(1, sizeof(_GLFWmonitor*)); monitors[0] = _glfwAllocMonitor("Display", @@ -259,9 +262,10 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) _glfw.x11.screen), DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen)); - *count = 1; + found = 1; } + *count = found; return monitors; } @@ -272,7 +276,7 @@ GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second) void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) { - if (_glfw.x11.randr.available) + if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { XRRScreenResources* sr; XRRCrtcInfo* ci; @@ -309,7 +313,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) // Build array of available resolutions - if (_glfw.x11.randr.available) + if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { int i, j; XRRScreenResources* sr; @@ -375,7 +379,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) { - if (_glfw.x11.randr.available) + if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { XRRScreenResources* sr; XRRCrtcInfo* ci; diff --git a/src/x11_platform.h b/src/x11_platform.h index d798f521..b3ca83fb 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -164,6 +164,7 @@ typedef struct _GLFWlibraryX11 int versionMajor; int versionMinor; GLboolean gammaBroken; + GLboolean monitorBroken; } randr; struct {