Browse Source

Added flag for non-functional RandR monitor path.

Camilla Berglund 11 years ago
parent
commit
dd02b96c94
3 changed files with 16 additions and 10 deletions
  1. 1 0
      README.md
  2. 14 10
      src/x11_monitor.c
  3. 1 0
      src/x11_platform.h

+ 1 - 0
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

+ 14 - 10
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;

+ 1 - 0
src/x11_platform.h

@@ -164,6 +164,7 @@ typedef struct _GLFWlibraryX11
         int         versionMajor;
         int         versionMinor;
         GLboolean   gammaBroken;
+        GLboolean   monitorBroken;
     } randr;
 
     struct {