Compare commits

..

1 commit

Author SHA1 Message Date
a0e3f67488
WIP: Add option to FORCE_X11 Graphics Backend
Some checks failed
eden-license / license-header (pull_request) Failing after 20s
Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
2025-09-28 17:35:44 -03:00
6 changed files with 73 additions and 50 deletions

View file

@ -643,10 +643,8 @@ struct Values {
// 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
InputSetting<std::array<PlayerInput, 10>> players;

View file

@ -1,25 +1,43 @@
// 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"
#include <QSettings>
namespace FS = Common::FS;
namespace GraphicsBackend {
namespace GUISettings {
QString GuiConfigPath() {
return QString::fromStdString(FS::PathToUTF8String(FS::GetEdenPath(FS::EdenPath::ConfigDir) / "gui_config.ini"));
Values values;
void SaveGUISettings() {
const auto gui_config_path =
FS::PathToUTF8String(FS::GetEdenPath(FS::EdenPath::ConfigDir) / "gui_config.ini");
(void)FS::CreateParentDir(gui_config_path);
QSettings config(QString::fromStdString(gui_config_path), QSettings::IniFormat);
config.beginGroup(QStringLiteral("Linux"));
config.setValue(QStringLiteral("gui_force_x11"), values.gui_force_x11.GetValue());
config.setValue(QStringLiteral("gui_hide_backend_warning"), values.gui_hide_backend_warning.GetValue());
config.endGroup();
config.sync();
}
void SetForceX11(bool state) {
(void)FS::CreateParentDir(GuiConfigPath().toStdString());
QSettings(GuiConfigPath(), QSettings::IniFormat).setValue("gui_force_x11", state);
void RestoreGUISettings() {
const auto gui_config_path =
FS::PathToUTF8String(FS::GetEdenPath(FS::EdenPath::ConfigDir) / "gui_config.ini");
if (!FS::Exists(gui_config_path))
return;
QSettings config(QString::fromStdString(gui_config_path), QSettings::IniFormat);
config.beginGroup(QStringLiteral("GUILinux"));
values.gui_force_x11.SetValue(config.value(QStringLiteral("gui_force_x11"), false).toBool());
values.gui_hide_backend_warning.SetValue(config.value(QStringLiteral("gui_hide_backend_warning"), false).toBool());
config.endGroup();
}
bool GetForceX11() {
return QSettings(GuiConfigPath(), QSettings::IniFormat).value("gui_force_x11", false).toBool();
}
} // namespace GUISettings
} // namespace GraphicsBackend

View file

@ -1,14 +1,27 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "common/settings.h"
#include <QSettings>
#include <QString>
namespace GUISettings {
namespace GraphicsBackend {
using namespace Settings;
void SetForceX11(bool state);
bool GetForceX11();
struct Values {
Settings::Linkage gui_linkage;
SwitchableSetting<bool> gui_force_x11;
Setting<bool> gui_hide_backend_warning;
Values()
: gui_force_x11(gui_linkage, false, "gui_force_x11", Settings::Category::Linux),
gui_hide_backend_warning(gui_linkage, false, "gui_hide_backend_warning", Settings::Category::Linux)
{
}
};
extern Values values;
void SaveGUISettings();
void RestoreGUISettings();
} // namespace GUISettings
} // namespace GraphicsBackend

View file

@ -15,6 +15,9 @@
#include "common/settings_setting.h"
#include "common/time_zone.h"
#include "qt_common/uisettings.h"
#ifdef __unix__
#include "qt_common/gui_settings.h"
#endif
#include <map>
#include <memory>
#include <utility>

View file

@ -546,7 +546,7 @@ GMainWindow::GMainWindow(bool has_broken_vulkan)
OnCheckFirmwareDecryption();
#ifdef __unix__
OnCheckGraphicsBackend();
OnCheckBackend();
#endif
game_list->LoadCompatibilityList();
@ -3425,9 +3425,6 @@ 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(),
@ -3492,11 +3489,6 @@ 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();
@ -4462,26 +4454,22 @@ void GMainWindow::OnCheckFirmwareDecryption() {
}
#ifdef __unix__
void GMainWindow::OnCheckGraphicsBackend() {
const QString platformName = QGuiApplication::platformName();
const QByteArray qtPlatform = qgetenv("QT_QPA_PLATFORM");
void GMainWindow::OnCheckBackend() {
QByteArray qtPlatform = qgetenv("QT_QPA_PLATFORM");
bool isWayland = qtPlatform.isEmpty() || qtPlatform == "wayland" || qtPlatform == "wayland-egl";
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();
const bool currently_hidden = GUISettings::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.setWindowTitle(tr("Wayland Detected"));
msgbox.setText(tr("You are running Eden under Wayland.\n"
"Some features may not work correctly.\n"
"It is recommended to use X11 for the best compatibility."));
msgbox.setIcon(QMessageBox::Warning);
QPushButton* okButton = msgbox.addButton(tr("Use X11"), QMessageBox::AcceptRole);
@ -4496,12 +4484,14 @@ void GMainWindow::OnCheckGraphicsBackend() {
const bool hide = cb->isChecked();
if (hide != currently_hidden) {
Settings::values.gui_hide_backend_warning.SetValue(hide);
GUISettings::values.gui_hide_backend_warning.SetValue(hide);
GUISettings::SaveGUISettings();
}
if (msgbox.clickedButton() == okButton) {
Settings::values.gui_force_x11.SetValue(true);
GraphicsBackend::SetForceX11(true);
GUISettings::values.gui_force_x11.SetValue(true);
GUISettings::SaveGUISettings();
QMessageBox::information(this,
tr("Restart Required"),
tr("Restart Eden to apply the X11 backend."));
@ -4998,7 +4988,8 @@ int main(int argc, char* argv[]) {
qputenv("DISPLAY", ":0");
}
if (GraphicsBackend::GetForceX11())
GUISettings::RestoreGUISettings();
if (GUISettings::values.gui_force_x11.GetValue())
qputenv("QT_QPA_PLATFORM", "xcb");
// Fix the Wayland appId. This needs to match the name of the .desktop file without the .desktop

View file

@ -412,7 +412,7 @@ private slots:
void OnCaptureScreenshot();
void OnCheckFirmwareDecryption();
#ifdef __unix__
void OnCheckGraphicsBackend();
void OnCheckBackend();
#endif
void OnLanguageChanged(const QString& locale);
void OnMouseActivity();