From 8784ece623aea66b7077d9d32ace4c53586d139e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 12 Sep 2023 10:25:04 +0200 Subject: [PATCH] Fix the chat window closing on pressing the X key. It's better to handle the chat window on the queued event path. --- UI/EmuScreen.cpp | 26 ++++++++++++++++---------- UI/EmuScreen.h | 3 +++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index d82ed51ae39d..09ddf8141169 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -844,21 +844,27 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) { System_Notify(SystemNotification::ACTIVITY); if (UI::IsFocusMovementEnabled()) { - bool retval = UIScreen::UnsyncKey(key); - if ((key.flags & KEY_DOWN) != 0 && UI::IsEscapeKey(key)) { - if (chatMenu_) - chatMenu_->Close(); - if (chatButton_) - chatButton_->SetVisibility(UI::V_VISIBLE); - UI::EnableFocusMovement(false); - retval = true; - } - return retval; + return UIScreen::UnsyncKey(key); } return controlMapper_.Key(key, &pauseTrigger_); } +bool EmuScreen::key(const KeyInput &key) { + bool retval = UIScreen::key(key); + + if (!retval && (key.flags & KEY_DOWN) != 0 && UI::IsEscapeKey(key)) { + if (chatMenu_) + chatMenu_->Close(); + if (chatButton_) + chatButton_->SetVisibility(UI::V_VISIBLE); + UI::EnableFocusMovement(false); + return true; + } + + return retval; +} + void EmuScreen::UnsyncAxis(const AxisInput &axis) { System_Notify(SystemNotification::ACTIVITY); return controlMapper_.Axis(axis); diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 3f07f3d78993..970844ba186b 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -55,6 +55,9 @@ class EmuScreen : public UIScreen { bool UnsyncKey(const KeyInput &key) override; void UnsyncAxis(const AxisInput &axis) override; + // We also need to do some special handling of queued UI events to handle closing the chat window. + bool key(const KeyInput &key) override; + private: void CreateViews() override; UI::EventReturn OnDevTools(UI::EventParams ¶ms);