From 1c4a33cc55ffbbecfd481a26f10c9d297cbc2dcf Mon Sep 17 00:00:00 2001 From: Collecting Date: Sun, 4 Jan 2026 18:42:34 +0000 Subject: [PATCH] fix(overhaul): UI and resolution bugs for Steam Deck (Gamescope) Signed-off-by: Collecting --- src/citron/controller_overlay.cpp | 33 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/citron/controller_overlay.cpp b/src/citron/controller_overlay.cpp index 52ccb9af7..f0f69a9bd 100644 --- a/src/citron/controller_overlay.cpp +++ b/src/citron/controller_overlay.cpp @@ -28,10 +28,8 @@ Core::HID::EmulatedController* GetPlayer1Controller(Core::System* system) { return hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); } -// Helper to detect Gamescope at runtime bool IsGamescope() { - static bool gamescope = qgetenv("XDG_CURRENT_DESKTOP") == "gamescope" || - !qgetenv("GAMESCOPE_WIDTH").isEmpty(); + static bool gamescope = qgetenv("XDG_CURRENT_DESKTOP") == "gamescope"; return gamescope; } } @@ -83,24 +81,28 @@ ControllerOverlay::ControllerOverlay(GMainWindow* parent) ControllerOverlay::~ControllerOverlay() = default; void ControllerOverlay::UpdateControllerState() { - if (!main_window) return; + if (!main_window || !is_enabled) return; if (IsGamescope()) { - bool sub_window_visible = false; + bool ui_active = false; for (QWidget* w : QApplication::topLevelWidgets()) { if (w->isWindow() && w->isVisible() && w != main_window && w != this && - !w->inherits("GRenderWindow") && !w->inherits("PerformanceOverlay") && !w->inherits("VramOverlay")) { - sub_window_visible = true; - break; - } + !w->inherits("GRenderWindow") && + !w->inherits("PerformanceOverlay") && + !w->inherits("VramOverlay") && + !w->inherits("ControllerOverlay")) { + ui_active = true; + break; + } } - if (sub_window_visible) { + + if (ui_active) { if (!this->isHidden()) this->hide(); return; } } - if (this->isHidden()) { + if (is_enabled && this->isHidden()) { this->show(); } @@ -156,3 +158,12 @@ void ControllerOverlay::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); layout()->update(); } + +void ControllerOverlay::SetVisible(bool visible) { + is_enabled = visible; + if (visible) { + this->show(); + } else { + this->hide(); + } +}