diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index e5d8fef940..ed723aba67 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -172,7 +172,7 @@ bool UIDialogScreen::key(const KeyInput &key) { if (!retval && (key.flags & KeyInputFlags::DOWN) && UI::IsEscapeKey(key)) { if (finished_) { ERROR_LOG(Log::System, "Screen already finished"); - } else { + } else if (!firstFrame_) { finished_ = true; TriggerFinish(DR_BACK); UI::PlayUISound(UI::UISound::BACK); diff --git a/Common/UI/UIScreen.h b/Common/UI/UIScreen.h index de162797d6..7202455124 100644 --- a/Common/UI/UIScreen.h +++ b/Common/UI/UIScreen.h @@ -79,9 +79,15 @@ class UIDialogScreen : public UIScreen { public: UIDialogScreen() : UIScreen(), finished_(false) {} ~UIDialogScreen() override; + void update() override { + UIScreen::update(); + firstFrame_ = false; + } bool key(const KeyInput &key) override; void sendMessage(UIMessage message, const char *value) override; +protected: + bool firstFrame_ = true; // Since back button can toggle this screen, we need to make sure we don't immediately pop it on the first frame. private: bool finished_; }; diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 22cafec1a3..a2ef1a141b 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -333,11 +333,13 @@ void SaveSlotView::OnSaveState(UI::EventParams &e) { void GamePauseScreen::update() { UpdateUIState(UISTATE_PAUSEMENU); - UIScreen::update(); - if (g_controlMapper.PollPauseTrigger()) { + if (!firstFrame_ && g_controlMapper.PollPauseTrigger()) { TriggerFinish(DR_BACK); } + UIScreen::update(); + + firstFrame_ = false; if (finishNextFrame_) { TriggerFinish(finishNextFrameResult_);