xrandr: move restore resolution to separated function because it makes a mess...

This commit is contained in:
Deve 2014-08-20 19:36:44 +02:00
parent 56fa56a38f
commit c2cf83bb6a
2 changed files with 56 additions and 50 deletions

View File

@ -194,7 +194,7 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
} }
// Reset fullscreen resolution change // Reset fullscreen resolution change
switchToFullscreen(true); restoreResolution();
if (!ExternalWindow) if (!ExternalWindow)
{ {
@ -235,61 +235,66 @@ int IrrPrintXError(Display *display, XErrorEvent *event)
} }
#endif #endif
bool CIrrDeviceLinux::restoreResolution()
bool CIrrDeviceLinux::switchToFullscreen(bool reset)
{ {
if (!CreationParams.Fullscreen) if (!CreationParams.Fullscreen)
return true; return true;
if (reset)
#ifdef _IRR_LINUX_X11_VIDMODE_
if (UseXVidMode && CreationParams.Fullscreen)
{ {
#ifdef _IRR_LINUX_X11_VIDMODE_ XF86VidModeSwitchToMode(display, screennr, &oldVideoMode);
if (UseXVidMode && CreationParams.Fullscreen) XF86VidModeSetViewPort(display, screennr, 0, 0);
{
XF86VidModeSwitchToMode(display, screennr, &oldVideoMode);
XF86VidModeSetViewPort(display, screennr, 0, 0);
}
#endif
#ifdef _IRR_LINUX_X11_RANDR_
if (UseXRandR && CreationParams.Fullscreen && old_mode != BadRRMode)
{
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
if (!res)
return false;
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
if (!output || !output->crtc || output->connection == RR_Disconnected)
{
XRRFreeOutputInfo(output);
return false;
}
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
if (!crtc)
{
XRRFreeCrtcInfo(crtc);
XRRFreeOutputInfo(output);
return false;
}
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
crtc->x, crtc->y, old_mode,
crtc->rotation, &output_id, 1);
XRRFreeOutputInfo(output);
XRRFreeCrtcInfo(crtc);
XRRFreeScreenResources(res);
if (s != Success)
return false;
}
#endif
return true;
} }
#endif
#ifdef _IRR_LINUX_X11_RANDR_
if (UseXRandR && CreationParams.Fullscreen && old_mode != BadRRMode)
{
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
if (!res)
return false;
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
if (!output || !output->crtc || output->connection == RR_Disconnected)
{
XRRFreeOutputInfo(output);
return false;
}
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
if (!crtc)
{
XRRFreeCrtcInfo(crtc);
XRRFreeOutputInfo(output);
return false;
}
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
crtc->x, crtc->y, old_mode,
crtc->rotation, &output_id, 1);
XRRFreeOutputInfo(output);
XRRFreeCrtcInfo(crtc);
XRRFreeScreenResources(res);
if (s != Success)
return false;
}
#endif
return true;
}
bool CIrrDeviceLinux::switchToFullscreen()
{
if (!CreationParams.Fullscreen)
return true;
getVideoModeList(); getVideoModeList();
#if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_)
s32 eventbase, errorbase; s32 eventbase, errorbase;
s32 bestMode = -1; s32 bestMode = -1;

View File

@ -150,7 +150,8 @@ namespace irr
void initXAtoms(); void initXAtoms();
bool switchToFullscreen(bool reset=false); bool restoreResolution();
bool switchToFullscreen();
//! Implementation of the linux cursor control //! Implementation of the linux cursor control
class CCursorControl : public gui::ICursorControl class CCursorControl : public gui::ICursorControl