mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Optimize calls to XRRGetScreenResources
This commit is contained in:
parent
cc3036860a
commit
b35d3d0c13
@ -458,6 +458,16 @@ static void detectEWMH(void)
|
|||||||
XFree(supportedAtoms);
|
XFree(supportedAtoms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XRRScreenResources* _glfwXRRGetScreenResources()
|
||||||
|
{
|
||||||
|
#if (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
|
||||||
|
if(_glfw.x11.randr.major > 1 || (_glfw.x11.randr.major == 1 && _glfw.x11.randr.minor >= 3))
|
||||||
|
return XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize X11 display and look for supported X11 extensions
|
// Initialize X11 display and look for supported X11 extensions
|
||||||
//
|
//
|
||||||
static GLFWbool initExtensions(void)
|
static GLFWbool initExtensions(void)
|
||||||
@ -492,8 +502,7 @@ static GLFWbool initExtensions(void)
|
|||||||
|
|
||||||
if (_glfw.x11.randr.available)
|
if (_glfw.x11.randr.available)
|
||||||
{
|
{
|
||||||
XRRScreenResources* sr = XRRGetScreenResources(_glfw.x11.display,
|
XRRScreenResources* sr = _glfwXRRGetScreenResources();
|
||||||
_glfw.x11.root);
|
|
||||||
|
|
||||||
if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
|
if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,7 @@ GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
sr = _glfwXRRGetScreenResources();
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
|
|||||||
if (monitor->x11.oldMode == None)
|
if (monitor->x11.oldMode == None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
sr = _glfwXRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
|
||||||
XRRSetCrtcConfig(_glfw.x11.display,
|
XRRSetCrtcConfig(_glfw.x11.display,
|
||||||
@ -209,7 +209,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
|||||||
{
|
{
|
||||||
int screenCount = 0;
|
int screenCount = 0;
|
||||||
XineramaScreenInfo* screens = NULL;
|
XineramaScreenInfo* screens = NULL;
|
||||||
XRRScreenResources* sr = XRRGetScreenResources(_glfw.x11.display,
|
XRRScreenResources* sr = _glfwXRRGetScreenResources(_glfw.x11.display,
|
||||||
_glfw.x11.root);
|
_glfw.x11.root);
|
||||||
RROutput primary = XRRGetOutputPrimary(_glfw.x11.display,
|
RROutput primary = XRRGetOutputPrimary(_glfw.x11.display,
|
||||||
_glfw.x11.root);
|
_glfw.x11.root);
|
||||||
@ -318,7 +318,7 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
|||||||
XRRScreenResources* sr;
|
XRRScreenResources* sr;
|
||||||
XRRCrtcInfo* ci;
|
XRRCrtcInfo* ci;
|
||||||
|
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
sr = _glfwXRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
|
||||||
if (xpos)
|
if (xpos)
|
||||||
@ -344,7 +344,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
XRRCrtcInfo* ci;
|
XRRCrtcInfo* ci;
|
||||||
XRROutputInfo* oi;
|
XRROutputInfo* oi;
|
||||||
|
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
sr = _glfwXRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
|||||||
XRRScreenResources* sr;
|
XRRScreenResources* sr;
|
||||||
XRRCrtcInfo* ci;
|
XRRCrtcInfo* ci;
|
||||||
|
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
sr = _glfwXRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
|
||||||
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
|
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
|
||||||
|
@ -299,4 +299,6 @@ void _glfwInputErrorX11(int error, const char* message);
|
|||||||
|
|
||||||
void _glfwPushSelectionToManagerX11(void);
|
void _glfwPushSelectionToManagerX11(void);
|
||||||
|
|
||||||
|
XRRScreenResources* _glfwXRRGetScreenResources();
|
||||||
|
|
||||||
#endif // _glfw3_x11_platform_h_
|
#endif // _glfw3_x11_platform_h_
|
||||||
|
Loading…
Reference in New Issue
Block a user