From 3849ec449bd88fb147eebb741539905f0ed9668c Mon Sep 17 00:00:00 2001
From: Silent <zdanio95@gmail.com>
Date: Mon, 8 Mar 2021 20:16:38 +0100
Subject: [PATCH 1/2] Revert "CommonHostInterface: Use key-release to open
 quick menu"

This reverts commit e0161c3bb2f5e5f4e9d7f9569ba86010899c08c5.
---
 src/frontend-common/common_host_interface.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp
index 522e8dbea..55a36f608 100644
--- a/src/frontend-common/common_host_interface.cpp
+++ b/src/frontend-common/common_host_interface.cpp
@@ -1789,7 +1789,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
 {
   RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("OpenQuickMenu"),
                  TRANSLATABLE("Hotkeys", "Open Quick Menu"), [this](bool pressed) {
-                   if (!pressed && m_fullscreen_ui_enabled)
+                   if (pressed && m_fullscreen_ui_enabled)
                      FullscreenUI::OpenQuickMenu();
                  });
 

From 435a8485597e1412eeb9ddccb51f17b325c180ea Mon Sep 17 00:00:00 2001
From: Silent <zdanio95@gmail.com>
Date: Mon, 8 Mar 2021 20:42:32 +0100
Subject: [PATCH 2/2] FullscreenUI: Close menus on Cancel button edge only

Now requires the button to be released, THEN pressed
---
 src/frontend-common/fullscreen_ui.cpp | 30 ++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp
index 058b6f29e..f90575c64 100644
--- a/src/frontend-common/fullscreen_ui.cpp
+++ b/src/frontend-common/fullscreen_ui.cpp
@@ -62,7 +62,6 @@ using ImGuiFullscreen::EndFullscreenWindow;
 using ImGuiFullscreen::EndMenuButtons;
 using ImGuiFullscreen::EnumChoiceButton;
 using ImGuiFullscreen::FloatingButton;
-using ImGuiFullscreen::IsCancelButtonPressed;
 using ImGuiFullscreen::LayoutScale;
 using ImGuiFullscreen::MenuButton;
 using ImGuiFullscreen::MenuButtonFrame;
@@ -110,6 +109,7 @@ static bool s_debug_menu_allowed = false;
 static bool s_quick_menu_was_open = false;
 static bool s_was_paused_on_quick_menu_open = false;
 static bool s_about_window_open = false;
+static u32 s_close_button_state = 0;
 
 //////////////////////////////////////////////////////////////////////////
 // Resources
@@ -357,6 +357,7 @@ void SaveAndApplySettings()
 void ClearImGuiFocus()
 {
   ImGui::SetWindowFocus(nullptr);
+  s_close_button_state = 0;
 }
 
 void ReturnToMainWindow()
@@ -1179,6 +1180,25 @@ static bool ConfirmChallengeModeEnable()
   return true;
 }
 
+static bool WantsToCloseMenu()
+{
+  // Wait for the Close button to be released, THEN pressed
+  if (s_close_button_state == 0)
+  {
+    if (!ImGuiFullscreen::IsCancelButtonPressed())
+      s_close_button_state = 1;
+  }
+  else if (s_close_button_state == 1)
+  {
+    if (ImGuiFullscreen::IsCancelButtonPressed())
+    {
+      s_close_button_state = 0;
+      return true;
+    }
+  }
+  return false;
+}
+
 void DrawSettingsWindow()
 {
   BeginFullscreenColumns();
@@ -1201,7 +1221,7 @@ void DrawSettingsWindow()
     }
 
     ImGui::SetCursorPosY(ImGui::GetWindowHeight() - LayoutScale(50.0f));
-    if (ActiveButton(ICON_FA_BACKWARD "  Back", false) || IsCancelButtonPressed())
+    if (ActiveButton(ICON_FA_BACKWARD "  Back", false) || WantsToCloseMenu())
       ReturnToMainWindow();
 
     EndMenuButtons();
@@ -2346,7 +2366,7 @@ void DrawQuickMenu(MainWindowType type)
                      ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING,
                      ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
 
-    if (ActiveButton(ICON_FA_PLAY "  Resume Game", false) || IsCancelButtonPressed())
+    if (ActiveButton(ICON_FA_PLAY "  Resume Game", false) || WantsToCloseMenu())
       CloseQuickMenu();
 
     if (ActiveButton(ICON_FA_FAST_FORWARD "  Fast Forward", false))
@@ -2610,7 +2630,7 @@ void DrawSaveStateSelector(bool is_loading, bool fullscreen)
     ImGui::SetNextWindowSize(LayoutScale(1000.0f, 680.0f));
     ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
     ImGui::OpenPopup(window_title);
-    bool is_open = !IsCancelButtonPressed();
+    bool is_open = !WantsToCloseMenu();
     if (!ImGui::BeginPopupModal(window_title, &is_open,
                                 ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove) ||
         !is_open)
@@ -3945,7 +3965,7 @@ void DrawAchievementWindow()
       const u32 total_points = Cheevos::GetMaximumPointsForGame();
 
       if (FloatingButton(ICON_FA_WINDOW_CLOSE, 10.0f, 10.0f, -1.0f, -1.0f, 1.0f, 0.0f, true, g_large_font) ||
-          IsCancelButtonPressed())
+          WantsToCloseMenu())
       {
         ReturnToMainWindow();
       }