From 920f25427e8155bd1a08f424137d9613c27fefc9 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 4 Jan 2025 16:09:31 +1000 Subject: [PATCH] Qt: Simplify Fullscreen UI state tracking Fixes application closing if the system was shut down while fullscreen. --- src/core/fullscreen_ui.cpp | 4 ---- src/core/fullscreen_ui.h | 3 --- src/duckstation-qt/qthost.cpp | 20 ++++++-------------- src/duckstation-qt/qthost.h | 1 - src/duckstation-regtest/regtest_host.cpp | 5 ----- 5 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 1e0b506e0..813fd07a5 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -602,8 +602,6 @@ bool FullscreenUI::Initialize() s_state.initialized = true; s_state.hotkey_list_cache = InputManager::GetHotkeyList(); - Host::RunOnCPUThread([]() { Host::OnFullscreenUIStartedOrStopped(true); }); - if (s_state.current_main_window == MainWindowType::None && !GPUThread::HasGPUBackend() && !GPUThread::IsGPUBackendRequested()) { @@ -830,8 +828,6 @@ void FullscreenUI::Shutdown(bool clear_state) DestroyResources(); ImGuiFullscreen::Shutdown(clear_state); - if (s_state.initialized) - Host::RunOnCPUThread([]() { Host::OnFullscreenUIStartedOrStopped(false); }); s_state.initialized = false; s_state.tried_to_initialize = false; diff --git a/src/core/fullscreen_ui.h b/src/core/fullscreen_ui.h index 304023b61..715f084cf 100644 --- a/src/core/fullscreen_ui.h +++ b/src/core/fullscreen_ui.h @@ -82,9 +82,6 @@ namespace Host { #ifndef __ANDROID__ -/// Called whenever fullscreen UI starts/stops. -void OnFullscreenUIStartedOrStopped(bool started); - /// Requests shut down and exit of the hosting application. This may not actually exit, /// if the user cancels the shutdown confirmation. void RequestExitApplication(bool allow_confirm); diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 2282b9cce..a8238e858 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -743,6 +743,9 @@ void EmuThread::startFullscreenUI() Host::ReportErrorAsync("Error", error.GetDescription()); return; } + + m_is_fullscreen_ui_started = true; + emit fullscreenUIStartedOrStopped(true); } void EmuThread::stopFullscreenUI() @@ -758,7 +761,10 @@ void EmuThread::stopFullscreenUI() } if (m_is_fullscreen_ui_started) + { GPUThread::StopFullscreenUI(); + emit fullscreenUIStartedOrStopped(false); + } } void EmuThread::bootSystem(std::shared_ptr params) @@ -1023,11 +1029,6 @@ void Host::OnSystemDestroyed() emit g_emu_thread->systemDestroyed(); } -void Host::OnFullscreenUIStartedOrStopped(bool started) -{ - g_emu_thread->setFullscreenUIStarted(started); -} - void Host::OnGPUThreadRunIdleChanged(bool is_active) { g_emu_thread->setGPUThreadRunIdle(is_active); @@ -1823,15 +1824,6 @@ void EmuThread::setGPUThreadRunIdle(bool active) g_emu_thread->startBackgroundControllerPollTimer(); } -void EmuThread::setFullscreenUIStarted(bool started) -{ - if (m_is_fullscreen_ui_started == started) - return; - - m_is_fullscreen_ui_started = started; - emit fullscreenUIStartedOrStopped(started); -} - void EmuThread::start() { AssertMsg(!g_emu_thread, "Emu thread does not exist"); diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h index 9f1f04375..095ba881d 100644 --- a/src/duckstation-qt/qthost.h +++ b/src/duckstation-qt/qthost.h @@ -103,7 +103,6 @@ public: void startBackgroundControllerPollTimer(); void stopBackgroundControllerPollTimer(); - void setFullscreenUIStarted(bool started); void wakeThread(); bool shouldRenderToMain() const; diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index 034728929..a1ad2d13f 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -296,11 +296,6 @@ void Host::OnGPUThreadRunIdleChanged(bool is_active) // } -void Host::OnFullscreenUIStartedOrStopped(bool started) -{ - // -} - void Host::OnPerformanceCountersUpdated(const GPUBackend* gpu_backend) { //