From 37230107f4e9f72759780a3a90e4c546eb71e506 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 29 Mar 2025 18:59:54 +1000 Subject: [PATCH] FullscreenUI: Run idle while notifications/toasts are onscreen --- src/core/fullscreen_ui.cpp | 3 ++- src/util/imgui_fullscreen.cpp | 18 ++++++++++++++++++ src/util/imgui_fullscreen.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 39a5934eb..a99fe7658 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -766,7 +766,8 @@ bool FullscreenUI::AreAnyDialogsOpen() return (s_state.save_state_selector_open || s_state.input_binding_type != InputBindingInfo::Type::Unknown || ImGuiFullscreen::IsAnyFixedPopupDialogOpen() || ImGuiFullscreen::IsChoiceDialogOpen() || ImGuiFullscreen::IsInputDialogOpen() || ImGuiFullscreen::IsFileSelectorOpen() || - ImGuiFullscreen::IsMessageBoxDialogOpen()); + ImGuiFullscreen::IsMessageBoxDialogOpen() || ImGuiFullscreen::HasToast() || + ImGuiFullscreen::HasAnyNotifications()); } void FullscreenUI::CheckForConfigChanges(const GPUSettings& old_settings) diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index 49ee57d1b..85cbb35d7 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -20,6 +20,7 @@ #include "core/host.h" #include "core/system.h" // For async workers, should be in general host. +#include "core/fullscreen_ui.h" // For updating run idle state. #include "fmt/core.h" @@ -3445,6 +3446,12 @@ void ImGuiFullscreen::AddNotification(std::string key, float duration, std::stri notif.target_y = -1.0f; notif.last_y = -1.0f; s_state.notifications.push_back(std::move(notif)); + FullscreenUI::UpdateRunIdleState(); +} + +bool ImGuiFullscreen::HasAnyNotifications() +{ + return !s_state.notifications.empty(); } void ImGuiFullscreen::ClearNotifications() @@ -3585,6 +3592,10 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing) position.y += s_notification_vertical_direction * (box_height + shadow_size + spacing); index++; } + + // all gone? + if (s_state.notifications.empty()) + FullscreenUI::UpdateRunIdleState(); } void ImGuiFullscreen::ShowToast(std::string title, std::string message, float duration) @@ -3593,6 +3604,12 @@ void ImGuiFullscreen::ShowToast(std::string title, std::string message, float du s_state.toast_message = std::move(message); s_state.toast_start_time = Timer::GetCurrentValue(); s_state.toast_duration = duration; + FullscreenUI::UpdateRunIdleState(); +} + +bool ImGuiFullscreen::HasToast() +{ + return (!s_state.toast_title.empty() || !s_state.toast_message.empty()); } void ImGuiFullscreen::ClearToast() @@ -3601,6 +3618,7 @@ void ImGuiFullscreen::ClearToast() s_state.toast_title = {}; s_state.toast_start_time = 0; s_state.toast_duration = 0.0f; + FullscreenUI::UpdateRunIdleState(); } void ImGuiFullscreen::DrawToast() diff --git a/src/util/imgui_fullscreen.h b/src/util/imgui_fullscreen.h index 3b067514a..0505540db 100644 --- a/src/util/imgui_fullscreen.h +++ b/src/util/imgui_fullscreen.h @@ -407,9 +407,11 @@ void CloseLoadingScreen(); void RenderLoadingScreen(); void AddNotification(std::string key, float duration, std::string title, std::string text, std::string image_path); +bool HasAnyNotifications(); void ClearNotifications(); void ShowToast(std::string title, std::string message, float duration = 10.0f); +bool HasToast(); void ClearToast(); // Message callbacks.