[meta] Add option to FORCE X11 as Graphics Backend
All checks were successful
eden-license / license-header (pull_request) Successful in 30s
All checks were successful
eden-license / license-header (pull_request) Successful in 30s
* 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>
This commit is contained in:
parent
b6241e4148
commit
cb9fd38569
7 changed files with 118 additions and 0 deletions
|
@ -625,6 +625,10 @@ struct Values {
|
||||||
|
|
||||||
// Linux
|
// Linux
|
||||||
SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux};
|
SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux};
|
||||||
|
#ifdef __unix__
|
||||||
|
SwitchableSetting<bool> gui_force_x11{linkage, false, "gui_force_x11", Category::Linux};
|
||||||
|
Setting<bool> gui_hide_backend_warning{linkage, false, "gui_hide_backend_warning", Category::Linux};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
InputSetting<std::array<PlayerInput, 10>> players;
|
InputSetting<std::array<PlayerInput, 10>> players;
|
||||||
|
|
|
@ -30,6 +30,10 @@ add_library(qt_common STATIC
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (UNIX)
|
||||||
|
target_sources(qt_common PRIVATE gui_settings.cpp gui_settings.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
create_target_directory_groups(qt_common)
|
create_target_directory_groups(qt_common)
|
||||||
|
|
||||||
# TODO(crueter)
|
# TODO(crueter)
|
||||||
|
|
25
src/qt_common/gui_settings.cpp
Normal file
25
src/qt_common/gui_settings.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#include "gui_settings.h"
|
||||||
|
#include "common/fs/fs.h"
|
||||||
|
#include "common/fs/path_util.h"
|
||||||
|
|
||||||
|
namespace FS = Common::FS;
|
||||||
|
|
||||||
|
namespace GraphicsBackend {
|
||||||
|
|
||||||
|
QString GuiConfigPath() {
|
||||||
|
return QString::fromStdString(FS::PathToUTF8String(FS::GetEdenPath(FS::EdenPath::ConfigDir) / "gui_config.ini"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetForceX11(bool state) {
|
||||||
|
(void)FS::CreateParentDir(GuiConfigPath().toStdString());
|
||||||
|
QSettings(GuiConfigPath(), QSettings::IniFormat).setValue("gui_force_x11", state);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetForceX11() {
|
||||||
|
return QSettings(GuiConfigPath(), QSettings::IniFormat).value("gui_force_x11", false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace GraphicsBackend
|
14
src/qt_common/gui_settings.h
Normal file
14
src/qt_common/gui_settings.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace GraphicsBackend {
|
||||||
|
|
||||||
|
void SetForceX11(bool state);
|
||||||
|
bool GetForceX11();
|
||||||
|
|
||||||
|
} // namespace GraphicsBackend
|
|
@ -424,6 +424,10 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QObject* parent)
|
||||||
|
|
||||||
// Linux
|
// Linux
|
||||||
INSERT(Settings, enable_gamemode, tr("Enable Gamemode"), QString());
|
INSERT(Settings, enable_gamemode, tr("Enable Gamemode"), QString());
|
||||||
|
#ifdef __unix__
|
||||||
|
INSERT(Settings, gui_force_x11, tr("Force X11 as Graphics Backend"), QString());
|
||||||
|
INSERT(Settings, gui_hide_backend_warning, QString(), QString());
|
||||||
|
#endif
|
||||||
|
|
||||||
// Ui Debugging
|
// Ui Debugging
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include "qt_common/gui_settings.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "common/linux/gamemode.h"
|
#include "common/linux/gamemode.h"
|
||||||
|
@ -545,6 +546,10 @@ GMainWindow::GMainWindow(bool has_broken_vulkan)
|
||||||
// Gen keys if necessary
|
// Gen keys if necessary
|
||||||
OnCheckFirmwareDecryption();
|
OnCheckFirmwareDecryption();
|
||||||
|
|
||||||
|
#ifdef __unix__
|
||||||
|
OnCheckGraphicsBackend();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check for orphaned profiles and reset profile data if necessary
|
// Check for orphaned profiles and reset profile data if necessary
|
||||||
QtCommon::Content::FixProfiles();
|
QtCommon::Content::FixProfiles();
|
||||||
|
|
||||||
|
@ -3433,6 +3438,9 @@ void GMainWindow::OnConfigure() {
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
const bool old_gamemode = Settings::values.enable_gamemode.GetValue();
|
const bool old_gamemode = Settings::values.enable_gamemode.GetValue();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __unix__
|
||||||
|
const bool old_force_x11 = Settings::values.gui_force_x11.GetValue();
|
||||||
|
#endif
|
||||||
|
|
||||||
Settings::SetConfiguringGlobal(true);
|
Settings::SetConfiguringGlobal(true);
|
||||||
ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(),
|
ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(),
|
||||||
|
@ -3497,6 +3505,11 @@ void GMainWindow::OnConfigure() {
|
||||||
SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue());
|
SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue());
|
||||||
}
|
}
|
||||||
#endif
|
#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()) {
|
if (!multiplayer_state->IsHostingPublicRoom()) {
|
||||||
multiplayer_state->UpdateCredentials();
|
multiplayer_state->UpdateCredentials();
|
||||||
|
@ -4463,6 +4476,54 @@ void GMainWindow::OnCheckFirmwareDecryption() {
|
||||||
UpdateMenuState();
|
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("You are running Eden under Wayland Graphics Backend.\n\n"
|
||||||
|
"It's recommended to use X11 for the best compatibility.\n\n"
|
||||||
|
"There's no plan to support Wayland at moment\nExpect crashes!"));
|
||||||
|
msgbox.setIcon(QMessageBox::Warning);
|
||||||
|
|
||||||
|
QPushButton* okButton = msgbox.addButton(tr("Use X11"), QMessageBox::AcceptRole);
|
||||||
|
QPushButton* cancelButton = 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() {
|
bool GMainWindow::CheckFirmwarePresence() {
|
||||||
return FirmwareManager::CheckFirmwarePresence(*QtCommon::system.get());
|
return FirmwareManager::CheckFirmwarePresence(*QtCommon::system.get());
|
||||||
}
|
}
|
||||||
|
@ -4952,6 +5013,9 @@ int main(int argc, char* argv[]) {
|
||||||
qputenv("DISPLAY", ":0");
|
qputenv("DISPLAY", ":0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GraphicsBackend::GetForceX11())
|
||||||
|
qputenv("QT_QPA_PLATFORM", "xcb");
|
||||||
|
|
||||||
// Fix the Wayland appId. This needs to match the name of the .desktop file without the .desktop
|
// Fix the Wayland appId. This needs to match the name of the .desktop file without the .desktop
|
||||||
// suffix.
|
// suffix.
|
||||||
QGuiApplication::setDesktopFileName(QStringLiteral("dev.eden_emu.eden"));
|
QGuiApplication::setDesktopFileName(QStringLiteral("dev.eden_emu.eden"));
|
||||||
|
|
|
@ -411,6 +411,9 @@ private slots:
|
||||||
void OnCreateHomeMenuApplicationMenuShortcut();
|
void OnCreateHomeMenuApplicationMenuShortcut();
|
||||||
void OnCaptureScreenshot();
|
void OnCaptureScreenshot();
|
||||||
void OnCheckFirmwareDecryption();
|
void OnCheckFirmwareDecryption();
|
||||||
|
#ifdef __unix__
|
||||||
|
void OnCheckGraphicsBackend();
|
||||||
|
#endif
|
||||||
void OnLanguageChanged(const QString& locale);
|
void OnLanguageChanged(const QString& locale);
|
||||||
void OnMouseActivity();
|
void OnMouseActivity();
|
||||||
bool OnShutdownBegin();
|
bool OnShutdownBegin();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue