Force full-screen mode on EGLFS

This commit is contained in:
Cameron Gutman 2020-02-08 21:31:04 -08:00
parent 505050e936
commit 5520a52379
6 changed files with 25 additions and 14 deletions

View File

@ -1,4 +1,5 @@
#include "systemproperties.h" #include "systemproperties.h"
#include "utils.h"
#include <QGuiApplication> #include <QGuiApplication>
@ -7,8 +8,8 @@
SystemProperties::SystemProperties() SystemProperties::SystemProperties()
{ {
isRunningWayland = qgetenv("XDG_SESSION_TYPE") == "wayland"; isRunningWayland = WMUtils::isRunningWayland();
isRunningXWayland = qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb"; isRunningXWayland = isRunningWayland && QGuiApplication::platformName() == "xcb";
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture(); isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
@ -28,6 +29,8 @@ SystemProperties::SystemProperties()
hasDiscordIntegration = false; hasDiscordIntegration = false;
#endif #endif
hasWindowManager = WMUtils::isRunningWindowManager();
unmappedGamepads = SdlInputHandler::getUnmappedGamepads(); unmappedGamepads = SdlInputHandler::getUnmappedGamepads();
// Populate data that requires talking to SDL. We do it all in one shot // Populate data that requires talking to SDL. We do it all in one shot

View File

@ -14,6 +14,7 @@ public:
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT) Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT) Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
Q_PROPERTY(bool isWow64 MEMBER isWow64 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 hasBrowser MEMBER hasBrowser CONSTANT)
Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT) Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT)
Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged) Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged)
@ -32,6 +33,7 @@ private:
bool isRunningWayland; bool isRunningWayland;
bool isRunningXWayland; bool isRunningXWayland;
bool isWow64; bool isWow64;
bool hasWindowManager;
bool hasBrowser; bool hasBrowser;
bool hasDiscordIntegration; bool hasDiscordIntegration;
QString unmappedGamepads; QString unmappedGamepads;

View File

@ -88,7 +88,7 @@ Flickable {
// Some platforms have different desktop resolutions // Some platforms have different desktop resolutions
// and native resolutions (like macOS with Retina displays) // and native resolutions (like macOS with Retina displays)
if (displayResIndex == 0) { if (displayResIndex === 0) {
screenRect = SystemProperties.getDesktopResolution(displayIndex) screenRect = SystemProperties.getDesktopResolution(displayIndex)
} }
else { else {
@ -338,19 +338,24 @@ Flickable {
} }
} }
var savedWm = StreamingPreferences.windowMode
currentIndex = 0 currentIndex = 0
for (var i = 0; i < windowModeListModel.count; i++) {
var thisWm = windowModeListModel.get(i).val; if (SystemProperties.hasWindowManager) {
if (savedWm === thisWm) { var savedWm = StreamingPreferences.windowMode
currentIndex = i for (var i = 0; i < windowModeListModel.count; i++) {
break var thisWm = windowModeListModel.get(i).val;
} if (savedWm === thisWm) {
currentIndex = i
break
}
}
} }
activated(currentIndex) activated(currentIndex)
} }
id: windowModeComboBox id: windowModeComboBox
enabled: SystemProperties.hasWindowManager
hoverEnabled: true hoverEnabled: true
textRole: "text" textRole: "text"
model: ListModel { model: ListModel {
@ -484,7 +489,8 @@ Flickable {
id: startMaximizedCheck id: startMaximizedCheck
text: "Maximize Moonlight window on startup" text: "Maximize Moonlight window on startup"
font.pointSize: 12 font.pointSize: 12
checked: !StreamingPreferences.startWindowed enabled: SystemProperties.hasWindowManager
checked: !StreamingPreferences.startWindowed || !SystemProperties.hasWindowManager
onCheckedChanged: { onCheckedChanged: {
StreamingPreferences.startWindowed = !checked StreamingPreferences.startWindowed = !checked
} }

View File

@ -17,7 +17,7 @@ ApplicationWindow {
width: 1280 width: 1280
height: 600 height: 600
visibility: StreamingPreferences.startWindowed ? "Windowed" : "Maximized" visibility: (SystemProperties.hasWindowManager && StreamingPreferences.startWindowed) ? "Windowed" : "Maximized"
StackView { StackView {
id: stackView id: stackView

View File

@ -382,7 +382,7 @@ int main(int argc, char *argv[])
// After the QGuiApplication is created, the platform stuff will be initialized // After the QGuiApplication is created, the platform stuff will be initialized
// and we can set the SDL video driver to match Qt. // 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, 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."); "Detected XWayland. This will probably break hardware decoding! Try running with QT_QPA_PLATFORM=wayland or switch to X11.");
} }

View File

@ -10,7 +10,7 @@
bool WMUtils::isRunningX11() bool WMUtils::isRunningX11()
{ {
#ifdef HAS_WAYLAND #ifdef HAS_X11
Display* display = XOpenDisplay(nullptr); Display* display = XOpenDisplay(nullptr);
if (display != nullptr) { if (display != nullptr) {
XCloseDisplay(display); XCloseDisplay(display);