On linux check to see if the xrandr extension is present and don't use it if not.

This fixes issue 2920.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5867 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-07-10 12:35:16 +00:00
parent 91dafccd27
commit 379706b25a
2 changed files with 33 additions and 10 deletions

View File

@ -17,9 +17,6 @@
#include "X11Utils.h"
#if defined(HAVE_XRANDR) && HAVE_XRANDR
#endif
namespace X11Utils
{
@ -41,7 +38,7 @@ void SendClientEvent(const char *message,
// Send the event
if (!XSendEvent(dpy, win, False, False, &event))
ERROR_LOG(VIDEO, "Failed to send message %s to the emulator window.\n", message);
ERROR_LOG(VIDEO, "Failed to send message %s to the emulator window.", message);
}
void SendKeyEvent(int key)
@ -58,7 +55,7 @@ void SendKeyEvent(int key)
// Send the event
if (!XSendEvent(dpy, win, False, False, &event))
ERROR_LOG(VIDEO, "Failed to send key press event to the emulator window.\n");
ERROR_LOG(VIDEO, "Failed to send key press event to the emulator window.");
}
void EWMH_Fullscreen(int action)
@ -81,7 +78,7 @@ void EWMH_Fullscreen(int action)
// Send the event
if (!XSendEvent(dpy, DefaultRootWindow(dpy), False,
SubstructureRedirectMask | SubstructureNotifyMask, &event))
ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.\n");
ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.");
}
#if defined(HAVE_WX) && HAVE_WX
@ -101,7 +98,21 @@ XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
: dpy(_dpy)
, win(_win)
, deskSize(-1), fullSize(-1)
, bValid(true)
{
XRRScreenSize *sizes;
int numSizes;
// XRRSizes is safe to call even if the RANDR extension is not present and numSizes
// will be 0 in that case (according to the documentation)
sizes = XRRSizes(dpy, DefaultScreen(dpy), &numSizes);
if (!numSizes)
{
NOTICE_LOG(VIDEO, "XRRExtension not supported.");
bValid = false;
return;
}
int vidModeMajorVersion, vidModeMinorVersion;
XRRQueryVersion(dpy, &vidModeMajorVersion, &vidModeMinorVersion);
NOTICE_LOG(VIDEO, "XRRExtension-Version %d.%d", vidModeMajorVersion, vidModeMinorVersion);
@ -110,13 +121,19 @@ XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
XRRConfiguration::~XRRConfiguration()
{
ToggleDisplayMode(False);
XRRFreeScreenConfigInfo(screenConfig);
if (bValid)
{
ToggleDisplayMode(False);
XRRFreeScreenConfigInfo(screenConfig);
}
}
void XRRConfiguration::Update()
{
if (!bValid)
return;
// Get the resolution setings for fullscreen mode
int fullWidth, fullHeight;
sscanf(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str(),
@ -145,12 +162,15 @@ void XRRConfiguration::Update()
}
else {
ERROR_LOG(VIDEO, "Failed to obtain fullscreen size.\n"
"Using current desktop resolution for fullscreen.\n");
"Using current desktop resolution for fullscreen.");
}
}
void XRRConfiguration::ToggleDisplayMode(bool bFullscreen)
{
if (!bValid)
return;
if (bFullscreen)
XRRSetScreenConfig(dpy, screenConfig, win,
fullSize, screenRotation, CurrentTime);
@ -162,6 +182,9 @@ void XRRConfiguration::ToggleDisplayMode(bool bFullscreen)
#if defined(HAVE_WX) && HAVE_WX
void XRRConfiguration::AddResolutions(wxArrayString& arrayStringFor_FullscreenResolution)
{
if (!bValid)
return;
int screen;
screen = DefaultScreen(dpy);
//Get all full screen resos for the config dialog

View File

@ -71,7 +71,7 @@ class XRRConfiguration
XRRScreenConfiguration *screenConfig;
Rotation screenRotation;
int deskSize, fullSize;
bool bValid;
};
#endif