Made client-side RandR and Xf86VidMode required.

This commit is contained in:
Camilla Berglund 2013-01-12 19:12:55 +01:00
parent 747b6d8805
commit 6a4c175816
8 changed files with 29 additions and 84 deletions

View File

@ -130,18 +130,22 @@ if (_GLFW_X11)
list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH}) list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH})
list(APPEND glfw_LIBRARIES ${X11_X11_LIB}) list(APPEND glfw_LIBRARIES ${X11_X11_LIB})
# Check for XRandR (modern resolution switching extension) # Check for XRandR (modern resolution switching and gamma control)
if (X11_Xrandr_FOUND) if (NOT X11_Xrandr_FOUND)
set(_GLFW_HAS_XRANDR 1) message(FATAL_ERROR "The RandR extension was not found")
endif()
list(APPEND glfw_INCLUDE_DIRS ${X11_Xrandr_INCLUDE_PATH}) list(APPEND glfw_INCLUDE_DIRS ${X11_Xrandr_INCLUDE_PATH})
list(APPEND glfw_LIBRARIES ${X11_Xrandr_LIB}) list(APPEND glfw_LIBRARIES ${X11_Xrandr_LIB})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xrandr") set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xrandr")
# Check for Xf86VidMode (fallback gamma control)
if (NOT X11_xf86vmode_FOUND)
message(FATAL_ERROR "The Xf86VidMode extension was not found")
endif() endif()
# Check for Xf86VidMode (fallback legacy resolution switching extension)
if (X11_xf86vmode_FOUND)
set(_GLFW_HAS_XF86VIDMODE 1)
list(APPEND glfw_INCLUDE_DIRS ${X11_xf86vmode_INCLUDE_PATH}) list(APPEND glfw_INCLUDE_DIRS ${X11_xf86vmode_INCLUDE_PATH})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xxf86vm")
# NOTE: This is a workaround for CMake bug 0006976 (missing # NOTE: This is a workaround for CMake bug 0006976 (missing
# X11_xf86vmode_LIB variable) # X11_xf86vmode_LIB variable)
@ -151,16 +155,13 @@ if (_GLFW_X11)
list(APPEND glfw_LIBRARIES Xxf86vm) list(APPEND glfw_LIBRARIES Xxf86vm)
endif() endif()
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xxf86vm")
endif()
# Check for Xkb (X keyboard extension) # Check for Xkb (X keyboard extension)
if (X11_Xkb_FOUND) if (NOT X11_Xkb_FOUND)
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
else()
message(FATAL_ERROR "The X keyboard extension was not found") message(FATAL_ERROR "The X keyboard extension was not found")
endif() endif()
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
find_library(RT_LIBRARY rt) find_library(RT_LIBRARY rt)
mark_as_advanced(RT_LIBRARY) mark_as_advanced(RT_LIBRARY)
if (RT_LIBRARY) if (RT_LIBRARY)

View File

@ -359,6 +359,7 @@ version of GLFW.</p>
<li>[X11] Added the POSIX <code>CLOCK_MONOTONIC</code> time source as the preferred method</li> <li>[X11] Added the POSIX <code>CLOCK_MONOTONIC</code> time source as the preferred method</li>
<li>[X11] Added dependency on libm, where present</li> <li>[X11] Added dependency on libm, where present</li>
<li>[X11] Added support for the <code>_NET_WM_NAME</code> and <code>_NET_WM_ICON_NAME</code> EWMH window properties</li> <li>[X11] Added support for the <code>_NET_WM_NAME</code> and <code>_NET_WM_ICON_NAME</code> EWMH window properties</li>
<li>[X11] Made client-side RandR and Xf86VidMode extensions required</li>
<li>[X11] Bugfix: Some window properties required by the ICCCM were not set</li> <li>[X11] Bugfix: Some window properties required by the ICCCM were not set</li>
<li>[X11] Bugfix: Calling <code>glXCreateContextAttribsARB</code> with an unavailable OpenGL version caused the application to terminate with a <code>BadMatch</code> Xlib error</li> <li>[X11] Bugfix: Calling <code>glXCreateContextAttribsARB</code> with an unavailable OpenGL version caused the application to terminate with a <code>BadMatch</code> Xlib error</li>
<li>[X11] Bugfix: A synchronization point necessary for jitter-free locked cursor mode was incorrectly removed</li> <li>[X11] Bugfix: A synchronization point necessary for jitter-free locked cursor mode was incorrectly removed</li>

View File

@ -57,11 +57,6 @@
// Define this to 1 to disable dynamic loading of winmm // Define this to 1 to disable dynamic loading of winmm
#cmakedefine _GLFW_NO_DLOAD_WINMM #cmakedefine _GLFW_NO_DLOAD_WINMM
// Define this to 1 if XRandR is available
#cmakedefine _GLFW_HAS_XRANDR
// Define this to 1 if Xf86VidMode is available
#cmakedefine _GLFW_HAS_XF86VIDMODE
// Define this to 1 if glXGetProcAddress is available // Define this to 1 if glXGetProcAddress is available
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS #cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
// Define this to 1 if glXGetProcAddressARB is available // Define this to 1 if glXGetProcAddressARB is available

View File

@ -43,7 +43,6 @@
void _glfwInitGammaRamp(void) void _glfwInitGammaRamp(void)
{ {
#ifdef _GLFW_HAS_XRANDR
// RandR gamma support is only available with version 1.2 and above // RandR gamma support is only available with version 1.2 and above
if (_glfw.x11.randr.available && if (_glfw.x11.randr.available &&
(_glfw.x11.randr.versionMajor > 1 || (_glfw.x11.randr.versionMajor > 1 ||
@ -68,9 +67,7 @@ void _glfwInitGammaRamp(void)
XRRFreeScreenResources(rr); XRRFreeScreenResources(rr);
} }
#endif /*_GLFW_HAS_XRANDR*/
#if defined(_GLFW_HAS_XF86VIDMODE)
if (_glfw.x11.vidmode.available && !_glfw.originalRampSize) if (_glfw.x11.vidmode.available && !_glfw.originalRampSize)
{ {
// Get the gamma size using XF86VidMode // Get the gamma size using XF86VidMode
@ -78,7 +75,6 @@ void _glfwInitGammaRamp(void)
_glfw.x11.screen, _glfw.x11.screen,
&_glfw.originalRampSize); &_glfw.originalRampSize);
} }
#endif /*_GLFW_HAS_XF86VIDMODE*/
if (_glfw.originalRampSize) if (_glfw.originalRampSize)
{ {
@ -121,7 +117,6 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
{ {
#if defined (_GLFW_HAS_XRANDR)
size_t size = GLFW_GAMMA_RAMP_SIZE * sizeof(unsigned short); size_t size = GLFW_GAMMA_RAMP_SIZE * sizeof(unsigned short);
XRRScreenResources* rr = XRRGetScreenResources(_glfw.x11.display, XRRScreenResources* rr = XRRGetScreenResources(_glfw.x11.display,
@ -138,18 +133,15 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
XRRFreeGamma(gamma); XRRFreeGamma(gamma);
XRRFreeScreenResources(rr); XRRFreeScreenResources(rr);
#endif /*_GLFW_HAS_XRANDR*/
} }
else if (_glfw.x11.vidmode.available) else if (_glfw.x11.vidmode.available)
{ {
#if defined (_GLFW_HAS_XF86VIDMODE)
XF86VidModeGetGammaRamp(_glfw.x11.display, XF86VidModeGetGammaRamp(_glfw.x11.display,
_glfw.x11.screen, _glfw.x11.screen,
GLFW_GAMMA_RAMP_SIZE, GLFW_GAMMA_RAMP_SIZE,
ramp->red, ramp->red,
ramp->green, ramp->green,
ramp->blue); ramp->blue);
#endif /*_GLFW_HAS_XF86VIDMODE*/
} }
} }
@ -171,7 +163,6 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
{ {
#if defined (_GLFW_HAS_XRANDR)
int i; int i;
size_t size = GLFW_GAMMA_RAMP_SIZE * sizeof(unsigned short); size_t size = GLFW_GAMMA_RAMP_SIZE * sizeof(unsigned short);
@ -192,18 +183,15 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
} }
XRRFreeScreenResources(rr); XRRFreeScreenResources(rr);
#endif /*_GLFW_HAS_XRANDR*/
} }
else if (_glfw.x11.vidmode.available) else if (_glfw.x11.vidmode.available)
{ {
#if defined (_GLFW_HAS_XF86VIDMODE)
XF86VidModeSetGammaRamp(_glfw.x11.display, XF86VidModeSetGammaRamp(_glfw.x11.display,
_glfw.x11.screen, _glfw.x11.screen,
GLFW_GAMMA_RAMP_SIZE, GLFW_GAMMA_RAMP_SIZE,
(unsigned short*) ramp->red, (unsigned short*) ramp->red,
(unsigned short*) ramp->green, (unsigned short*) ramp->green,
(unsigned short*) ramp->blue); (unsigned short*) ramp->blue);
#endif /*_GLFW_HAS_XF86VIDMODE*/
} }
} }

