Fixed video modes not being rotated to match CRTC.

Fixes #284.
This commit is contained in:
Camilla Berglund 2014-08-10 16:35:09 +02:00
parent 036da0fb4e
commit 87490316c8
2 changed files with 22 additions and 6 deletions

View File

@ -102,6 +102,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
- [X11] Bugfix: Window frame interactions were reported as focus events
- [X11] Bugfix: Workaround for legacy Compiz caused flickering during resize
- [X11] Bugfix: The name pointer of joysticks were not cleared on disconnection
- [X11] Bugfix: Video mode dimensions were not rotated to match the CRTC
## Contact
@ -139,6 +140,7 @@ skills.
- Niklas Bergström
- Doug Binks
- blanco
- Martin Capitanio
- Lambert Clara
- Andrew Corrigan
- Noel Cower

View File

@ -66,11 +66,22 @@ static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
// Convert RandR mode info to GLFW video mode
//
static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi)
static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,
const XRRCrtcInfo* ci)
{
GLFWvidmode mode;
if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
{
mode.width = mi->height;
mode.height = mi->width;
}
else
{
mode.width = mi->width;
mode.height = mi->height;
}
mode.refreshRate = calculateRefreshRate(mi);
_glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
@ -113,7 +124,7 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
if (!modeIsGood(mi))
continue;
const GLFWvidmode mode = vidmodeFromModeInfo(mi);
const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
if (_glfwCompareVideoModes(best, &mode) == 0)
{
native = mi->id;
@ -325,9 +336,11 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
{
int i, j;
XRRScreenResources* sr;
XRRCrtcInfo* ci;
XRROutputInfo* oi;
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
result = calloc(oi->nmode, sizeof(GLFWvidmode));
@ -338,7 +351,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
if (!modeIsGood(mi))
continue;
const GLFWvidmode mode = vidmodeFromModeInfo(mi);
const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
for (j = 0; j < *found; j++)
{
@ -361,6 +374,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
}
XRRFreeOutputInfo(oi);
XRRFreeCrtcInfo(ci);
XRRFreeScreenResources(sr);
}
else
@ -383,7 +397,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode));
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
XRRFreeCrtcInfo(ci);
XRRFreeScreenResources(sr);