1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-22 18:28:52 -05:00

X11: Load Xxf86vm at run-time

This commit is contained in:
Camilla Löwy 2016-12-10 23:41:19 +01:00
parent 21eeaffc23
commit 6eae8f22dc
9 changed files with 34 additions and 47 deletions

View File

@ -140,7 +140,7 @@ include the __GLFW release version__ (e.g. `3.1.2`), otherwise include the
__GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git. __GLFW commit ID__ (e.g. `3795d78b14ef06008889cc422a1fb8d642597751`) from Git.
Please also include the __GLFW version string__ (`3.2.0 X11 EGL clock_gettime Please also include the __GLFW version string__ (`3.2.0 X11 EGL clock_gettime
/dev/js XI Xf86vm`), as described /dev/js`), as described
[here](http://www.glfw.org/docs/latest/intro.html#intro_version_string), the [here](http://www.glfw.org/docs/latest/intro.html#intro_version_string), the
__GPU model and driver version__ (e.g. `GeForce GTX660 with 352.79`), and the __GPU model and driver version__ (e.g. `GeForce GTX660 with 352.79`), and the
__output of `glfwinfo`__ (with switches matching any hints you set in your __output of `glfwinfo`__ (with switches matching any hints you set in your

View File

@ -262,21 +262,6 @@ if (_GLFW_X11)
list(APPEND glfw_LIBRARIES "${X11_Xinerama_LIB}") list(APPEND glfw_LIBRARIES "${X11_Xinerama_LIB}")
list(APPEND glfw_PKG_DEPS "xinerama") list(APPEND glfw_PKG_DEPS "xinerama")
# Check for Xf86VidMode (fallback gamma control)
if (X11_xf86vmode_FOUND)
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()
set(_GLFW_HAS_XF86VM TRUE)
endif()
# Check for Xkb (X keyboard extension) # Check for Xkb (X keyboard extension)
if (NOT X11_Xkb_FOUND) if (NOT X11_Xkb_FOUND)
message(FATAL_ERROR "The X keyboard extension headers were not found") message(FATAL_ERROR "The X keyboard extension headers were not found")

View File

@ -118,6 +118,7 @@ information on what to include when reporting a bug.
- Bugfix: `glfwGetInstanceProcAddress` returned `NULL` for - Bugfix: `glfwGetInstanceProcAddress` returned `NULL` for
`vkGetInstanceProcAddr` when `_GLFW_VULKAN_STATIC` was enabled `vkGetInstanceProcAddr` when `_GLFW_VULKAN_STATIC` was enabled
- [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861) - [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861)
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
- [Cocoa] Added support for Vulkan window surface creation via MoltenVK (#870) - [Cocoa] Added support for Vulkan window surface creation via MoltenVK (#870)
- [Cocoa] Bugfix: Disabling window aspect ratio would assert (#852) - [Cocoa] Bugfix: Disabling window aspect ratio would assert (#852)
- [Cocoa] Bugfix: Window creation failed to set first responder (#876,#883) - [Cocoa] Bugfix: Window creation failed to set first responder (#876,#883)

View File

@ -281,12 +281,6 @@ For the EGL context creation API, the following options are available:
- @b _GLFW_USE_EGLPLATFORM_H to use `EGL/eglplatform.h` for native handle - @b _GLFW_USE_EGLPLATFORM_H to use `EGL/eglplatform.h` for native handle
definitions (fallback) definitions (fallback)
If you are using the X11 window creation API, support for the following X11
extensions can be enabled:
- @b _GLFW_HAS_XF86VM to use Xxf86vm as a fallback when RandR gamma is broken
(recommended)
If you are using the Cocoa window creation API, the following options are If you are using the Cocoa window creation API, the following options are
available: available:

View File

@ -111,6 +111,6 @@ which is generated from the `glfw_config.h.in` file by CMake.
Configuration macros the same style as tokens in the public interface, except Configuration macros the same style as tokens in the public interface, except
with a leading underscore. with a leading underscore.
Examples: `_GLFW_HAS_XF86VM` Examples: `_GLFW_USE_HYBRID_HPG`
*/ */

View File

@ -55,9 +55,6 @@
// Define this to 1 to force use of high-performance GPU on hybrid systems // Define this to 1 to force use of high-performance GPU on hybrid systems
#cmakedefine _GLFW_USE_HYBRID_HPG #cmakedefine _GLFW_USE_HYBRID_HPG
// Define this to 1 if the Xxf86vm X11 extension is available
#cmakedefine _GLFW_HAS_XF86VM
// Define this to 1 if glfwInit should change the current directory // Define this to 1 if glfwInit should change the current directory
#cmakedefine _GLFW_USE_CHDIR #cmakedefine _GLFW_USE_CHDIR
// Define this to 1 if glfwCreateWindow should populate the menu bar // Define this to 1 if glfwCreateWindow should populate the menu bar

View File

@ -462,13 +462,23 @@ static void detectEWMH(void)
// //
static GLFWbool initExtensions(void) static GLFWbool initExtensions(void)
{ {
#if defined(_GLFW_HAS_XF86VM) _glfw.x11.vidmode.handle = dlopen("libXxf86vm.so", RTLD_LAZY | RTLD_GLOBAL);
// Check for XF86VidMode extension if (_glfw.x11.vidmode.handle)
_glfw.x11.vidmode.available = {
XF86VidModeQueryExtension(_glfw.x11.display, _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
&_glfw.x11.vidmode.eventBase, dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
&_glfw.x11.vidmode.errorBase); _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
#endif /*_GLFW_HAS_XF86VM*/ dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
_glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp)
dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
_glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize)
dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
_glfw.x11.vidmode.available =
XF86VidModeQueryExtension(_glfw.x11.display,
&_glfw.x11.vidmode.eventBase,
&_glfw.x11.vidmode.errorBase);
}
// Check for RandR extension // Check for RandR extension
if (XRRQueryExtension(_glfw.x11.display, if (XRRQueryExtension(_glfw.x11.display,
@ -848,9 +858,6 @@ const char* _glfwPlatformGetVersionString(void)
#if defined(__linux__) #if defined(__linux__)
" /dev/js" " /dev/js"
#endif #endif
#if defined(_GLFW_HAS_XF86VM)
" Xf86vm"
#endif
#if defined(_GLFW_BUILD_DLL) #if defined(_GLFW_BUILD_DLL)
" shared" " shared"
#endif #endif

View File

@ -429,7 +429,6 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
XRRFreeGamma(gamma); XRRFreeGamma(gamma);
} }
#if defined(_GLFW_HAS_XF86VM)
else if (_glfw.x11.vidmode.available) else if (_glfw.x11.vidmode.available)
{ {
int size; int size;
@ -441,7 +440,6 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
_glfw.x11.screen, _glfw.x11.screen,
ramp->size, ramp->red, ramp->green, ramp->blue); ramp->size, ramp->red, ramp->green, ramp->blue);
} }
#endif /*_GLFW_HAS_XF86VM*/
} }
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
@ -457,7 +455,6 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma); XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma);
XRRFreeGamma(gamma); XRRFreeGamma(gamma);
} }
#if defined(_GLFW_HAS_XF86VM)
else if (_glfw.x11.vidmode.available) else if (_glfw.x11.vidmode.available)
{ {
XF86VidModeSetGammaRamp(_glfw.x11.display, XF86VidModeSetGammaRamp(_glfw.x11.display,
@ -467,7 +464,6 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
(unsigned short*) ramp->green, (unsigned short*) ramp->green,
(unsigned short*) ramp->blue); (unsigned short*) ramp->blue);
} }
#endif /*_GLFW_HAS_XF86VM*/
} }

