From ef72f27fea4f9dc1fcb4cee7a35bd59dbd12211d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 14 Oct 2026 11:00:00 +0200 Subject: [PATCH] Game browser: Keep the search and focus when returning from a game FocusGame cleared the path to focus right after setting it, so since the refresh became deferred nothing got refocused. The refresh also showed every game again while the search bar still showed the filter. Now an existing button is focused directly, without a refresh, and a refresh reapplies an active search filter. Co-Authored-By: Claude Opus 5.5 (1M context) --- UI/GameBrowser.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/UI/GameBrowser.cpp b/UI/GameBrowser.cpp index 5e6d9a602f..b7a5c00cc0 100644 --- a/UI/GameBrowser.cpp +++ b/UI/GameBrowser.cpp @@ -742,9 +742,19 @@ GameBrowser::GameBrowser(int token, const Path &path, BrowseFlags browseFlags, b } void GameBrowser::FocusGame(const Path &gamePath) { + // If the button's still there, just focus it. That keeps the search results and scroll position. + if (gameList_) { + for (int i = 0; i < gameList_->GetNumSubviews(); i++) { + GameButton *button = dynamic_cast(gameList_->GetViewByIndex(i)); + if (button && button->GamePath() == gamePath && button->GetVisibility() == UI::V_VISIBLE) { + button->SetFocus(UI::FocusFlags::CAUSE_RESTORE); + return; + } + } + } + // Otherwise, Refresh focuses it when it recreates the buttons. focusGamePath_ = gamePath; refreshPending_ = true; - focusGamePath_.clear(); } void GameBrowser::SetPath(const Path &path) { @@ -1143,6 +1153,7 @@ void GameBrowser::Refresh() { b->SetFocus(FocusFlags::CAUSE_RESTORE); } } + focusGamePath_.clear(); // Show a button to toggle pinning at the very end. if ((browseFlags_ & BrowseFlags::PIN) && !path_.GetPath().empty()) { @@ -1163,6 +1174,11 @@ void GameBrowser::Refresh() { Add(new Spacer()); Add(new Choice(lastText_, ImageID("I_LINK_OUT"), new UI::LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT, Margins(10, 0, 0, 10))))->OnClick.Handle(this, &GameBrowser::LastClick); } + + // The new buttons are all visible, so filter them again if a search is active. + if (!search_.searchFilter.empty()) { + search_.ApplySearchFilter(gameList_, false); + } } bool GameBrowser::IsCurrentPathPinned() {