From 5520a52379c1932cd7f1c6553f5ec2905d5c20ea Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 8 Feb 2020 21:31:04 -0800 Subject: [PATCH] Force full-screen mode on EGLFS --- app/backend/systemproperties.cpp | 7 +++++-- app/backend/systemproperties.h | 2 ++ app/gui/SettingsView.qml | 24 +++++++++++++++--------- app/gui/main.qml | 2 +- app/main.cpp | 2 +- app/wm.cpp | 2 +- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/backend/systemproperties.cpp b/app/backend/systemproperties.cpp index b5f88588..49017d31 100644 --- a/app/backend/systemproperties.cpp +++ b/app/backend/systemproperties.cpp @@ -1,4 +1,5 @@ #include "systemproperties.h" +#include "utils.h" #include @@ -7,8 +8,8 @@ SystemProperties::SystemProperties() { - isRunningWayland = qgetenv("XDG_SESSION_TYPE") == "wayland"; - isRunningXWayland = qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb"; + isRunningWayland = WMUtils::isRunningWayland(); + isRunningXWayland = isRunningWayland && QGuiApplication::platformName() == "xcb"; #ifdef Q_OS_WIN32 isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture(); @@ -28,6 +29,8 @@ SystemProperties::SystemProperties() hasDiscordIntegration = false; #endif + hasWindowManager = WMUtils::isRunningWindowManager(); + unmappedGamepads = SdlInputHandler::getUnmappedGamepads(); // Populate data that requires talking to SDL. We do it all in one shot diff --git a/app/backend/systemproperties.h b/app/backend/systemproperties.h index 4d59049a..7b9263ff 100644 --- a/app/backend/systemproperties.h +++ b/app/backend/systemproperties.h @@ -14,6 +14,7 @@ public: Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT) Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT) Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT) + Q_PROPERTY(bool hasWindowManager MEMBER hasWindowManager CONSTANT) Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT) Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT) Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged) @@ -32,6 +33,7 @@ private: bool isRunningWayland; bool isRunningXWayland; bool isWow64; + bool hasWindowManager; bool hasBrowser; bool hasDiscordIntegration; QString unmappedGamepads; diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index c85d9f08..c8e4cef7 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -88,7 +88,7 @@ Flickable { // Some platforms have different desktop resolutions // and native resolutions (like macOS with Retina displays) - if (displayResIndex == 0) { + if (displayResIndex === 0) { screenRect = SystemProperties.getDesktopResolution(displayIndex) } else { @@ -338,19 +338,24 @@ Flickable { } } - var savedWm = StreamingPreferences.windowMode currentIndex = 0 - for (var i = 0; i < windowModeListModel.count; i++) { - var thisWm = windowModeListModel.get(i).val; - if (savedWm === thisWm) { - currentIndex = i - break - } + + if (SystemProperties.hasWindowManager) { + var savedWm = StreamingPreferences.windowMode + for (var i = 0; i < windowModeListModel.count; i++) { + var thisWm = windowModeListModel.get(i).val; + if (savedWm === thisWm) { + currentIndex = i + break + } + } } + activated(currentIndex) } id: windowModeComboBox + enabled: SystemProperties.hasWindowManager hoverEnabled: true textRole: "text" model: ListModel { @@ -484,7 +489,8 @@ Flickable { id: startMaximizedCheck text: "Maximize Moonlight window on startup" font.pointSize: 12 - checked: !StreamingPreferences.startWindowed + enabled: SystemProperties.hasWindowManager + checked: !StreamingPreferences.startWindowed || !SystemProperties.hasWindowManager onCheckedChanged: { StreamingPreferences.startWindowed = !checked } diff --git a/app/gui/main.qml b/app/gui/main.qml index 4314ee25..e2555caf 100644 --- a/app/gui/main.qml +++ b/app/gui/main.qml @@ -17,7 +17,7 @@ ApplicationWindow { width: 1280 height: 600 - visibility: StreamingPreferences.startWindowed ? "Windowed" : "Maximized" + visibility: (SystemProperties.hasWindowManager && StreamingPreferences.startWindowed) ? "Windowed" : "Maximized" StackView { id: stackView diff --git a/app/main.cpp b/app/main.cpp index 1a7a0bc7..3f4a5c0e 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -382,7 +382,7 @@ int main(int argc, char *argv[]) // After the QGuiApplication is created, the platform stuff will be initialized // and we can set the SDL video driver to match Qt. - if (qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb") { + if (WMUtils::isRunningWayland() && QGuiApplication::platformName() == "xcb") { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Detected XWayland. This will probably break hardware decoding! Try running with QT_QPA_PLATFORM=wayland or switch to X11."); } diff --git a/app/wm.cpp b/app/wm.cpp index 3d622d20..5e5e8226 100644 --- a/app/wm.cpp +++ b/app/wm.cpp @@ -10,7 +10,7 @@ bool WMUtils::isRunningX11() { -#ifdef HAS_WAYLAND +#ifdef HAS_X11 Display* display = XOpenDisplay(nullptr); if (display != nullptr) { XCloseDisplay(display);