View File

@ -47,16 +47,20 @@
// The Xinerama extension provides legacy monitor indices // The Xinerama extension provides legacy monitor indices
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#if defined(_GLFW_HAS_XF86VM)
// The Xf86VidMode extension provides fallback gamma control
#include <X11/extensions/xf86vmode.h>
#endif
typedef XID xcb_window_t; typedef XID xcb_window_t;
typedef XID xcb_visualid_t; typedef XID xcb_visualid_t;
typedef struct xcb_connection_t xcb_connection_t; typedef struct xcb_connection_t xcb_connection_t;
typedef xcb_connection_t* (* PFN_XGetXCBConnection)(Display*); typedef xcb_connection_t* (* PFN_XGetXCBConnection)(Display*);
typedef Bool (* PFN_XF86VidModeQueryExtension)(Display*,int*,int*);
typedef Bool (* PFN_XF86VidModeGetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
typedef Bool (* PFN_XF86VidModeSetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
typedef Bool (* PFN_XF86VidModeGetGammaRampSize)(Display*,int,int*);
#define XF86VidModeQueryExtension _glfw.x11.vidmode.QueryExtension
#define XF86VidModeGetGammaRamp _glfw.x11.vidmode.GetGammaRamp
#define XF86VidModeSetGammaRamp _glfw.x11.vidmode.SetGammaRamp
#define XF86VidModeGetGammaRampSize _glfw.x11.vidmode.GetGammaRampSize
typedef VkFlags VkXlibSurfaceCreateFlagsKHR; typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
typedef VkFlags VkXcbSurfaceCreateFlagsKHR; typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
@ -250,13 +254,16 @@ typedef struct _GLFWlibraryX11
PFN_XGetXCBConnection XGetXCBConnection; PFN_XGetXCBConnection XGetXCBConnection;
} x11xcb; } x11xcb;
#if defined(_GLFW_HAS_XF86VM)
struct { struct {
GLFWbool available; GLFWbool available;
void* handle;
int eventBase; int eventBase;
int errorBase; int errorBase;
PFN_XF86VidModeQueryExtension QueryExtension;
PFN_XF86VidModeGetGammaRamp GetGammaRamp;
PFN_XF86VidModeSetGammaRamp SetGammaRamp;
PFN_XF86VidModeGetGammaRampSize GetGammaRampSize;
} vidmode; } vidmode;
#endif /*_GLFW_HAS_XF86VM*/
} _GLFWlibraryX11; } _GLFWlibraryX11;