Qt: Implement pause on start

This commit is contained in:
Connor McLaughlin 2022-06-28 22:37:10 +10:00 committed by refractionpcsx2
parent 63163737c2
commit dedb1e0c80
4 changed files with 35 additions and 2 deletions

View File

@ -114,7 +114,18 @@ void EmuThread::startVM(std::shared_ptr<VMBootParameters> boot_params)
if (!VMManager::Initialize(*boot_params))
return;
VMManager::SetState(VMState::Running);
if (!Host::GetBoolSettingValue("UI", "StartPaused", false))
{
// This will come back and call OnVMResumed().
VMManager::SetState(VMState::Running);
}
else
{
// When starting paused, redraw the window, so there's at least something there.
redrawDisplayWindow();
Host::OnVMPaused();
}
m_event_loop->quit();
}
@ -609,6 +620,21 @@ void EmuThread::onDisplayWindowResized(int width, int height, float scale)
void EmuThread::onDisplayWindowFocused() {}
void EmuThread::redrawDisplayWindow()
{
if (!isOnEmuThread())
{
QMetaObject::invokeMethod(this, &EmuThread::redrawDisplayWindow, Qt::QueuedConnection);
return;
}
// If we're running, we're going to re-present anyway.
if (!VMManager::HasValidVM() || VMManager::GetState() == VMState::Running)
return;
GetMTGS().RunOnGSThread([]() { GetMTGS().PresentCurrentFrame(); });
}
void EmuThread::runOnCPUThread(const std::function<void()>& func)
{
func();

View File

@ -146,6 +146,7 @@ private Q_SLOTS:
void doBackgroundControllerPoll();
void onDisplayWindowResized(int width, int height, float scale);
void onDisplayWindowFocused();
void redrawDisplayWindow();
private:
QThread* m_ui_thread;

View File

@ -117,7 +117,6 @@ InterfaceSettingsWidget::InterfaceSettingsWidget(SettingsDialog* dialog, QWidget
tr("Hides the main window (with the game list) when a game is running, requires Render To Separate Window to be enabled."));
// Not yet used, disable the options
m_ui.pauseOnStart->setDisabled(true);
m_ui.pauseOnFocusLoss->setDisabled(true);
m_ui.language->setDisabled(true);

View File

@ -27,6 +27,10 @@
#include "common/Timer.h"
#include "imgui.h"
#ifdef PCSX2_CORE
#include "imgui_internal.h"
#endif
#include "Config.h"
#include "Counters.h"
#include "Frontend/ImGuiManager.h"
@ -198,6 +202,9 @@ void ImGuiManager::NewFrame()
ImGui::NewFrame();
#ifdef PCSX2_CORE
// Disable nav input on the implicit (Debug##Default) window. Otherwise we end up requesting keyboard
// focus when there's nothing there. We use GetCurrentWindowRead() because otherwise it'll make it visible.
ImGui::GetCurrentWindowRead()->Flags |= ImGuiWindowFlags_NoNavInputs;
s_imgui_wants_keyboard.store(io.WantCaptureKeyboard, std::memory_order_relaxed);
s_imgui_wants_mouse.store(io.WantCaptureMouse, std::memory_order_release);
#endif