diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index 65d3e3b6c..28d3a815b 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -115,8 +115,8 @@ void BasicGameListView::setCursor(FileData* cursor) populateList(cursor->getParent()->getChildrenListToDisplay(), cursor->getParent()); mList.setCursor(cursor); - // Update our cursor stack in case our cursor just - // got set to some folder we weren't in before. + // Update our cursor stack in case our cursor just got set to some folder + // we weren't in before. if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) { std::stack tmp; FileData* ptr = cursor->getParent(); diff --git a/es-app/src/views/gamelist/BasicGameListView.h b/es-app/src/views/gamelist/BasicGameListView.h index 7bd84f1e0..414bbf8c8 100644 --- a/es-app/src/views/gamelist/BasicGameListView.h +++ b/es-app/src/views/gamelist/BasicGameListView.h @@ -23,7 +23,7 @@ public: virtual void onThemeChanged(const std::shared_ptr& theme) override; virtual FileData* getCursor() override; - virtual void setCursor(FileData* file) override; + virtual void setCursor(FileData* cursor) override; virtual FileData* getNextEntry() override; virtual FileData* getPreviousEntry() override; virtual FileData* getFirstEntry() override; diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index c6992285f..d14ded520 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -171,11 +171,29 @@ FileData* GridGameListView::getCursor() return mGrid.getSelected(); } -void GridGameListView::setCursor(FileData* file) +void GridGameListView::setCursor(FileData* cursor) { - if (!mGrid.setCursor(file) && (!file->isPlaceHolder())) { - populateList(file->getParent()->getChildrenListToDisplay(), file->getParent()); - mGrid.setCursor(file); + if (!mGrid.setCursor(cursor) && (!cursor->isPlaceHolder())) { + populateList(cursor->getParent()->getChildrenListToDisplay(), cursor->getParent()); + mGrid.setCursor(cursor); + + // Update our cursor stack in case our cursor just got set to some folder + // we weren't in before. + if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) { + std::stack tmp; + FileData* ptr = cursor->getParent(); + while (ptr && ptr != mRoot) { + tmp.push(ptr); + ptr = ptr->getParent(); + } + + // Flip the stack and put it in mCursorStack. + mCursorStack = std::stack(); + while (!tmp.empty()) { + mCursorStack.push(tmp.top()); + tmp.pop(); + } + } } } diff --git a/es-app/src/views/gamelist/GridGameListView.h b/es-app/src/views/gamelist/GridGameListView.h index 058b85d7b..e72036d15 100644 --- a/es-app/src/views/gamelist/GridGameListView.h +++ b/es-app/src/views/gamelist/GridGameListView.h @@ -30,7 +30,7 @@ public: virtual void onThemeChanged(const std::shared_ptr& theme) override; virtual FileData* getCursor() override; - virtual void setCursor(FileData*) override; + virtual void setCursor(FileData* cursor) override; virtual FileData* getNextEntry() override; virtual FileData* getPreviousEntry() override; virtual FileData* getFirstEntry() override;