mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-15 21:22:40 +00:00
Autodetect a Wayland environment and configure SDL correctly. Fixes #211
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
#include "systemproperties.h"
|
#include "systemproperties.h"
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#include "streaming/session.h"
|
#include "streaming/session.h"
|
||||||
#include "streaming/streamutils.h"
|
#include "streaming/streamutils.h"
|
||||||
|
|
||||||
SystemProperties::SystemProperties()
|
SystemProperties::SystemProperties()
|
||||||
{
|
{
|
||||||
isRunningWayland = qgetenv("XDG_SESSION_TYPE") == "wayland";
|
isRunningWayland = qgetenv("XDG_SESSION_TYPE") == "wayland";
|
||||||
|
isRunningXWayland = qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb";
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
|
isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public:
|
|||||||
|
|
||||||
Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT)
|
Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT)
|
||||||
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
|
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland 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 hasBrowser MEMBER hasBrowser CONSTANT)
|
Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT)
|
||||||
Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged)
|
Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged)
|
||||||
@@ -28,6 +29,7 @@ private:
|
|||||||
|
|
||||||
bool hasHardwareAcceleration;
|
bool hasHardwareAcceleration;
|
||||||
bool isRunningWayland;
|
bool isRunningWayland;
|
||||||
|
bool isRunningXWayland;
|
||||||
bool isWow64;
|
bool isWow64;
|
||||||
bool hasBrowser;
|
bool hasBrowser;
|
||||||
QString unmappedGamepads;
|
QString unmappedGamepads;
|
||||||
|
|||||||
+10
-8
@@ -138,14 +138,16 @@ ApplicationWindow {
|
|||||||
// onAfterRendering call and potentially reenter this code.
|
// onAfterRendering call and potentially reenter this code.
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
if (SystemProperties.isRunningWayland) {
|
if (SystemProperties.isWow64) {
|
||||||
waylandDialog.open()
|
|
||||||
}
|
|
||||||
else if (SystemProperties.isWow64) {
|
|
||||||
wow64Dialog.open()
|
wow64Dialog.open()
|
||||||
}
|
}
|
||||||
else if (!SystemProperties.hasHardwareAcceleration) {
|
else if (!SystemProperties.hasHardwareAcceleration) {
|
||||||
noHwDecoderDialog.open()
|
if (SystemProperties.isRunningXWayland) {
|
||||||
|
xWaylandDialog.open()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
noHwDecoderDialog.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SystemProperties.unmappedGamepads) {
|
if (SystemProperties.unmappedGamepads) {
|
||||||
@@ -385,9 +387,9 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ErrorMessageDialog {
|
ErrorMessageDialog {
|
||||||
id: waylandDialog
|
id: xWaylandDialog
|
||||||
text: "Moonlight does not support hardware acceleration on Wayland. Continuing on Wayland may result in poor streaming performance. " +
|
text: "Hardware acceleration doesn't work on XWayland. Continuing on XWayland may result in poor streaming performance. " +
|
||||||
"Please switch to an X session for optimal performance."
|
"Try running with QT_QPA_PLATFORM=wayland or switch to X11."
|
||||||
helpText: "Click the Help button for more information."
|
helpText: "Click the Help button for more information."
|
||||||
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"
|
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,6 +346,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, 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") {
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
else if (QGuiApplication::platformName().startsWith("wayland")) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Detected Wayland. Performance may be worse than X11.");
|
||||||
|
qputenv("SDL_VIDEODRIVER", "wayland");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef STEAM_LINK
|
#ifdef STEAM_LINK
|
||||||
// Qt 5.9 from the Steam Link SDK is not able to load any fonts
|
// Qt 5.9 from the Steam Link SDK is not able to load any fonts
|
||||||
// since the Steam Link doesn't include any of the ones it looks
|
// since the Steam Link doesn't include any of the ones it looks
|
||||||
|
|||||||
Reference in New Issue
Block a user