Skip to content

Commit

Permalink
FSUI: Allow toggling fullscreen when VM is paused
Browse files Browse the repository at this point in the history
  • Loading branch information
kamfretoz authored and stenzek committed Jan 13, 2024
1 parent f9833bb commit 140fc28
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pcsx2-qt/DisplayWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "QtHost.h"
#include "QtUtils.h"

#include "pcsx2/ImGui/FullscreenUI.h"
#include "pcsx2/ImGui/ImGuiManager.h"

#include "common/Assertions.h"
Expand Down Expand Up @@ -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<const QMouseEvent*>(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();
Expand Down
2 changes: 1 addition & 1 deletion pcsx2-qt/QtHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pcsx2/ImGui/ImGuiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions pcsx2/ImGui/ImGuiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions pcsx2/MTGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}

Expand Down

0 comments on commit 140fc28

Please sign in to comment.