From 5f5f835b2e09ba909c235ebd46515d0741a26f07 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 11 Aug 2018 22:42:25 -0700 Subject: [PATCH] Display a warning when running under Wayland --- app/gui/PcView.qml | 17 ++++++++++++++++- app/settings/streamingpreferences.cpp | 5 +++++ app/settings/streamingpreferences.h | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/gui/PcView.qml b/app/gui/PcView.qml index 18128b39..d97dd443 100644 --- a/app/gui/PcView.qml +++ b/app/gui/PcView.qml @@ -34,7 +34,10 @@ GridView { // Setup signals on CM ComputerManager.computerAddCompleted.connect(addComplete) - if (!prefs.hasAnyHardwareAcceleration()) { + if (prefs.isRunningWayland()) { + waylandDialog.open() + } + else if (!prefs.hasAnyHardwareAcceleration()) { noHwDecoderDialog.open() } } @@ -224,6 +227,18 @@ GridView { } } + MessageDialog { + id: waylandDialog + modality:Qt.WindowModal + icon: StandardIcon.Warning + standardButtons: StandardButton.Ok | StandardButton.Help + text: "Moonlight does not support hardware acceleration on Wayland. Continuing on Wayland may result in poor streaming performance. " + + "Please switch to an X session for optimal performance." + onHelp: { + Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"); + } + } + MessageDialog { id: pairDialog // don't allow edits to the rest of the window while open diff --git a/app/settings/streamingpreferences.cpp b/app/settings/streamingpreferences.cpp index f7bd5521..ae6bdb7c 100644 --- a/app/settings/streamingpreferences.cpp +++ b/app/settings/streamingpreferences.cpp @@ -67,6 +67,11 @@ bool StreamingPreferences::hasAnyHardwareAcceleration() 1920, 1080, 60); } +bool StreamingPreferences::isRunningWayland() +{ + return qgetenv("XDG_SESSION_TYPE") == QByteArray("wayland"); +} + int StreamingPreferences::getMaximumStreamingFrameRate() { // Never let the maximum drop below 60 FPS diff --git a/app/settings/streamingpreferences.h b/app/settings/streamingpreferences.h index 3a5d8651..9aea8722 100644 --- a/app/settings/streamingpreferences.h +++ b/app/settings/streamingpreferences.h @@ -17,6 +17,8 @@ public: Q_INVOKABLE static bool hasAnyHardwareAcceleration(); + Q_INVOKABLE static bool isRunningWayland(); + Q_INVOKABLE static int getMaximumStreamingFrameRate(); Q_INVOKABLE QRect getDisplayResolution(int displayIndex);