From 935e04370a7063d5a93bfdd47a48eeb575eef829 Mon Sep 17 00:00:00 2001 From: collecting Date: Mon, 29 Sep 2025 04:48:30 +0000 Subject: [PATCH] feat: Wayland UI Linux Option: Performance Optimizations --- .../configuration/configure_general.cpp | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/citron/configuration/configure_general.cpp b/src/citron/configuration/configure_general.cpp index 63e77b148..faeb65e4f 100644 --- a/src/citron/configuration/configure_general.cpp +++ b/src/citron/configuration/configure_general.cpp @@ -1,6 +1,9 @@ // SPDX-FileCopyrightText: 2016 Citra Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include #include #include #include @@ -54,9 +57,9 @@ void ConfigureGeneral::Setup(const ConfigurationShared::Builder& builder) { push(Settings::values.linkage.by_category[Settings::Category::Linux]); // Only show Linux group on Unix -#ifndef __unix__ + #ifndef __unix__ ui->LinuxGroupBox->setVisible(false); -#endif + #endif for (const auto setting : settings) { auto* widget = builder.BuildWidget(setting, apply_funcs); @@ -70,14 +73,14 @@ void ConfigureGeneral::Setup(const ConfigurationShared::Builder& builder) { } switch (setting->GetCategory()) { - case Settings::Category::UiGeneral: - general_hold.emplace(setting->Id(), widget); - break; - case Settings::Category::Linux: - linux_hold.emplace(setting->Id(), widget); - break; - default: - widget->deleteLater(); + case Settings::Category::UiGeneral: + general_hold.emplace(setting->Id(), widget); + break; + case Settings::Category::Linux: + linux_hold.emplace(setting->Id(), widget); + break; + default: + widget->deleteLater(); } } @@ -87,6 +90,27 @@ void ConfigureGeneral::Setup(const ConfigurationShared::Builder& builder) { for (const auto& [id, widget] : linux_hold) { linux_layout.addWidget(widget); } + + // --- Manually add Wayland setting to the Linux UI group --- + #ifdef __linux__ + // This logic only runs if the user is on a Wayland session. + if (QGuiApplication::platformName().startsWith(QStringLiteral("wayland"))) { + // Create a new, clean checkbox. + auto wayland_checkbox = new QCheckBox(tr("Enable Wayland Performance Optimizations")); + wayland_checkbox->setToolTip(tr("Use Wayland-specific presentation modes to reduce input latency and improve smoothness.")); + + // Set its initial checked state from our hidden setting. + wayland_checkbox->setChecked(Settings::values.is_wayland_platform.GetValue()); + + // Connect the checkbox so it toggles our hidden setting. + connect(wayland_checkbox, &QCheckBox::toggled, this, [](bool checked) { + Settings::values.is_wayland_platform.SetValue(checked); + }); + + // Add our new, clean checkbox to the Linux layout. + linux_layout.addWidget(wayland_checkbox); + } + #endif } // Called to set the callback when resetting settings to defaults