View File

@ -483,17 +483,12 @@ static GLboolean initDisplay(void)
_glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen); _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
// Check for XF86VidMode extension // Check for XF86VidMode extension
#ifdef _GLFW_HAS_XF86VIDMODE
_glfw.x11.vidmode.available = _glfw.x11.vidmode.available =
XF86VidModeQueryExtension(_glfw.x11.display, XF86VidModeQueryExtension(_glfw.x11.display,
&_glfw.x11.vidmode.eventBase, &_glfw.x11.vidmode.eventBase,
&_glfw.x11.vidmode.errorBase); &_glfw.x11.vidmode.errorBase);
#else
_glfw.x11.vidmode.available = GL_FALSE;
#endif /*_GLFW_HAS_XF86VIDMODE*/
// Check for RandR extension // Check for RandR extension
#ifdef _GLFW_HAS_XRANDR
_glfw.x11.randr.available = _glfw.x11.randr.available =
XRRQueryExtension(_glfw.x11.display, XRRQueryExtension(_glfw.x11.display,
&_glfw.x11.randr.eventBase, &_glfw.x11.randr.eventBase,
@ -517,9 +512,6 @@ static GLboolean initDisplay(void)
_glfw.x11.randr.available = GL_FALSE; _glfw.x11.randr.available = GL_FALSE;
} }
} }
#else
_glfw.x11.randr.available = GL_FALSE;
#endif /*_GLFW_HAS_XRANDR*/
// Check if Xkb is supported on this display // Check if Xkb is supported on this display
_glfw.x11.xkb.versionMajor = 1; _glfw.x11.xkb.versionMajor = 1;
@ -681,15 +673,6 @@ const char* _glfwPlatformGetVersionString(void)
#elif defined(_GLFW_EGL) #elif defined(_GLFW_EGL)
" EGL" " EGL"
#endif #endif
#if defined(_GLFW_HAS_XRANDR)
" XRandR"
#endif
#if defined(_GLFW_HAS_XF86VIDMODE)
" Xf86VidMode"
#endif
#if !defined(_GLFW_HAS_XRANDR) && !defined(_GLFW_HAS_XF86VIDMODE)
" no-mode-switching-support"
#endif
#if defined(_GLFW_HAS_GLXGETPROCADDRESS) #if defined(_GLFW_HAS_GLXGETPROCADDRESS)
" glXGetProcAddress" " glXGetProcAddress"
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB) #elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB)

View File

@ -49,7 +49,6 @@ int _glfwGetClosestVideoMode(_GLFWmonitor* monitor, int* width, int* height)
if (_glfw.x11.randr.available) if (_glfw.x11.randr.available)
{ {
#if defined(_GLFW_HAS_XRANDR)
int sizecount, bestsize; int sizecount, bestsize;
XRRScreenConfiguration* sc; XRRScreenConfiguration* sc;
XRRScreenSize* sizelist; XRRScreenSize* sizelist;
@ -85,7 +84,6 @@ int _glfwGetClosestVideoMode(_GLFWmonitor* monitor, int* width, int* height)
if (bestsize != -1) if (bestsize != -1)
return bestsize; return bestsize;
#endif /*_GLFW_HAS_XRANDR*/
} }
// Default: Simply use the screen resolution // Default: Simply use the screen resolution
@ -104,7 +102,6 @@ void _glfwSetVideoModeMODE(_GLFWmonitor* monitor, int mode)
{ {
if (_glfw.x11.randr.available) if (_glfw.x11.randr.available)
{ {
#if defined(_GLFW_HAS_XRANDR)
XRRScreenConfiguration* sc; XRRScreenConfiguration* sc;
Window root; Window root;
@ -131,7 +128,6 @@ void _glfwSetVideoModeMODE(_GLFWmonitor* monitor, int mode)
CurrentTime); CurrentTime);
XRRFreeScreenConfigInfo(sc); XRRFreeScreenConfigInfo(sc);
#endif /*_GLFW_HAS_XRANDR*/
} }
} }
@ -163,7 +159,6 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
if (_glfw.x11.randr.available) if (_glfw.x11.randr.available)
{ {
#if defined(_GLFW_HAS_XRANDR)
XRRScreenConfiguration* sc; XRRScreenConfiguration* sc;
sc = XRRGetScreenInfo(_glfw.x11.display, _glfw.x11.root); sc = XRRGetScreenInfo(_glfw.x11.display, _glfw.x11.root);
@ -176,7 +171,6 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
CurrentTime); CurrentTime);
XRRFreeScreenConfigInfo(sc); XRRFreeScreenConfigInfo(sc);
#endif /*_GLFW_HAS_XRANDR*/
} }
monitor->x11.modeChanged = GL_FALSE; monitor->x11.modeChanged = GL_FALSE;
@ -200,7 +194,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
if (_glfw.x11.randr.available) if (_glfw.x11.randr.available)
{ {
#if defined (_GLFW_HAS_XRANDR)
int i; int i;
RROutput primary; RROutput primary;
XRRScreenResources* sr; XRRScreenResources* sr;
@ -249,7 +242,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
monitors[*found]->x11.output = oi; monitors[*found]->x11.output = oi;
(*found)++; (*found)++;
} }
#endif /*_GLFW_HAS_XRANDR*/
} }
else else
{ {
@ -284,11 +276,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
void _glfwPlatformDestroyMonitor(_GLFWmonitor* monitor) void _glfwPlatformDestroyMonitor(_GLFWmonitor* monitor)
{ {
if (_glfw.x11.randr.available) if (_glfw.x11.randr.available)
{
#if defined (_GLFW_HAS_XRANDR)
XRRFreeOutputInfo(monitor->x11.output); XRRFreeOutputInfo(monitor->x11.output);
#endif /*_GLFW_HAS_XRANDR*/
}
} }
@ -310,7 +298,6 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
if (_glfw.x11.randr.available) if (_glfw.x11.randr.available)
{ {
#if defined(_GLFW_HAS_XRANDR)
XRRScreenResources* sr; XRRScreenResources* sr;
int i, j, count = monitor->x11.output->nmode; int i, j, count = monitor->x11.output->nmode;
@ -363,7 +350,6 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
} }
XRRFreeScreenResources(sr); XRRFreeScreenResources(sr);
#endif /*_GLFW_HAS_XRANDR*/
} }
else else
{ {
@ -395,7 +381,6 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
if (_glfw.x11.randr.available) if (_glfw.x11.randr.available)
{ {
#if defined (_GLFW_HAS_XRANDR)
XRRScreenResources* sr; XRRScreenResources* sr;
XRRCrtcInfo* ci; XRRCrtcInfo* ci;
@ -422,7 +407,6 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
XRRFreeCrtcInfo(ci); XRRFreeCrtcInfo(ci);
XRRFreeScreenResources(sr); XRRFreeScreenResources(sr);
#endif /*_GLFW_HAS_XRANDR*/
} }
else else
{ {

View File

@ -38,15 +38,11 @@
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
// With XFree86, we can use the XF86VidMode extension // The Xf86VidMode extension provides fallback gamma control
#if defined(_GLFW_HAS_XF86VIDMODE) #include <X11/extensions/xf86vmode.h>
#include <X11/extensions/xf86vmode.h>
#endif
// The XRandR extension provides mode setting and gamma control // The XRandR extension provides mode setting and gamma control
#if defined(_GLFW_HAS_XRANDR) #include <X11/extensions/Xrandr.h>
#include <X11/extensions/Xrandr.h>
#endif
// The Xkb extension provides improved keyboard support // The Xkb extension provides improved keyboard support
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
@ -207,13 +203,11 @@ typedef struct _GLFWmonitorX11
{ {
GLboolean modeChanged; GLboolean modeChanged;
#if defined(_GLFW_HAS_XRANDR)
XRROutputInfo* output; XRROutputInfo* output;
SizeID oldSizeID; SizeID oldSizeID;
int oldWidth; int oldWidth;
int oldHeight; int oldHeight;
Rotation oldRotation; Rotation oldRotation;
#endif /*_GLFW_HAS_XRANDR*/
} _GLFWmonitorX11; } _GLFWmonitorX11;

View File

@ -816,7 +816,6 @@ static void processEvent(XEvent *event)
default: default:
{ {
#if defined(_GLFW_HAS_XRANDR)
switch (event->type - _glfw.x11.randr.eventBase) switch (event->type - _glfw.x11.randr.eventBase)
{ {
case RRScreenChangeNotify: case RRScreenChangeNotify:
@ -826,7 +825,7 @@ static void processEvent(XEvent *event)
break; break;
} }
} }
#endif /*_GLFW_HAS_XRANDR*/
break; break;
} }
} }