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(); + } +}