From c0fd319295d18c348b525b14e8cd3a673fcba8cf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 24 Nov 2014 20:26:33 -0500 Subject: VideoOGL: Move X11 wxWidgets utilities to DolphinWX --- Source/Core/DolphinWX/CMakeLists.txt | 10 +- Source/Core/DolphinWX/ConfigMain.h | 2 +- Source/Core/DolphinWX/Frame.h | 2 +- Source/Core/DolphinWX/MainNoGUI.cpp | 2 +- Source/Core/DolphinWX/X11Utils.cpp | 278 +++++++++++++++++++++ Source/Core/DolphinWX/X11Utils.h | 71 ++++++ Source/Core/VideoBackends/OGL/CMakeLists.txt | 2 +- .../VideoBackends/OGL/GLInterface/X11Utils.cpp | 278 --------------------- .../Core/VideoBackends/OGL/GLInterface/X11Utils.h | 71 ------ 9 files changed, 360 insertions(+), 356 deletions(-) create mode 100644 Source/Core/DolphinWX/X11Utils.cpp create mode 100644 Source/Core/DolphinWX/X11Utils.h delete mode 100644 Source/Core/VideoBackends/OGL/GLInterface/X11Utils.cpp delete mode 100644 Source/Core/VideoBackends/OGL/GLInterface/X11Utils.h (limited to 'Source') diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 7d70e0692b..3f20e400bf 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -48,6 +48,13 @@ set(GUI_SRCS WiimoteConfigDiag.cpp WxUtils.cpp) +set(NOGUI_SRCS MainNoGUI.cpp) + +if(USE_X11) + set(GUI_SRCS ${GUI_SRCS} X11Utils.cpp) + set(NOGUI_SRCS ${NOGUI_SRCS} X11Utils.cpp) +endif() + set(WXLIBS ${wxWidgets_LIBRARIES} dl) list(APPEND LIBS core uicommon) @@ -56,12 +63,9 @@ if(ANDROID) list(APPEND LIBS png) endif() - set(ANDROID_SRCS Android/ButtonManager.cpp MainAndroid.cpp) -set(NOGUI_SRCS MainNoGUI.cpp) - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(wxWidgets_FOUND) list(APPEND WXLIBS diff --git a/Source/Core/DolphinWX/ConfigMain.h b/Source/Core/DolphinWX/ConfigMain.h index 23cd4714f0..bf447b0ace 100644 --- a/Source/Core/DolphinWX/ConfigMain.h +++ b/Source/Core/DolphinWX/ConfigMain.h @@ -18,7 +18,7 @@ #include "Common/CommonTypes.h" #if defined(HAVE_XRANDR) && HAVE_XRANDR -#include "VideoBackends/OGL/GLInterface/X11Utils.h" +#include "DolphinWX/X11Utils.h" #endif class wxBoxSizer; diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index 91486f53cc..29b3eeb21d 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -28,7 +28,7 @@ #include "InputCommon/GCPadStatus.h" #if defined(HAVE_X11) && HAVE_X11 -#include "VideoBackends/OGL/GLInterface/X11Utils.h" +#include "DolphinWX/X11Utils.h" #endif // Class declarations diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 0b8f4b1099..c723bac087 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -101,7 +101,7 @@ void Host_ShowVideoConfig(void*, const std::string&, const std::string&) {} #if HAVE_X11 #include -#include "VideoBackends/OGL/GLInterface/X11Utils.h" +#include "DolphinWX/X11Utils.h" class PlatformX11 : public Platform { diff --git a/Source/Core/DolphinWX/X11Utils.cpp b/Source/Core/DolphinWX/X11Utils.cpp new file mode 100644 index 0000000000..6a666692a2 --- /dev/null +++ b/Source/Core/DolphinWX/X11Utils.cpp @@ -0,0 +1,278 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include +#include + +#include "Common/Logging/Log.h" +#include "Core/ConfigManager.h" +#include "Core/Core.h" +#include "Core/CoreParameter.h" +#include "DolphinWX/X11Utils.h" + +extern char **environ; + +#if defined(HAVE_WX) && HAVE_WX +#include +#include + +#include "DolphinWX/WxUtils.h" +#endif + +namespace X11Utils +{ + +void ToggleFullscreen(Display *dpy, Window win) +{ + // Init X event structure for _NET_WM_STATE_FULLSCREEN client message + XEvent event; + event.xclient.type = ClientMessage; + event.xclient.message_type = XInternAtom(dpy, "_NET_WM_STATE", False); + event.xclient.window = win; + event.xclient.format = 32; + event.xclient.data.l[0] = _NET_WM_STATE_TOGGLE; + event.xclient.data.l[1] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); + + // Send the event + if (!XSendEvent(dpy, DefaultRootWindow(dpy), False, + SubstructureRedirectMask | SubstructureNotifyMask, &event)) + ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode."); +} + +void InhibitScreensaver(Display *dpy, Window win, bool suspend) +{ + char id[11]; + snprintf(id, sizeof(id), "0x%lx", win); + + // Call xdg-screensaver + char *argv[4] = { + (char *)"xdg-screensaver", + (char *)(suspend ? "suspend" : "resume"), + id, + nullptr}; + pid_t pid; + if (!posix_spawnp(&pid, "xdg-screensaver", nullptr, nullptr, argv, environ)) + { + int status; + while (waitpid (pid, &status, 0) == -1); + + DEBUG_LOG(VIDEO, "Started xdg-screensaver (PID = %d)", (int)pid); + } +} + +#if defined(HAVE_XRANDR) && HAVE_XRANDR +XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win) + : dpy(_dpy) + , win(_win) + , screenResources(nullptr), outputInfo(nullptr), crtcInfo(nullptr) + , fullMode(0) + , fs_fb_width(0), fs_fb_height(0), fs_fb_width_mm(0), fs_fb_height_mm(0) + , bValid(true), bIsFullscreen(false) +{ + int XRRMajorVersion, XRRMinorVersion; + + if (!XRRQueryVersion(dpy, &XRRMajorVersion, &XRRMinorVersion) || + (XRRMajorVersion < 1 || (XRRMajorVersion == 1 && XRRMinorVersion < 3))) + { + WARN_LOG(VIDEO, "XRRExtension not supported."); + bValid = false; + return; + } + + screenResources = XRRGetScreenResourcesCurrent(dpy, win); + + screen = DefaultScreen(dpy); + fb_width = DisplayWidth(dpy, screen); + fb_height = DisplayHeight(dpy, screen); + fb_width_mm = DisplayWidthMM(dpy, screen); + fb_height_mm = DisplayHeightMM(dpy, screen); + + INFO_LOG(VIDEO, "XRRExtension-Version %d.%d", XRRMajorVersion, XRRMinorVersion); + Update(); +} + +XRRConfiguration::~XRRConfiguration() +{ + if (bValid && bIsFullscreen) + ToggleDisplayMode(False); + if (screenResources) + XRRFreeScreenResources(screenResources); + if (outputInfo) + XRRFreeOutputInfo(outputInfo); + if (crtcInfo) + XRRFreeCrtcInfo(crtcInfo); +} + +void XRRConfiguration::Update() +{ + if (SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution == "Auto") + return; + + if (!bValid) + return; + + if (outputInfo) + { + XRRFreeOutputInfo(outputInfo); + outputInfo = nullptr; + } + if (crtcInfo) + { + XRRFreeCrtcInfo(crtcInfo); + crtcInfo = nullptr; + } + fullMode = 0; + + // Get the resolution setings for fullscreen mode + unsigned int fullWidth, fullHeight; + char *output_name = nullptr; + if (SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.find(':') == + std::string::npos) + { + fullWidth = fb_width; + fullHeight = fb_height; + } + else + { + sscanf(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str(), + "%m[^:]: %ux%u", &output_name, &fullWidth, &fullHeight); + } + + for (int i = 0; i < screenResources->noutput; i++) + { + XRROutputInfo *output_info = XRRGetOutputInfo(dpy, screenResources, screenResources->outputs[i]); + if (output_info && output_info->crtc && output_info->connection == RR_Connected) + { + XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(dpy, screenResources, output_info->crtc); + if (crtc_info) + { + if (!output_name || !strcmp(output_name, output_info->name)) + { + // Use the first output for the default setting. + if (!output_name) + { + output_name = strdup(output_info->name); + SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution = + StringFromFormat("%s: %ux%u", output_info->name, fullWidth, fullHeight); + } + outputInfo = output_info; + crtcInfo = crtc_info; + for (int j = 0; j < output_info->nmode && fullMode == 0; j++) + { + for (int k = 0; k < screenResources->nmode && fullMode == 0; k++) + { + if (output_info->modes[j] == screenResources->modes[k].id) + { + if (fullWidth == screenResources->modes[k].width && + fullHeight == screenResources->modes[k].height) + { + fullMode = screenResources->modes[k].id; + if (crtcInfo->x + (int)screenResources->modes[k].width > fs_fb_width) + fs_fb_width = crtcInfo->x + screenResources->modes[k].width; + if (crtcInfo->y + (int)screenResources->modes[k].height > fs_fb_height) + fs_fb_height = crtcInfo->y + screenResources->modes[k].height; + } + } + } + } + } + else + { + if (crtc_info->x + (int)crtc_info->width > fs_fb_width) + fs_fb_width = crtc_info->x + crtc_info->width; + if (crtc_info->y + (int)crtc_info->height > fs_fb_height) + fs_fb_height = crtc_info->y + crtc_info->height; + } + } + if (crtc_info && crtcInfo != crtc_info) + XRRFreeCrtcInfo(crtc_info); + } + if (output_info && outputInfo != output_info) + XRRFreeOutputInfo(output_info); + } + fs_fb_width_mm = fs_fb_width * DisplayHeightMM(dpy, screen) / DisplayHeight(dpy, screen); + fs_fb_height_mm = fs_fb_height * DisplayHeightMM(dpy, screen) / DisplayHeight(dpy, screen); + + if (output_name) + free(output_name); + + if (outputInfo && crtcInfo && fullMode) + { + INFO_LOG(VIDEO, "Fullscreen Resolution %dx%d", fullWidth, fullHeight); + } + else + { + ERROR_LOG(VIDEO, "Failed to obtain fullscreen size.\n" + "Using current desktop resolution for fullscreen."); + } +} + +void XRRConfiguration::ToggleDisplayMode(bool bFullscreen) +{ + if (!bValid || !screenResources || !outputInfo || !crtcInfo || !fullMode) + return; + if (bFullscreen == bIsFullscreen) + return; + + XGrabServer(dpy); + if (bFullscreen) + { + XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, + crtcInfo->x, crtcInfo->y, fullMode, crtcInfo->rotation, + crtcInfo->outputs, crtcInfo->noutput); + XRRSetScreenSize(dpy, win, fs_fb_width, fs_fb_height, fs_fb_width_mm, fs_fb_height_mm); + bIsFullscreen = true; + } + else + { + XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, + crtcInfo->x, crtcInfo->y, crtcInfo->mode, crtcInfo->rotation, + crtcInfo->outputs, crtcInfo->noutput); + XRRSetScreenSize(dpy, win, fb_width, fb_height, fb_width_mm, fb_height_mm); + bIsFullscreen = false; + } + XUngrabServer(dpy); + XSync(dpy, false); +} + +void XRRConfiguration::AddResolutions(std::vector& resos) +{ + if (!bValid || !screenResources) + return; + + //Get all full screen resolutions for the config dialog + for (int i = 0; i < screenResources->noutput; i++) + { + XRROutputInfo *output_info = + XRRGetOutputInfo(dpy, screenResources, screenResources->outputs[i]); + + if (output_info && output_info->crtc && output_info->connection == RR_Connected) + { + for (int j = 0; j < output_info->nmode; j++) + { + for (int k = 0; k < screenResources->nmode; k++) + { + if (output_info->modes[j] == screenResources->modes[k].id) + { + const std::string strRes = + std::string(output_info->name) + ": " + + std::string(screenResources->modes[k].name); + // Only add unique resolutions + if (std::find(resos.begin(), resos.end(), strRes) == resos.end()) + { + resos.push_back(strRes); + } + } + } + } + } + if (output_info) + XRRFreeOutputInfo(output_info); + } +} + +#endif + +} diff --git a/Source/Core/DolphinWX/X11Utils.h b/Source/Core/DolphinWX/X11Utils.h new file mode 100644 index 0000000000..b68a1babe6 --- /dev/null +++ b/Source/Core/DolphinWX/X11Utils.h @@ -0,0 +1,71 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +// HACK: Xlib.h (included from gtk/gdk headers and directly) uses #defines on +// common names such as "Status", "BadRequest" or "Response", causing SFML +// headers to be completely broken. +// +// We work around that issue by including SFML first before X11 headers. This +// is terrible, but such is the life with Xlib. +#include // NOLINT + +#if defined(HAVE_WX) && HAVE_WX +#include +#include +#include +#endif + +#if defined(HAVE_XRANDR) && HAVE_XRANDR +#include +#endif +#include +#include + + +// EWMH state actions, see +// http://freedesktop.org/wiki/Specifications/wm-spec?action=show&redirect=Standards%2Fwm-spec +#define _NET_WM_STATE_REMOVE 0 // remove/unset property +#define _NET_WM_STATE_ADD 1 // add/set property +#define _NET_WM_STATE_TOGGLE 2 // toggle property + +namespace X11Utils +{ + +void ToggleFullscreen(Display *dpy, Window win); +#if defined(HAVE_WX) && HAVE_WX +Window XWindowFromHandle(void *Handle); +Display *XDisplayFromHandle(void *Handle); +#endif + +void InhibitScreensaver(Display *dpy, Window win, bool suspend); + +#if defined(HAVE_XRANDR) && HAVE_XRANDR +class XRRConfiguration +{ + public: + XRRConfiguration(Display *_dpy, Window _win); + ~XRRConfiguration(); + + void Update(); + void ToggleDisplayMode(bool bFullscreen); + void AddResolutions(std::vector& resos); + + private: + Display *dpy; + Window win; + int screen; + XRRScreenResources *screenResources; + XRROutputInfo *outputInfo; + XRRCrtcInfo *crtcInfo; + RRMode fullMode; + int fb_width, fb_height, fb_width_mm, fb_height_mm; + int fs_fb_width, fs_fb_height, fs_fb_width_mm, fs_fb_height_mm; + bool bValid; + bool bIsFullscreen; +}; +#endif + +} diff --git a/Source/Core/VideoBackends/OGL/CMakeLists.txt b/Source/Core/VideoBackends/OGL/CMakeLists.txt index 03bbdb9b9c..6d972e538c 100644 --- a/Source/Core/VideoBackends/OGL/CMakeLists.txt +++ b/Source/Core/VideoBackends/OGL/CMakeLists.txt @@ -35,7 +35,7 @@ elseif(USE_X11) # Make sure to link to it if using GLX. set(LIBS ${LIBS} ${OPENGL_LIBRARIES}) endif() - set(SRCS ${SRCS} GLInterface/X11_Util.cpp GLInterface/X11Utils.cpp) + set(SRCS ${SRCS} GLInterface/X11_Util.cpp) set(LIBS ${LIBS} ${XRANDR_LIBRARIES}) endif() diff --git a/Source/Core/VideoBackends/OGL/GLInterface/X11Utils.cpp b/Source/Core/VideoBackends/OGL/GLInterface/X11Utils.cpp deleted file mode 100644 index 7832269e27..0000000000 --- a/Source/Core/VideoBackends/OGL/GLInterface/X11Utils.cpp +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2014 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#include -#include -#include - -#include "Common/Logging/Log.h" -#include "Core/ConfigManager.h" -#include "Core/Core.h" -#include "Core/CoreParameter.h" -#include "VideoBackends/OGL/GLInterface/X11Utils.h" - -extern char **environ; - -#if defined(HAVE_WX) && HAVE_WX -#include -#include - -#include "DolphinWX/WxUtils.h" -#endif - -namespace X11Utils -{ - -void ToggleFullscreen(Display *dpy, Window win) -{ - // Init X event structure for _NET_WM_STATE_FULLSCREEN client message - XEvent event; - event.xclient.type = ClientMessage; - event.xclient.message_type = XInternAtom(dpy, "_NET_WM_STATE", False); - event.xclient.window = win; - event.xclient.format = 32; - event.xclient.data.l[0] = _NET_WM_STATE_TOGGLE; - event.xclient.data.l[1] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); - - // Send the event - if (!XSendEvent(dpy, DefaultRootWindow(dpy), False, - SubstructureRedirectMask | SubstructureNotifyMask, &event)) - ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode."); -} - -void InhibitScreensaver(Display *dpy, Window win, bool suspend) -{ - char id[11]; - snprintf(id, sizeof(id), "0x%lx", win); - - // Call xdg-screensaver - char *argv[4] = { - (char *)"xdg-screensaver", - (char *)(suspend ? "suspend" : "resume"), - id, - nullptr}; - pid_t pid; - if (!posix_spawnp(&pid, "xdg-screensaver", nullptr, nullptr, argv, environ)) - { - int status; - while (waitpid (pid, &status, 0) == -1); - - DEBUG_LOG(VIDEO, "Started xdg-screensaver (PID = %d)", (int)pid); - } -} - -#if defined(HAVE_XRANDR) && HAVE_XRANDR -XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win) - : dpy(_dpy) - , win(_win) - , screenResources(nullptr), outputInfo(nullptr), crtcInfo(nullptr) - , fullMode(0) - , fs_fb_width(0), fs_fb_height(0), fs_fb_width_mm(0), fs_fb_height_mm(0) - , bValid(true), bIsFullscreen(false) -{ - int XRRMajorVersion, XRRMinorVersion; - - if (!XRRQueryVersion(dpy, &XRRMajorVersion, &XRRMinorVersion) || - (XRRMajorVersion < 1 || (XRRMajorVersion == 1 && XRRMinorVersion < 3))) - { - WARN_LOG(VIDEO, "XRRExtension not supported."); - bValid = false; - return; - } - - screenResources = XRRGetScreenResourcesCurrent(dpy, win); - - screen = DefaultScreen(dpy); - fb_width = DisplayWidth(dpy, screen); - fb_height = DisplayHeight(dpy, screen); - fb_width_mm = DisplayWidthMM(dpy, screen); - fb_height_mm = DisplayHeightMM(dpy, screen); - - INFO_LOG(VIDEO, "XRRExtension-Version %d.%d", XRRMajorVersion, XRRMinorVersion); - Update(); -} - -XRRConfiguration::~XRRConfiguration() -{ - if (bValid && bIsFullscreen) - ToggleDisplayMode(False); - if (screenResources) - XRRFreeScreenResources(screenResources); - if (outputInfo) - XRRFreeOutputInfo(outputInfo); - if (crtcInfo) - XRRFreeCrtcInfo(crtcInfo); -} - -void XRRConfiguration::Update() -{ - if (SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution == "Auto") - return; - - if (!bValid) - return; - - if (outputInfo) - { - XRRFreeOutputInfo(outputInfo); - outputInfo = nullptr; - } - if (crtcInfo) - { - XRRFreeCrtcInfo(crtcInfo); - crtcInfo = nullptr; - } - fullMode = 0; - - // Get the resolution setings for fullscreen mode - unsigned int fullWidth, fullHeight; - char *output_name = nullptr; - if (SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.find(':') == - std::string::npos) - { - fullWidth = fb_width; - fullHeight = fb_height; - } - else - { - sscanf(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str(), - "%m[^:]: %ux%u", &output_name, &fullWidth, &fullHeight); - } - - for (int i = 0; i < screenResources->noutput; i++) - { - XRROutputInfo *output_info = XRRGetOutputInfo(dpy, screenResources, screenResources->outputs[i]); - if (output_info && output_info->crtc && output_info->connection == RR_Connected) - { - XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(dpy, screenResources, output_info->crtc); - if (crtc_info) - { - if (!output_name || !strcmp(output_name, output_info->name)) - { - // Use the first output for the default setting. - if (!output_name) - { - output_name = strdup(output_info->name); - SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution = - StringFromFormat("%s: %ux%u", output_info->name, fullWidth, fullHeight); - } - outputInfo = output_info; - crtcInfo = crtc_info; - for (int j = 0; j < output_info->nmode && fullMode == 0; j++) - { - for (int k = 0; k < screenResources->nmode && fullMode == 0; k++) - { - if (output_info->modes[j] == screenResources->modes[k].id) - { - if (fullWidth == screenResources->modes[k].width && - fullHeight == screenResources->modes[k].height) - { - fullMode = screenResources->modes[k].id; - if (crtcInfo->x + (int)screenResources->modes[k].width > fs_fb_width) - fs_fb_width = crtcInfo->x + screenResources->modes[k].width; - if (crtcInfo->y + (int)screenResources->modes[k].height > fs_fb_height) - fs_fb_height = crtcInfo->y + screenResources->modes[k].height; - } - } - } - } - } - else - { - if (crtc_info->x + (int)crtc_info->width > fs_fb_width) - fs_fb_width = crtc_info->x + crtc_info->width; - if (crtc_info->y + (int)crtc_info->height > fs_fb_height) - fs_fb_height = crtc_info->y + crtc_info->height; - } - } - if (crtc_info && crtcInfo != crtc_info) - XRRFreeCrtcInfo(crtc_info); - } - if (output_info && outputInfo != output_info) - XRRFreeOutputInfo(output_info); - } - fs_fb_width_mm = fs_fb_width * DisplayHeightMM(dpy, screen) / DisplayHeight(dpy, screen); - fs_fb_height_mm = fs_fb_height * DisplayHeightMM(dpy, screen) / DisplayHeight(dpy, screen); - - if (output_name) - free(output_name); - - if (outputInfo && crtcInfo && fullMode) - { - INFO_LOG(VIDEO, "Fullscreen Resolution %dx%d", fullWidth, fullHeight); - } - else - { - ERROR_LOG(VIDEO, "Failed to obtain fullscreen size.\n" - "Using current desktop resolution for fullscreen."); - } -} - -void XRRConfiguration::ToggleDisplayMode(bool bFullscreen) -{ - if (!bValid || !screenResources || !outputInfo || !crtcInfo || !fullMode) - return; - if (bFullscreen == bIsFullscreen) - return; - - XGrabServer(dpy); - if (bFullscreen) - { - XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, - crtcInfo->x, crtcInfo->y, fullMode, crtcInfo->rotation, - crtcInfo->outputs, crtcInfo->noutput); - XRRSetScreenSize(dpy, win, fs_fb_width, fs_fb_height, fs_fb_width_mm, fs_fb_height_mm); - bIsFullscreen = true; - } - else - { - XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, - crtcInfo->x, crtcInfo->y, crtcInfo->mode, crtcInfo->rotation, - crtcInfo->outputs, crtcInfo->noutput); - XRRSetScreenSize(dpy, win, fb_width, fb_height, fb_width_mm, fb_height_mm); - bIsFullscreen = false; - } - XUngrabServer(dpy); - XSync(dpy, false); -} - -void XRRConfiguration::AddResolutions(std::vector& resos) -{ - if (!bValid || !screenResources) - return; - - //Get all full screen resolutions for the config dialog - for (int i = 0; i < screenResources->noutput; i++) - { - XRROutputInfo *output_info = - XRRGetOutputInfo(dpy, screenResources, screenResources->outputs[i]); - - if (output_info && output_info->crtc && output_info->connection == RR_Connected) - { - for (int j = 0; j < output_info->nmode; j++) - { - for (int k = 0; k < screenResources->nmode; k++) - { - if (output_info->modes[j] == screenResources->modes[k].id) - { - const std::string strRes = - std::string(output_info->name) + ": " + - std::string(screenResources->modes[k].name); - // Only add unique resolutions - if (std::find(resos.begin(), resos.end(), strRes) == resos.end()) - { - resos.push_back(strRes); - } - } - } - } - } - if (output_info) - XRRFreeOutputInfo(output_info); - } -} - -#endif - -} diff --git a/Source/Core/VideoBackends/OGL/GLInterface/X11Utils.h b/Source/Core/VideoBackends/OGL/GLInterface/X11Utils.h deleted file mode 100644 index b68a1babe6..0000000000 --- a/Source/Core/VideoBackends/OGL/GLInterface/X11Utils.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2014 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#pragma once - -// HACK: Xlib.h (included from gtk/gdk headers and directly) uses #defines on -// common names such as "Status", "BadRequest" or "Response", causing SFML -// headers to be completely broken. -// -// We work around that issue by including SFML first before X11 headers. This -// is terrible, but such is the life with Xlib. -#include // NOLINT - -#if defined(HAVE_WX) && HAVE_WX -#include -#include -#include -#endif - -#if defined(HAVE_XRANDR) && HAVE_XRANDR -#include -#endif -#include -#include - - -// EWMH state actions, see -// http://freedesktop.org/wiki/Specifications/wm-spec?action=show&redirect=Standards%2Fwm-spec -#define _NET_WM_STATE_REMOVE 0 // remove/unset property -#define _NET_WM_STATE_ADD 1 // add/set property -#define _NET_WM_STATE_TOGGLE 2 // toggle property - -namespace X11Utils -{ - -void ToggleFullscreen(Display *dpy, Window win); -#if defined(HAVE_WX) && HAVE_WX -Window XWindowFromHandle(void *Handle); -Display *XDisplayFromHandle(void *Handle); -#endif - -void InhibitScreensaver(Display *dpy, Window win, bool suspend); - -#if defined(HAVE_XRANDR) && HAVE_XRANDR -class XRRConfiguration -{ - public: - XRRConfiguration(Display *_dpy, Window _win); - ~XRRConfiguration(); - - void Update(); - void ToggleDisplayMode(bool bFullscreen); - void AddResolutions(std::vector& resos); - - private: - Display *dpy; - Window win; - int screen; - XRRScreenResources *screenResources; - XRROutputInfo *outputInfo; - XRRCrtcInfo *crtcInfo; - RRMode fullMode; - int fb_width, fb_height, fb_width_mm, fb_height_mm; - int fs_fb_width, fs_fb_height, fs_fb_width_mm, fs_fb_height_mm; - bool bValid; - bool bIsFullscreen; -}; -#endif - -} -- cgit v1.2.3