Qt: Allow toggling fullscreen when VM is paused

This commit is contained in:
Stenzek 2024-01-20 20:24:28 +10:00
parent ecd8d97f72
commit 429cb4f351
No known key found for this signature in database
4 changed files with 28 additions and 7 deletions

View file

@ -322,7 +322,12 @@ void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
if (System::IsValid()) if (System::IsValid())
{ {
if (System::IsPaused()) if (System::IsPaused())
{
// 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.
System::InvalidateDisplay(); System::InvalidateDisplay();
System::InvalidateDisplay();
}
System::HostDisplayResized(); System::HostDisplayResized();
} }

View file

@ -1,14 +1,19 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "displaywidget.h" #include "displaywidget.h"
#include "common/assert.h"
#include "common/bitutils.h"
#include "common/log.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "qthost.h" #include "qthost.h"
#include "qtutils.h" #include "qtutils.h"
#include "core/fullscreen_ui.h"
#include "util/imgui_manager.h" #include "util/imgui_manager.h"
#include "common/assert.h"
#include "common/bitutils.h"
#include "common/log.h"
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QtGui/QKeyEvent> #include <QtGui/QKeyEvent>
@ -311,9 +316,12 @@ bool DisplayWidget::event(QEvent* event)
// don't toggle fullscreen when we're bound.. that wouldn't end well. // don't toggle fullscreen when we're bound.. that wouldn't end well.
if (event->type() == QEvent::MouseButtonDblClick && if (event->type() == QEvent::MouseButtonDblClick &&
static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton && static_cast<const QMouseEvent*>(event)->button() == Qt::LeftButton && QtHost::IsSystemValid() &&
!InputManager::HasAnyBindingsForKey(InputManager::MakePointerButtonKey(0, 0)) && QtHost::IsSystemValid() && !FullscreenUI::HasActiveWindow() &&
!QtHost::IsSystemPaused() && Host::GetBoolSettingValue("Main", "DoubleClickTogglesFullscreen", true)) ((!QtHost::IsSystemPaused() &&
!InputManager::HasAnyBindingsForKey(InputManager::MakePointerButtonKey(0, 0))) ||
(QtHost::IsSystemPaused() && !ImGuiManager::WantsMouseInput())) &&
Host::GetBoolSettingValue("Main", "DoubleClickTogglesFullscreen", true))
{ {
g_emu_thread->toggleFullscreen(); g_emu_thread->toggleFullscreen();
} }

View file

@ -892,6 +892,11 @@ bool ImGuiManager::WantsTextInput()
return s_imgui_wants_keyboard.load(std::memory_order_acquire); return s_imgui_wants_keyboard.load(std::memory_order_acquire);
} }
bool ImGuiManager::WantsMouseInput()
{
return s_imgui_wants_mouse.load(std::memory_order_acquire);
}
void ImGuiManager::AddTextInput(std::string str) void ImGuiManager::AddTextInput(std::string str)
{ {
if (!ImGui::GetCurrentContext()) if (!ImGui::GetCurrentContext())

View file

@ -69,6 +69,9 @@ ImFont* GetLargeFont();
/// Returns true if imgui wants to intercept text input. /// Returns true if imgui wants to intercept text input.
bool WantsTextInput(); 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. /// Called on the UI or CPU thread in response to a key press. String is UTF-8.
void AddTextInput(std::string str); void AddTextInput(std::string str);