xrandr: few more checks
- try to run in windowed mode if no output was found - close display correctly in case of no output - add few warnings
This commit is contained in:
parent
fe62df253d
commit
0dc34b2c0d
@ -340,8 +340,9 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
|||||||
{
|
{
|
||||||
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
||||||
|
|
||||||
if (!res)
|
if (!res || output_id == BadRRMode)
|
||||||
{
|
{
|
||||||
|
os::Printer::log("Could not get video output. Try to run in windowed mode.", ELL_WARNING);
|
||||||
CreationParams.Fullscreen = false;
|
CreationParams.Fullscreen = false;
|
||||||
return CreationParams.Fullscreen;
|
return CreationParams.Fullscreen;
|
||||||
}
|
}
|
||||||
@ -349,31 +350,28 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
|||||||
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
|
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
|
||||||
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
||||||
float refresh_rate, refresh_rate_new;
|
float refresh_rate, refresh_rate_new;
|
||||||
unsigned int mode0_width = -1, mode0_height = -1;
|
core::dimension2d<u32> mode0_size = core::dimension2d<u32>(0, 0);
|
||||||
|
|
||||||
for (int i = 0; i < res->nmode; i++)
|
for (int i = 0; i < res->nmode; i++)
|
||||||
{
|
{
|
||||||
const XRRModeInfo* mode = &res->modes[i];
|
const XRRModeInfo* mode = &res->modes[i];
|
||||||
unsigned int w, h;
|
core::dimension2d<u32> size;
|
||||||
|
|
||||||
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
|
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
|
||||||
{
|
{
|
||||||
w = mode->height;
|
size = core::dimension2d<u32>(mode->height, mode->width);
|
||||||
h = mode->width;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = mode->width;
|
size = core::dimension2d<u32>(mode->width, mode->height);
|
||||||
h = mode->height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bestMode == -1 && mode->id == output->modes[0])
|
if (bestMode == -1 && mode->id == output->modes[0])
|
||||||
{
|
{
|
||||||
mode0_width = w;
|
mode0_size = size;
|
||||||
mode0_height = h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bestMode == -1 && w == Width && h == Height)
|
if (bestMode == -1 && size.Width == Width && size.Height == Height)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < output->nmode; j++)
|
for (int j = 0; j < output->nmode; j++)
|
||||||
{
|
{
|
||||||
@ -385,7 +383,7 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bestMode != -1 && w == Width && h == Height)
|
else if (bestMode != -1 && size.Width == Width && size.Height == Height)
|
||||||
{
|
{
|
||||||
refresh_rate_new = (mode->dotClock * 1000.0) / (mode->hTotal * mode->vTotal);
|
refresh_rate_new = (mode->dotClock * 1000.0) / (mode->hTotal * mode->vTotal);
|
||||||
|
|
||||||
@ -408,8 +406,8 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
|||||||
if (bestMode == -1)
|
if (bestMode == -1)
|
||||||
{
|
{
|
||||||
bestMode = 0;
|
bestMode = 0;
|
||||||
Width = mode0_width;
|
Width = mode0_size.Width;
|
||||||
Height = mode0_height;
|
Height = mode0_size.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
|
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
|
||||||
@ -1595,16 +1593,17 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef _IRR_LINUX_X11_RANDR_
|
#ifdef _IRR_LINUX_X11_RANDR_
|
||||||
if (XRRQueryExtension(display, &eventbase, &errorbase))
|
while (XRRQueryExtension(display, &eventbase, &errorbase))
|
||||||
{
|
{
|
||||||
|
XRROutputInfo* output = NULL;
|
||||||
|
XRRCrtcInfo* crtc = NULL;
|
||||||
|
crtc_x = crtc_y = -1;
|
||||||
|
output_id = BadRRMode;
|
||||||
|
|
||||||
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
return &VideoModeList;
|
break;
|
||||||
|
|
||||||
XRROutputInfo *output = NULL;
|
|
||||||
XRRCrtcInfo* crtc = NULL;
|
|
||||||
crtc_x = crtc_y = -1;
|
|
||||||
|
|
||||||
RROutput primary_id = XRRGetOutputPrimary(display, DefaultRootWindow(display));
|
RROutput primary_id = XRRGetOutputPrimary(display, DefaultRootWindow(display));
|
||||||
|
|
||||||
@ -1655,39 +1654,34 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
|||||||
XRRFreeOutputInfo(output);
|
XRRFreeOutputInfo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (output_id == BadRRMode)
|
||||||
|
{
|
||||||
|
os::Printer::log("Could not get video output.", ELL_WARNING);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
output = XRRGetOutputInfo(display, res, output_id);
|
output = XRRGetOutputInfo(display, res, output_id);
|
||||||
crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
||||||
|
|
||||||
if (crtc == NULL)
|
|
||||||
{
|
|
||||||
XRRFreeCrtcInfo(crtc);
|
|
||||||
XRRFreeOutputInfo(output);
|
|
||||||
XRRFreeScreenResources(res);
|
|
||||||
return &VideoModeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < res->nmode; i++)
|
for (int i = 0; i < res->nmode; i++)
|
||||||
{
|
{
|
||||||
const XRRModeInfo* mode = &res->modes[i];
|
const XRRModeInfo* mode = &res->modes[i];
|
||||||
unsigned int w, h;
|
core::dimension2d<u32> size;
|
||||||
|
|
||||||
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
|
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
|
||||||
{
|
{
|
||||||
w = mode->height;
|
size = core::dimension2d<u32>(mode->height, mode->width);
|
||||||
h = mode->width;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = mode->width;
|
size = core::dimension2d<u32>(mode->width, mode->height);
|
||||||
h = mode->height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < output->nmode; j++)
|
for (int j = 0; j < output->nmode; j++)
|
||||||
{
|
{
|
||||||
if (mode->id == output->modes[j])
|
if (mode->id == output->modes[j])
|
||||||
{
|
{
|
||||||
VideoModeList.addMode(core::dimension2d<u32>(
|
VideoModeList.addMode(size, defaultDepth);
|
||||||
w, h), defaultDepth);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1695,21 +1689,19 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
|||||||
if (mode->id == crtc->mode)
|
if (mode->id == crtc->mode)
|
||||||
{
|
{
|
||||||
old_mode = crtc->mode;
|
old_mode = crtc->mode;
|
||||||
VideoModeList.setDesktop(defaultDepth,
|
VideoModeList.setDesktop(defaultDepth, size);
|
||||||
core::dimension2d<u32>(w, h));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XRRFreeCrtcInfo(crtc);
|
XRRFreeCrtcInfo(crtc);
|
||||||
XRRFreeOutputInfo(output);
|
XRRFreeOutputInfo(output);
|
||||||
XRRFreeScreenResources(res);
|
XRRFreeScreenResources(res);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
os::Printer::log("VidMode or RandR X11 extension requireed for VideoModeList." , ELL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display && temporaryDisplay)
|
if (display && temporaryDisplay)
|
||||||
{
|
{
|
||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user