From 379706b25ad952749d400da2bd45b0b4b370e259 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sat, 10 Jul 2010 12:35:16 +0000 Subject: [PATCH] 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 --- Source/Core/DolphinWX/Src/X11Utils.cpp | 41 ++++++++++++++++++++------ Source/Core/DolphinWX/Src/X11Utils.h | 2 +- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinWX/Src/X11Utils.cpp b/Source/Core/DolphinWX/Src/X11Utils.cpp index 6c535ebcbc..bf3eab9164 100644 --- a/Source/Core/DolphinWX/Src/X11Utils.cpp +++ b/Source/Core/DolphinWX/Src/X11Utils.cpp @@ -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 diff --git a/Source/Core/DolphinWX/Src/X11Utils.h b/Source/Core/DolphinWX/Src/X11Utils.h index c75da74fc4..d226b6cce4 100644 --- a/Source/Core/DolphinWX/Src/X11Utils.h +++ b/Source/Core/DolphinWX/Src/X11Utils.h @@ -71,7 +71,7 @@ class XRRConfiguration XRRScreenConfiguration *screenConfig; Rotation screenRotation; int deskSize, fullSize; - + bool bValid; }; #endif