From 6c19b5947be6ca32c15d5ddb58a68644cc034a4b Mon Sep 17 00:00:00 2001 From: spycrab Date: Fri, 8 Jun 2018 19:59:24 +0200 Subject: [PATCH 1/2] Qt: Fix exclusive fullscreen not being entered on startup --- Source/Core/DolphinQt2/MainWindow.cpp | 17 ++++++++++------- Source/Core/DolphinQt2/MainWindow.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index befa0f6ca4..0a49b5f9be 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -209,6 +209,12 @@ void MainWindow::InitCoreCallbacks() connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [=](Core::State state) { if (state == Core::State::Uninitialized) OnStopComplete(); + + if (state == Core::State::Running && m_fullscreen_requested) + { + FullScreen(); + m_fullscreen_requested = false; + } }); installEventFilter(this); m_render_widget->installEventFilter(this); @@ -771,8 +777,12 @@ void MainWindow::StartGame(std::unique_ptr&& parameters) QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok); return; } + ShowRenderWidget(); + if (SConfig::GetInstance().bFullscreen) + m_fullscreen_requested = true; + #ifdef Q_OS_WIN // Prevents Windows from sleeping, turning off the display, or idling EXECUTION_STATE shouldScreenSave = @@ -810,13 +820,6 @@ void MainWindow::SetFullScreenResolution(bool fullscreen) void MainWindow::ShowRenderWidget() { - if (SConfig::GetInstance().bFullscreen && !m_render_widget->isFullScreen()) - { - m_render_widget->showFullScreen(); - SetFullScreenResolution(true); - return; - } - SetFullScreenResolution(false); Host::GetInstance()->SetRenderFullscreen(false); diff --git a/Source/Core/DolphinQt2/MainWindow.h b/Source/Core/DolphinQt2/MainWindow.h index 7bf2f3fd80..3f922672ed 100644 --- a/Source/Core/DolphinQt2/MainWindow.h +++ b/Source/Core/DolphinQt2/MainWindow.h @@ -175,6 +175,7 @@ private: bool m_rendering_to_main; bool m_stop_requested = false; bool m_exit_requested = false; + bool m_fullscreen_requested = false; int m_state_slot = 1; std::unique_ptr m_pending_boot; From 0273cae3a2d2c52e8287438ae15a7269353d5a3c Mon Sep 17 00:00:00 2001 From: spycrab Date: Fri, 8 Jun 2018 20:47:15 +0200 Subject: [PATCH 2/2] Qt: Restore fullscreen resolution when regaining focus --- Source/Core/DolphinQt2/MainWindow.cpp | 8 ++++++++ Source/Core/DolphinQt2/RenderWidget.cpp | 8 ++++++-- Source/Core/DolphinQt2/RenderWidget.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 0a49b5f9be..cd3be9999f 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -482,6 +482,10 @@ void MainWindow::ConnectRenderWidget() m_rendering_to_main = false; m_render_widget->hide(); connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop); + connect(m_render_widget, &RenderWidget::FocusChanged, this, [this](bool focus) { + if (m_render_widget->isFullScreen()) + SetFullScreenResolution(focus); + }); } void MainWindow::ConnectHost() @@ -874,6 +878,10 @@ void MainWindow::HideRenderWidget(bool reinit) m_render_widget->installEventFilter(this); connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop); + connect(m_render_widget, &RenderWidget::FocusChanged, this, [this](bool focus) { + if (m_render_widget->isFullScreen()) + SetFullScreenResolution(focus); + }); } } diff --git a/Source/Core/DolphinQt2/RenderWidget.cpp b/Source/Core/DolphinQt2/RenderWidget.cpp index 0d8e1a9660..8d61e05b23 100644 --- a/Source/Core/DolphinQt2/RenderWidget.cpp +++ b/Source/Core/DolphinQt2/RenderWidget.cpp @@ -52,6 +52,8 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent) Qt::DirectConnection); connect(this, &RenderWidget::SizeChanged, Host::GetInstance(), &Host::ResizeSurface, Qt::DirectConnection); + connect(this, &RenderWidget::FocusChanged, Host::GetInstance(), &Host::SetRenderFocus, + Qt::DirectConnection); emit HandleChanged((void*)winId()); @@ -145,14 +147,16 @@ bool RenderWidget::event(QEvent* event) emit HandleChanged((void*)winId()); break; case QEvent::WindowActivate: - Host::GetInstance()->SetRenderFocus(true); if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Paused) Core::SetState(Core::State::Running); + + emit FocusChanged(true); break; case QEvent::WindowDeactivate: - Host::GetInstance()->SetRenderFocus(false); if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Running) Core::SetState(Core::State::Paused); + + emit FocusChanged(false); break; case QEvent::Resize: { diff --git a/Source/Core/DolphinQt2/RenderWidget.h b/Source/Core/DolphinQt2/RenderWidget.h index 6122fc8633..ef7762ae1d 100644 --- a/Source/Core/DolphinQt2/RenderWidget.h +++ b/Source/Core/DolphinQt2/RenderWidget.h @@ -28,6 +28,7 @@ signals: void HandleChanged(void* handle); void StateChanged(bool fullscreen); void SizeChanged(int new_width, int new_height); + void FocusChanged(bool focus); private: void HandleCursorTimer();