diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index 7126d2a19..f6feceaea 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -628,6 +628,8 @@ void FullscreenUI::Render() GetEditingSettingsInterface()->Save(); Host::RunOnCPUThread([]() { System::ApplySettings(false); }); } + + ImGuiFullscreen::ResetCloseMenuIfNeeded(); } void FullscreenUI::ReturnToMainWindow() @@ -2066,7 +2068,7 @@ void FullscreenUI::DrawSettingsWindow() { ResetFocusHere(); - if (ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Pressed)) + if (WantsToCloseMenu()) { if (ImGui::IsWindowFocused()) ReturnToMainWindow(); diff --git a/src/frontend-common/imgui_fullscreen.cpp b/src/frontend-common/imgui_fullscreen.cpp index a7da61d72..5a6c323ac 100644 --- a/src/frontend-common/imgui_fullscreen.cpp +++ b/src/frontend-common/imgui_fullscreen.cpp @@ -474,18 +474,26 @@ bool ImGuiFullscreen::WantsToCloseMenu() // Wait for the Close button to be released, THEN pressed if (s_close_button_state == 0) { - if (!IsCancelButtonPressed()) + if (ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Pressed)) s_close_button_state = 1; } else if (s_close_button_state == 1) { - if (IsCancelButtonPressed()) + if (ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Released)) { - s_close_button_state = 0; - return true; + s_close_button_state = 2; } } - return false; + return s_close_button_state > 1; +} + +void ImGuiFullscreen::ResetCloseMenuIfNeeded() +{ + // If s_close_button_state reached the "Released" state, reset it after the tick + if (s_close_button_state > 1) + { + s_close_button_state = 0; + } } void ImGuiFullscreen::PushPrimaryColor() @@ -516,11 +524,6 @@ void ImGuiFullscreen::PopSecondaryColor() ImGui::PopStyleColor(5); } -bool ImGuiFullscreen::IsCancelButtonPressed() -{ - return ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Pressed); -} - bool ImGuiFullscreen::BeginFullscreenColumns(const char* title) { ImGui::SetNextWindowPos(ImVec2(g_layout_padding_left, 0.0f)); @@ -1639,7 +1642,7 @@ void ImGuiFullscreen::DrawFileSelector() ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor); ImGui::PushStyleColor(ImGuiCol_PopupBg, UIBackgroundColor); - bool is_open = !IsCancelButtonPressed(); + bool is_open = !WantsToCloseMenu(); bool directory_selected = false; if (ImGui::BeginPopupModal(s_file_selector_title.c_str(), &is_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) @@ -1759,7 +1762,7 @@ void ImGuiFullscreen::DrawChoiceDialog() ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor); ImGui::PushStyleColor(ImGuiCol_PopupBg, UIBackgroundColor); - bool is_open = !IsCancelButtonPressed(); + bool is_open = !WantsToCloseMenu(); s32 choice = -1; if (ImGui::BeginPopupModal(s_choice_dialog_title.c_str(), &is_open, diff --git a/src/frontend-common/imgui_fullscreen.h b/src/frontend-common/imgui_fullscreen.h index bfe0d095d..192bfc9d8 100644 --- a/src/frontend-common/imgui_fullscreen.h +++ b/src/frontend-common/imgui_fullscreen.h @@ -128,14 +128,13 @@ void EndLayout(); void QueueResetFocus(); bool ResetFocusHere(); bool WantsToCloseMenu(); +void ResetCloseMenuIfNeeded(); void PushPrimaryColor(); void PopPrimaryColor(); void PushSecondaryColor(); void PopSecondaryColor(); -bool IsCancelButtonPressed(); - void DrawWindowTitle(const char* title); bool BeginFullscreenColumns(const char* title = nullptr);