aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/main.cpp
diff options
context:
space:
mode:
authorCaio Oliveira <caiooliveirafarias0@gmail.com>2025-10-29 13:16:57 +0100
committercrueter <crueter@eden-emu.dev>2025-10-29 13:16:57 +0100
commit2f591d33d356e81a5a4c9688fa36fd556f27aacb (patch)
tree5365aa01682d3a31ef24306cb718330514f9c26e /src/yuzu/main.cpp
parente4b0c03a22808c37c96010cadc7511ad4de18759 (diff)
[meta] Add option to FORCE X11 as Graphics Backend (#2820)
* save the option on a external file because settings are loaded AFTER Qt window is created and then the graphics backend is already applied Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2820 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev> Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Co-committed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r--src/yuzu/main.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 521c677c2a..a4800d4b29 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -25,6 +25,7 @@
#ifdef __unix__
#include <csignal>
#include <sys/socket.h>
+#include "qt_common/gui_settings.h"
#endif
#ifdef __linux__
#include "common/linux/gamemode.h"
@@ -552,6 +553,10 @@ GMainWindow::GMainWindow(bool has_broken_vulkan)
// Gen keys if necessary
OnCheckFirmwareDecryption();
+#ifdef __unix__
+ OnCheckGraphicsBackend();
+#endif
+
// Check for orphaned profiles and reset profile data if necessary
QtCommon::Content::FixProfiles();
@@ -3497,6 +3502,9 @@ void GMainWindow::OnConfigure() {
#ifdef __linux__
const bool old_gamemode = Settings::values.enable_gamemode.GetValue();
#endif
+#ifdef __unix__
+ const bool old_force_x11 = Settings::values.gui_force_x11.GetValue();
+#endif
Settings::SetConfiguringGlobal(true);
ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(),
@@ -3561,6 +3569,11 @@ void GMainWindow::OnConfigure() {
SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue());
}
#endif
+#ifdef __unix__
+ if (Settings::values.gui_force_x11.GetValue() != old_force_x11) {
+ GraphicsBackend::SetForceX11(Settings::values.gui_force_x11.GetValue());
+ }
+#endif
if (!multiplayer_state->IsHostingPublicRoom()) {
multiplayer_state->UpdateCredentials();
@@ -4536,6 +4549,54 @@ void GMainWindow::OnCheckFirmwareDecryption() {
UpdateMenuState();
}
+#ifdef __unix__
+void GMainWindow::OnCheckGraphicsBackend() {
+ const QString platformName = QGuiApplication::platformName();
+ const QByteArray qtPlatform = qgetenv("QT_QPA_PLATFORM");
+
+ if (platformName == QStringLiteral("xcb") || qtPlatform == "xcb")
+ return;
+
+ const bool isWayland = platformName.startsWith(QStringLiteral("wayland"), Qt::CaseInsensitive) || qtPlatform.startsWith("wayland");
+ if (!isWayland)
+ return;
+
+ const bool currently_hidden = Settings::values.gui_hide_backend_warning.GetValue();
+ if (currently_hidden)
+ return;
+
+ QMessageBox msgbox(this);
+ msgbox.setWindowTitle(tr("Wayland Detected!"));
+ msgbox.setText(tr("Wayland is known to have significant performance issues and mysterious bugs.\n"
+ "It's recommended to use X11 instead.\n\n"
+ "Would you like to force it for future launches?"));
+ msgbox.setIcon(QMessageBox::Warning);
+
+ QPushButton* okButton = msgbox.addButton(tr("Use X11"), QMessageBox::AcceptRole);
+ msgbox.addButton(tr("Continue with Wayland"), QMessageBox::RejectRole);
+ msgbox.setDefaultButton(okButton);
+
+ QCheckBox* cb = new QCheckBox(tr("Don't show again"), &msgbox);
+ cb->setChecked(currently_hidden);
+ msgbox.setCheckBox(cb);
+
+ msgbox.exec();
+
+ const bool hide = cb->isChecked();
+ if (hide != currently_hidden) {
+ Settings::values.gui_hide_backend_warning.SetValue(hide);
+ }
+
+ if (msgbox.clickedButton() == okButton) {
+ Settings::values.gui_force_x11.SetValue(true);
+ GraphicsBackend::SetForceX11(true);
+ QMessageBox::information(this,
+ tr("Restart Required"),
+ tr("Restart Eden to apply the X11 backend."));
+ }
+}
+#endif
+
bool GMainWindow::CheckFirmwarePresence() {
return FirmwareManager::CheckFirmwarePresence(*QtCommon::system.get());
}
@@ -5029,6 +5090,9 @@ int main(int argc, char* argv[]) {
qputenv("DISPLAY", ":0");
}
+ if (GraphicsBackend::GetForceX11() && qEnvironmentVariableIsEmpty("QT_QPA_PLATFORM"))
+ qputenv("QT_QPA_PLATFORM", "xcb");
+
// Fix the Wayland appId. This needs to match the name of the .desktop file without the .desktop
// suffix.
QGuiApplication::setDesktopFileName(QStringLiteral("dev.eden_emu.eden"));