From 29eaf09be4e9cd7fa537718466faf0c28004e08e Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Wed, 3 Feb 2021 01:25:06 +0100 Subject: [PATCH 1/2] Cleanup X11 and XRANDR Macros This fixes build with X11 enabled and XRANDR disabled. --- Source/Core/DolphinNoGUI/PlatformX11.cpp | 1 + Source/Core/DolphinQt/MainWindow.cpp | 2 +- .../InputCommon/ControllerInterface/ControllerInterface.h | 2 +- Source/Core/UICommon/UICommon.cpp | 6 +++--- Source/Core/UICommon/UICommon.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinNoGUI/PlatformX11.cpp b/Source/Core/DolphinNoGUI/PlatformX11.cpp index 8eb8f2b802..c57e60bd9a 100644 --- a/Source/Core/DolphinNoGUI/PlatformX11.cpp +++ b/Source/Core/DolphinNoGUI/PlatformX11.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include "UICommon/X11Utils.h" #include "VideoCommon/RenderBase.h" diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 20572d88b2..5e9b9b09cb 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -1463,7 +1463,7 @@ void MainWindow::UpdateScreenSaverInhibition() m_is_screensaver_inhibited = inhibit; -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_X11 if (GetWindowSystemType() == WindowSystemType::X11) UICommon::InhibitScreenSaver(winId(), inhibit); #else diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index ffa189437f..254516fb6e 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -18,7 +18,7 @@ #ifdef _WIN32 #define CIFACE_USE_WIN32 #endif -#if defined(HAVE_X11) && HAVE_X11 +#ifdef HAVE_X11 #define CIFACE_USE_XLIB #endif #if defined(__APPLE__) diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index ec612df3fe..81d8bf23e2 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -39,7 +39,7 @@ #include "UICommon/UICommon.h" #include "UICommon/USBUtils.h" -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_X11 #include "UICommon/X11Utils.h" #endif @@ -394,7 +394,7 @@ bool TriggerSTMPowerEvent() return true; } -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_X11 void InhibitScreenSaver(Window win, bool inhibit) #else void InhibitScreenSaver(bool inhibit) @@ -403,7 +403,7 @@ void InhibitScreenSaver(bool inhibit) // Inhibit the screensaver. Depending on the operating system this may also // disable low-power states and/or screen dimming. -#if defined(HAVE_X11) && HAVE_X11 +#ifdef HAVE_X11 X11Utils::InhibitScreensaver(win, inhibit); #endif diff --git a/Source/Core/UICommon/UICommon.h b/Source/Core/UICommon/UICommon.h index 830dc064e5..dd6ef4ccc9 100644 --- a/Source/Core/UICommon/UICommon.h +++ b/Source/Core/UICommon/UICommon.h @@ -13,7 +13,7 @@ namespace UICommon void Init(); void Shutdown(); -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_X11 void InhibitScreenSaver(unsigned long win, bool enable); #else void InhibitScreenSaver(bool enable); From d4b293e969341b630340f3d3c35e1c0d3edf4152 Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Mon, 22 Feb 2021 14:32:53 +0100 Subject: [PATCH 2/2] Simplify macro guards for HAVE_XRANDR --- CMakeLists.txt | 2 -- Source/Core/DolphinNoGUI/PlatformX11.cpp | 10 +++++----- Source/Core/DolphinQt/MainWindow.cpp | 4 ++-- Source/Core/DolphinQt/MainWindow.h | 2 +- Source/Core/UICommon/VideoUtils.cpp | 2 +- Source/Core/UICommon/X11Utils.cpp | 2 +- Source/Core/UICommon/X11Utils.h | 4 ++-- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37c2ba2197..9197156e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -440,8 +440,6 @@ if(ENABLE_X11) check_lib(XRANDR xrandr Xrandr) if(XRANDR_FOUND) add_definitions(-DHAVE_XRANDR=1) - else() - add_definitions(-DHAVE_XRANDR=0) endif() pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0) message(STATUS "X11 support enabled") diff --git a/Source/Core/DolphinNoGUI/PlatformX11.cpp b/Source/Core/DolphinNoGUI/PlatformX11.cpp index c57e60bd9a..b44620a048 100644 --- a/Source/Core/DolphinNoGUI/PlatformX11.cpp +++ b/Source/Core/DolphinNoGUI/PlatformX11.cpp @@ -48,7 +48,7 @@ private: Display* m_display = nullptr; Window m_window = {}; Cursor m_blank_cursor = None; -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR X11Utils::XRRConfiguration* m_xrr_config = nullptr; #endif int m_window_x = Config::Get(Config::MAIN_RENDER_WINDOW_XPOS); @@ -59,7 +59,7 @@ private: PlatformX11::~PlatformX11() { -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR delete m_xrr_config; #endif @@ -106,7 +106,7 @@ bool PlatformX11::Init() if (Config::Get(Config::MAIN_DISABLE_SCREENSAVER)) X11Utils::InhibitScreensaver(m_window, true); -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR m_xrr_config = new X11Utils::XRRConfiguration(m_display, m_window); #endif @@ -126,7 +126,7 @@ bool PlatformX11::Init() if (Config::Get(Config::MAIN_FULLSCREEN)) { m_window_fullscreen = X11Utils::ToggleFullscreen(m_display, m_window); -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR m_xrr_config->ToggleDisplayMode(True); #endif ProcessEvents(); @@ -210,7 +210,7 @@ void PlatformX11::ProcessEvents() { m_window_fullscreen = !m_window_fullscreen; X11Utils::ToggleFullscreen(m_display, m_window); -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR m_xrr_config->ToggleDisplayMode(m_window_fullscreen); #endif UpdateWindowPosition(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 5e9b9b09cb..c0235835e4 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -119,7 +119,7 @@ #include "VideoCommon/NetPlayChatUI.h" #include "VideoCommon/VideoConfig.h" -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR #include "UICommon/X11Utils.h" // This #define within X11/X.h conflicts with our WiimoteSource enum. #undef None @@ -1172,7 +1172,7 @@ void MainWindow::ShowGraphicsWindow() { if (!m_graphics_window) { -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR if (GetWindowSystemType() == WindowSystemType::X11) { m_xrr_config = std::make_unique( diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index bd9da7651c..60653412bb 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -191,7 +191,7 @@ private: void dropEvent(QDropEvent* event) override; QSize sizeHint() const override; -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR std::unique_ptr m_xrr_config; #endif diff --git a/Source/Core/UICommon/VideoUtils.cpp b/Source/Core/UICommon/VideoUtils.cpp index 73c88a743a..b6cdde49bf 100644 --- a/Source/Core/UICommon/VideoUtils.cpp +++ b/Source/Core/UICommon/VideoUtils.cpp @@ -11,7 +11,7 @@ #include #endif -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR #include "UICommon/X11Utils.h" #endif diff --git a/Source/Core/UICommon/X11Utils.cpp b/Source/Core/UICommon/X11Utils.cpp index 24317d8a04..239482f01f 100644 --- a/Source/Core/UICommon/X11Utils.cpp +++ b/Source/Core/UICommon/X11Utils.cpp @@ -64,7 +64,7 @@ void InhibitScreensaver(Window win, bool suspend) } } -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef 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), diff --git a/Source/Core/UICommon/X11Utils.h b/Source/Core/UICommon/X11Utils.h index 33b2fa2d0e..6d69d8bdd0 100644 --- a/Source/Core/UICommon/X11Utils.h +++ b/Source/Core/UICommon/X11Utils.h @@ -7,7 +7,7 @@ #include #include -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR #include #endif #include @@ -26,7 +26,7 @@ Display* XDisplayFromHandle(void* Handle); void InhibitScreensaver(Window win, bool suspend); -#if defined(HAVE_XRANDR) && HAVE_XRANDR +#ifdef HAVE_XRANDR class XRRConfiguration { public: