mirror of
https://github.com/glfw/glfw.git
synced 2026-09-19 23:43:15 +00:00
X11: Load Xxf86vm at run-time
This commit is contained in:
@@ -55,9 +55,6 @@
|
||||
// Define this to 1 to force use of high-performance GPU on hybrid systems
|
||||
#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
|
||||
#cmakedefine _GLFW_USE_CHDIR
|
||||
// Define this to 1 if glfwCreateWindow should populate the menu bar
|
||||
|
||||
+17
-10
@@ -462,13 +462,23 @@ static void detectEWMH(void)
|
||||
//
|
||||
static GLFWbool initExtensions(void)
|
||||
{
|
||||
#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*/
|
||||
_glfw.x11.vidmode.handle = dlopen("libXxf86vm.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (_glfw.x11.vidmode.handle)
|
||||
{
|
||||
_glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
|
||||
dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
|
||||
_glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
|
||||
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
|
||||
if (XRRQueryExtension(_glfw.x11.display,
|
||||
@@ -848,9 +858,6 @@ const char* _glfwPlatformGetVersionString(void)
|
||||
#if defined(__linux__)
|
||||
" /dev/js"
|
||||
#endif
|
||||
#if defined(_GLFW_HAS_XF86VM)
|
||||
" Xf86vm"
|
||||
#endif
|
||||
#if defined(_GLFW_BUILD_DLL)
|
||||
" shared"
|
||||
#endif
|
||||
|
||||
@@ -429,7 +429,6 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
|
||||
XRRFreeGamma(gamma);
|
||||
}
|
||||
#if defined(_GLFW_HAS_XF86VM)
|
||||
else if (_glfw.x11.vidmode.available)
|
||||
{
|
||||
int size;
|
||||
@@ -441,7 +440,6 @@ 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)
|
||||
@@ -457,7 +455,6 @@ 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,7 +464,6 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
(unsigned short*) ramp->green,
|
||||
(unsigned short*) ramp->blue);
|
||||
}
|
||||
#endif /*_GLFW_HAS_XF86VM*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-7
@@ -47,16 +47,20 @@
|
||||
// The Xinerama extension provides legacy monitor indices
|
||||
#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_visualid_t;
|
||||
typedef struct xcb_connection_t xcb_connection_t;
|
||||
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 VkXcbSurfaceCreateFlagsKHR;
|
||||
|
||||
@@ -250,13 +254,16 @@ typedef struct _GLFWlibraryX11
|
||||
PFN_XGetXCBConnection XGetXCBConnection;
|
||||
} x11xcb;
|
||||
|
||||
#if defined(_GLFW_HAS_XF86VM)
|
||||
struct {
|
||||
GLFWbool available;
|
||||
void* handle;
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
PFN_XF86VidModeQueryExtension QueryExtension;
|
||||
PFN_XF86VidModeGetGammaRamp GetGammaRamp;
|
||||
PFN_XF86VidModeSetGammaRamp SetGammaRamp;
|
||||
PFN_XF86VidModeGetGammaRampSize GetGammaRampSize;
|
||||
} vidmode;
|
||||
#endif /*_GLFW_HAS_XF86VM*/
|
||||
|
||||
} _GLFWlibraryX11;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user