From 699c899a49c712165d8aefb1b54322892a6cb3ee Mon Sep 17 00:00:00 2001 From: Antti Tuppurainen Date: Thu, 2 Jan 2014 15:13:25 +0200 Subject: [PATCH] Create default monitor if Xrandr lookup fails Allows glfwInit to succeed on headless systems --- src/x11_gamma.c | 6 +++++- src/x11_monitor.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/x11_gamma.c b/src/x11_gamma.c index 1831263d7..7fbf535ce 100644 --- a/src/x11_gamma.c +++ b/src/x11_gamma.c @@ -51,7 +51,11 @@ void _glfwInitGammaRamp(void) XRRScreenResources* rr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root); - if (XRRGetCrtcGammaSize(_glfw.x11.display, rr->crtcs[0]) == 0) + if (rr->ncrtc == 0) + { + _glfw.x11.randr.gammaBroken = GL_TRUE; + } + else if (XRRGetCrtcGammaSize(_glfw.x11.display, rr->crtcs[0]) == 0) { // This is probably older Nvidia RandR with broken gamma support // Flag it as useless and try Xf86VidMode below, if available diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 48d47b4ae..1cea69816 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -251,7 +251,8 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) *count = found; } - else + + if (monitors == NULL) { monitors = calloc(1, sizeof(_GLFWmonitor*)); monitors[0] = _glfwCreateMonitor("Display",