From 140fc28b3e25d296f816a430e621f060ae39f00c Mon Sep 17 00:00:00 2001 From: KamFretoZ <14798312+kamfretoz@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:41:54 +0700 Subject: [PATCH] FSUI: Allow toggling fullscreen when VM is paused --- pcsx2-qt/DisplayWidget.cpp | 6 ++++-- pcsx2-qt/QtHost.cpp | 2 +- pcsx2/ImGui/ImGuiManager.cpp | 5 +++++ pcsx2/ImGui/ImGuiManager.h | 3 +++ pcsx2/MTGS.cpp | 5 +++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pcsx2-qt/DisplayWidget.cpp b/pcsx2-qt/DisplayWidget.cpp index 54493b1961..36084419bb 100644 --- a/pcsx2-qt/DisplayWidget.cpp +++ b/pcsx2-qt/DisplayWidget.cpp @@ -6,6 +6,7 @@ #include "QtHost.h" #include "QtUtils.h" +#include "pcsx2/ImGui/FullscreenUI.h" #include "pcsx2/ImGui/ImGuiManager.h" #include "common/Assertions.h" @@ -323,8 +324,9 @@ bool DisplayWidget::event(QEvent* event) // don't toggle fullscreen when we're bound.. that wouldn't end well. if (event->type() == QEvent::MouseButtonDblClick && static_cast(event)->button() == Qt::LeftButton && - QtHost::IsVMValid() && !QtHost::IsVMPaused() && - !InputManager::HasAnyBindingsForKey(InputManager::MakePointerButtonKey(0, 0)) && + QtHost::IsVMValid() && !FullscreenUI::HasActiveWindow() && + ((!QtHost::IsVMPaused() && !InputManager::HasAnyBindingsForKey(InputManager::MakePointerButtonKey(0, 0))) || + (QtHost::IsVMPaused() && !ImGuiManager::WantsMouseInput())) && Host::GetBoolSettingValue("UI", "DoubleClickTogglesFullscreen", true)) { g_emu_thread->toggleFullscreen(); diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index e9d3271801..3fbb94b1f3 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -497,7 +497,7 @@ void EmuThread::setFullscreen(bool fullscreen, bool allow_render_to_main) MTGS::WaitGS(); // If we're using exclusive fullscreen, the refresh rate may have changed. - UpdateVSyncRate(true); + VMManager::UpdateTargetSpeed(); } void EmuThread::setSurfaceless(bool surfaceless) diff --git a/pcsx2/ImGui/ImGuiManager.cpp b/pcsx2/ImGui/ImGuiManager.cpp index 1383bbcf43..112521a0c3 100644 --- a/pcsx2/ImGui/ImGuiManager.cpp +++ b/pcsx2/ImGui/ImGuiManager.cpp @@ -836,6 +836,11 @@ bool ImGuiManager::WantsTextInput() return s_imgui_wants_text.load(std::memory_order_acquire); } +bool ImGuiManager::WantsMouseInput() +{ + return s_imgui_wants_mouse.load(std::memory_order_acquire); +} + void ImGuiManager::AddTextInput(std::string str) { if (!s_imgui_wants_text.load(std::memory_order_acquire)) diff --git a/pcsx2/ImGui/ImGuiManager.h b/pcsx2/ImGui/ImGuiManager.h index de440850cc..05efa9577e 100644 --- a/pcsx2/ImGui/ImGuiManager.h +++ b/pcsx2/ImGui/ImGuiManager.h @@ -72,6 +72,9 @@ namespace ImGuiManager /// Returns true if imgui wants to intercept text input. bool WantsTextInput(); + /// Returns true if imgui wants to intercept mouse input. + bool WantsMouseInput(); + /// Called on the UI or CPU thread in response to a key press. String is UTF-8. void AddTextInput(std::string str); diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index d127e1046a..b182c4cb83 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -963,7 +963,12 @@ void MTGS::UpdateDisplayWindow() // If we're paused, re-present the current frame at the new window size. if (VMManager::GetState() == VMState::Paused) + { + // Hackity hack, on some systems, presenting a single frame isn't enough to actually get it + // displayed. Two seems to be good enough. Maybe something to do with direct scanout. GSPresentCurrentFrame(); + GSPresentCurrentFrame(); + } }); }