mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
RandR and VidMode cleanup and formatting.
This commit is contained in:
parent
63a5e9a3de
commit
26aaf55872
|
@ -51,15 +51,15 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
||||||
short* ratelist;
|
short* ratelist;
|
||||||
XRRScreenConfiguration* sc;
|
XRRScreenConfiguration* sc;
|
||||||
XRRScreenSize* sizelist;
|
XRRScreenSize* sizelist;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
XF86VidModeModeInfo** modelist;
|
XF86VidModeModeInfo** modelist;
|
||||||
int bestmode, modecount;
|
int bestmode, modecount;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display,
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display,
|
||||||
RootWindow(_glfwLibrary.X11.display, screen));
|
RootWindow(_glfwLibrary.X11.display, screen));
|
||||||
|
|
||||||
|
@ -113,14 +113,11 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
||||||
|
|
||||||
if (bestsize != -1)
|
if (bestsize != -1)
|
||||||
return bestsize;
|
return bestsize;
|
||||||
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
#endif
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
// Use the XF86VidMode extension to control video resolution
|
|
||||||
if (_glfwLibrary.X11.VidMode.available &&
|
|
||||||
!_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
// Get a list of all available display modes
|
// Get a list of all available display modes
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
||||||
&modecount, &modelist);
|
&modecount, &modelist);
|
||||||
|
@ -153,8 +150,8 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
||||||
|
|
||||||
if (bestmode != -1)
|
if (bestmode != -1)
|
||||||
return bestmode;
|
return bestmode;
|
||||||
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Default: Simply use the screen resolution
|
// Default: Simply use the screen resolution
|
||||||
*width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
*width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
||||||
|
@ -173,15 +170,15 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
XRRScreenConfiguration* sc;
|
XRRScreenConfiguration* sc;
|
||||||
Window root;
|
Window root;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
XF86VidModeModeInfo **modelist;
|
XF86VidModeModeInfo **modelist;
|
||||||
int modecount;
|
int modecount;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
root = RootWindow(_glfwLibrary.X11.display, screen);
|
root = RootWindow(_glfwLibrary.X11.display, screen);
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, root);
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, root);
|
||||||
|
|
||||||
|
@ -218,14 +215,11 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
#endif
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
// Use the XF86VidMode extension to control video resolution
|
|
||||||
if (_glfwLibrary.X11.VidMode.available &&
|
|
||||||
!_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
// Get a list of all available display modes
|
// Get a list of all available display modes
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
||||||
&modecount, &modelist);
|
&modecount, &modelist);
|
||||||
|
@ -253,8 +247,8 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
||||||
|
|
||||||
// Free mode list
|
// Free mode list
|
||||||
XFree(modelist);
|
XFree(modelist);
|
||||||
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,9 +276,9 @@ void _glfwRestoreVideoMode(int screen)
|
||||||
{
|
{
|
||||||
if (_glfwLibrary.X11.FS.modeChanged)
|
if (_glfwLibrary.X11.FS.modeChanged)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
XRRScreenConfiguration* sc;
|
XRRScreenConfiguration* sc;
|
||||||
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
|
@ -301,12 +295,11 @@ void _glfwRestoreVideoMode(int screen)
|
||||||
|
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
}
|
}
|
||||||
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
#endif
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
if (_glfwLibrary.X11.VidMode.available &&
|
|
||||||
!_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
// Unlock mode switch
|
// Unlock mode switch
|
||||||
XF86VidModeLockModeSwitch(_glfwLibrary.X11.display, screen, 0);
|
XF86VidModeLockModeSwitch(_glfwLibrary.X11.display, screen, 0);
|
||||||
|
|
||||||
|
@ -314,8 +307,8 @@ void _glfwRestoreVideoMode(int screen)
|
||||||
XF86VidModeSwitchToMode(_glfwLibrary.X11.display,
|
XF86VidModeSwitchToMode(_glfwLibrary.X11.display,
|
||||||
screen,
|
screen,
|
||||||
&_glfwLibrary.X11.FS.oldMode);
|
&_glfwLibrary.X11.FS.oldMode);
|
||||||
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
_glfwLibrary.X11.FS.modeChanged = GL_FALSE;
|
_glfwLibrary.X11.FS.modeChanged = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -349,11 +342,11 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
XRRScreenConfiguration* sc;
|
XRRScreenConfiguration* sc;
|
||||||
XRRScreenSize* sizelist;
|
XRRScreenSize* sizelist;
|
||||||
int sizecount;
|
int sizecount;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
XF86VidModeModeInfo** modelist;
|
XF86VidModeModeInfo** modelist;
|
||||||
int modecount, width, height;
|
int modecount, width, height;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
// Get list of visuals
|
// Get list of visuals
|
||||||
vislist = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &viscount);
|
vislist = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &viscount);
|
||||||
|
@ -400,9 +393,10 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
resarray = NULL;
|
resarray = NULL;
|
||||||
|
|
||||||
// Build resolution array
|
// Build resolution array
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
||||||
sizelist = XRRConfigSizes(sc, &sizecount);
|
sizelist = XRRConfigSizes(sc, &sizecount);
|
||||||
|
|
||||||
|
@ -416,13 +410,11 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
}
|
}
|
||||||
|
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
#endif
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
if (_glfwLibrary.X11.VidMode.available &&
|
|
||||||
!_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
||||||
|
|
||||||
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * modecount);
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * modecount);
|
||||||
|
@ -448,8 +440,8 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(modelist);
|
XFree(modelist);
|
||||||
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!resarray)
|
if (!resarray)
|
||||||
{
|
{
|
||||||
|
@ -495,7 +487,7 @@ void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
XF86VidModeModeInfo** modelist;
|
XF86VidModeModeInfo** modelist;
|
||||||
int modecount;
|
int modecount;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
// Get display depth
|
// Get display depth
|
||||||
bpp = DefaultDepth(_glfwLibrary.X11.display, screen);
|
bpp = DefaultDepth(_glfwLibrary.X11.display, screen);
|
||||||
|
@ -503,46 +495,27 @@ void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
||||||
// Convert BPP to RGB bits
|
// Convert BPP to RGB bits
|
||||||
_glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
_glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
if (_glfwLibrary.X11.FS.modeChanged)
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
{
|
||||||
if (_glfwLibrary.X11.FS.modeChanged)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
mode->width = _glfwLibrary.X11.FS.oldWidth;
|
mode->width = _glfwLibrary.X11.FS.oldWidth;
|
||||||
mode->height = _glfwLibrary.X11.FS.oldHeight;
|
mode->height = _glfwLibrary.X11.FS.oldHeight;
|
||||||
return;
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
}
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
#endif
|
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
if (_glfwLibrary.X11.VidMode.available &&
|
|
||||||
!_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
|
||||||
if (_glfwLibrary.X11.FS.modeChanged)
|
|
||||||
{
|
{
|
||||||
// The old (desktop) mode is stored in _glfwWin.FS.oldMode
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
mode->width = _glfwLibrary.X11.FS.oldMode.hdisplay;
|
mode->width = _glfwLibrary.X11.FS.oldMode.hdisplay;
|
||||||
mode->height = _glfwLibrary.X11.FS.oldMode.vdisplay;
|
mode->height = _glfwLibrary.X11.FS.oldMode.vdisplay;
|
||||||
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use the XF86VidMode extension to get list of video modes
|
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
|
||||||
|
|
||||||
// The first mode in the list is the current (desktio) mode
|
|
||||||
mode->width = modelist[0]->hdisplay;
|
|
||||||
mode->height = modelist[0]->vdisplay;
|
|
||||||
|
|
||||||
// Free list
|
|
||||||
XFree(modelist);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#endif
|
else
|
||||||
|
{
|
||||||
// Get current display width and height
|
mode->width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
||||||
mode->width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
mode->height = DisplayHeight(_glfwLibrary.X11.display, screen);
|
||||||
mode->height = DisplayHeight(_glfwLibrary.X11.display, screen);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
|
||||||
XRRFreeGamma(gamma);
|
XRRFreeGamma(gamma);
|
||||||
XRRFreeScreenResources(rr);
|
XRRFreeScreenResources(rr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
else if (_glfwLibrary.X11.VidMode.available)
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
{
|
{
|
||||||
#if defined (_GLFW_HAS_XF86VIDMODE)
|
#if defined (_GLFW_HAS_XF86VIDMODE)
|
||||||
|
@ -72,7 +72,7 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
|
||||||
ramp->red,
|
ramp->red,
|
||||||
ramp->green,
|
ramp->green,
|
||||||
ramp->blue);
|
ramp->blue);
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
|
||||||
|
|
||||||
XRRFreeScreenResources(rr);
|
XRRFreeScreenResources(rr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
else if (_glfwLibrary.X11.VidMode.available)
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
{
|
{
|
||||||
#if defined (_GLFW_HAS_XF86VIDMODE)
|
#if defined (_GLFW_HAS_XF86VIDMODE)
|
||||||
|
@ -118,7 +118,7 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
|
||||||
(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
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ static GLboolean initDisplay(void)
|
||||||
&_glfwLibrary.X11.VidMode.errorBase);
|
&_glfwLibrary.X11.VidMode.errorBase);
|
||||||
#else
|
#else
|
||||||
_glfwLibrary.X11.VidMode.available = GL_FALSE;
|
_glfwLibrary.X11.VidMode.available = GL_FALSE;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
// Check for XRandR extension
|
// Check for XRandR extension
|
||||||
#ifdef _GLFW_HAS_XRANDR
|
#ifdef _GLFW_HAS_XRANDR
|
||||||
|
@ -107,7 +107,7 @@ static GLboolean initDisplay(void)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
_glfwLibrary.X11.RandR.available = GL_FALSE;
|
_glfwLibrary.X11.RandR.available = GL_FALSE;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
|
|
||||||
// Check if GLX is supported on this display
|
// Check if GLX is supported on this display
|
||||||
if (!glXQueryExtension(_glfwLibrary.X11.display, NULL, NULL))
|
if (!glXQueryExtension(_glfwLibrary.X11.display, NULL, NULL))
|
||||||
|
@ -162,7 +162,7 @@ static void initGammaRamp(void)
|
||||||
|
|
||||||
XRRFreeScreenResources(rr);
|
XRRFreeScreenResources(rr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
if (_glfwLibrary.X11.VidMode.available &&
|
if (_glfwLibrary.X11.VidMode.available &&
|
||||||
|
@ -173,7 +173,7 @@ static void initGammaRamp(void)
|
||||||
_glfwLibrary.X11.screen,
|
_glfwLibrary.X11.screen,
|
||||||
&_glfwLibrary.originalRampSize);
|
&_glfwLibrary.originalRampSize);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
if (!_glfwLibrary.originalRampSize)
|
if (!_glfwLibrary.originalRampSize)
|
||||||
fprintf(stderr, "Gamma ramp setting unsupported\n");
|
fprintf(stderr, "Gamma ramp setting unsupported\n");
|
||||||
|
|
|
@ -1380,7 +1380,7 @@ static void processSingleEvent(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1444,7 +1444,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||||
window->X11.handle,
|
window->X11.handle,
|
||||||
RRScreenChangeNotifyMask);
|
RRScreenChangeNotifyMask);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
|
|
||||||
enterFullscreenMode(window);
|
enterFullscreenMode(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1670,12 +1671,12 @@ void _glfwPlatformRefreshWindowParams(void)
|
||||||
GLXFBConfig* fbconfig;
|
GLXFBConfig* fbconfig;
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
XRRScreenConfiguration* sc;
|
XRRScreenConfiguration* sc;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
XF86VidModeModeLine modeline;
|
XF86VidModeModeLine modeline;
|
||||||
int dotclock;
|
int dotclock;
|
||||||
float pixels_per_second, pixels_per_frame;
|
float pixels_per_second, pixels_per_frame;
|
||||||
#endif
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||||
|
|
||||||
int attribs[] = { GLX_FBCONFIG_ID, window->GLX.fbconfigID, None };
|
int attribs[] = { GLX_FBCONFIG_ID, window->GLX.fbconfigID, None };
|
||||||
|
@ -1734,26 +1735,25 @@ void _glfwPlatformRefreshWindowParams(void)
|
||||||
window->refreshRate = 0;
|
window->refreshRate = 0;
|
||||||
|
|
||||||
// Retrieve refresh rate if possible
|
// Retrieve refresh rate if possible
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
||||||
window->refreshRate = XRRConfigCurrentRate(sc);
|
window->refreshRate = XRRConfigCurrentRate(sc);
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
#endif
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
if (_glfwLibrary.X11.VidMode.available &&
|
|
||||||
!_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
{
|
||||||
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
// Use the XF86VidMode extension to get current video mode
|
// Use the XF86VidMode extension to get current video mode
|
||||||
XF86VidModeGetModeLine(_glfwLibrary.X11.display, _glfwLibrary.X11.screen,
|
XF86VidModeGetModeLine(_glfwLibrary.X11.display, _glfwLibrary.X11.screen,
|
||||||
&dotclock, &modeline);
|
&dotclock, &modeline);
|
||||||
pixels_per_second = 1000.0f * (float) dotclock;
|
pixels_per_second = 1000.0f * (float) dotclock;
|
||||||
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
|
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
|
||||||
window->refreshRate = (int)(pixels_per_second/pixels_per_frame+0.5);
|
window->refreshRate = (int)(pixels_per_second/pixels_per_frame+0.5);
|
||||||
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
XFree(fbconfig);
|
XFree(fbconfig);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user