diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ff15f0d..efb559c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,18 +288,18 @@ if (_GLFW_X11) endif() # Check for Xf86VidMode (fallback gamma control) - if (NOT X11_xf86vmode_FOUND) - message(FATAL_ERROR "The Xf86VidMode library and headers were not found") - endif() + if (X11_xf86vmode_FOUND) + list(APPEND glfw_INCLUDE_DIRS "${X11_xf86vmode_INCLUDE_PATH}") + list(APPEND glfw_PKG_DEPS "xxf86vm") - list(APPEND glfw_INCLUDE_DIRS "${X11_xf86vmode_INCLUDE_PATH}") - list(APPEND glfw_PKG_DEPS "xxf86vm") + if (X11_Xxf86vm_LIB) + list(APPEND glfw_LIBRARIES "${X11_Xxf86vm_LIB}") + else() + # Backwards compatibility (see CMake bug 0006976) + list(APPEND glfw_LIBRARIES Xxf86vm) + endif() - if (X11_Xxf86vm_LIB) - list(APPEND glfw_LIBRARIES "${X11_Xxf86vm_LIB}") - else() - # Backwards compatibility (see CMake bug 0006976) - list(APPEND glfw_LIBRARIES Xxf86vm) + set(_GLFW_HAS_XF86VM TRUE) endif() # Check for Xkb (X keyboard extension) diff --git a/README.md b/README.md index 9d26bdf6..00e4c5c7 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ GLFW bundles a number of dependencies in the `deps/` directory. - [Cocoa] Bugfix: `glfwSetWindowSize` did not change the video mode for full screen windows - [X11] Made XInput2 optional at compile-time + - [X11] Made Xxf86vm optional at compile-time ## Contact diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index 842fa432..296c96de 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -64,6 +64,8 @@ // Define this to 1 if the XInput X11 extension is available #cmakedefine _GLFW_HAS_XINPUT +// Define this to 1 if the Xxf86vm X11 extension is available +#cmakedefine _GLFW_HAS_XF86VM // Define this to 1 if glXGetProcAddress is available #cmakedefine _GLFW_HAS_GLXGETPROCADDRESS // Define this to 1 if glXGetProcAddressARB is available diff --git a/src/x11_init.c b/src/x11_init.c index aa9c1c2c..dc33bcee 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -479,11 +479,13 @@ static GLboolean initExtensions(void) "_MOTIF_WM_HINTS", False); +#if defined(_GLFW_HAS_XF86VM) // Check for XF86VidMode extension _glfw.x11.vidmode.available = XF86VidModeQueryExtension(_glfw.x11.display, &_glfw.x11.vidmode.eventBase, &_glfw.x11.vidmode.errorBase); +#endif /*_GLFW_HAS_XF86VM*/ // Check for RandR extension _glfw.x11.randr.available = diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 6265070f..cdb1c92a 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -432,6 +432,7 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) XRRFreeGamma(gamma); } +#if defined(_GLFW_HAS_XF86VM) else if (_glfw.x11.vidmode.available) { int size; @@ -443,6 +444,7 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) _glfw.x11.screen, ramp->size, ramp->red, ramp->green, ramp->blue); } +#endif /*_GLFW_HAS_XF86VM*/ } void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) @@ -458,6 +460,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma); XRRFreeGamma(gamma); } +#if defined(_GLFW_HAS_XF86VM) else if (_glfw.x11.vidmode.available) { XF86VidModeSetGammaRamp(_glfw.x11.display, @@ -467,6 +470,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) (unsigned short*) ramp->green, (unsigned short*) ramp->blue); } +#endif /*_GLFW_HAS_XF86VM*/ } diff --git a/src/x11_platform.h b/src/x11_platform.h index d1572ba8..0c6450b3 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -37,9 +37,6 @@ #include #include -// The Xf86VidMode extension provides fallback gamma control -#include - // The XRandR extension provides mode setting and gamma control #include @@ -54,6 +51,11 @@ #include #endif +#if defined(_GLFW_HAS_XF86VM) + // The Xf86VidMode extension provides fallback gamma control + #include +#endif + #include "posix_tls.h" #if defined(_GLFW_GLX) @@ -164,12 +166,6 @@ typedef struct _GLFWlibraryX11 Atom ATOM_PAIR; Atom GLFW_SELECTION; - struct { - GLboolean available; - int eventBase; - int errorBase; - } vidmode; - struct { GLboolean available; int eventBase; @@ -219,6 +215,14 @@ typedef struct _GLFWlibraryX11 } xi; #endif /*_GLFW_HAS_XINPUT*/ +#if defined(_GLFW_HAS_XF86VM) + struct { + GLboolean available; + int eventBase; + int errorBase; + } vidmode; +#endif /*_GLFW_HAS_XF86VM*/ + } _GLFWlibraryX11;