Merge pull request #7094 from spycrab/qt_fs_fixes
Qt: Fix multiple fullscreen issues
This commit is contained in:
commit
09df03382d
|
@ -209,6 +209,12 @@ void MainWindow::InitCoreCallbacks()
|
||||||
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [=](Core::State state) {
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [=](Core::State state) {
|
||||||
if (state == Core::State::Uninitialized)
|
if (state == Core::State::Uninitialized)
|
||||||
OnStopComplete();
|
OnStopComplete();
|
||||||
|
|
||||||
|
if (state == Core::State::Running && m_fullscreen_requested)
|
||||||
|
{
|
||||||
|
FullScreen();
|
||||||
|
m_fullscreen_requested = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
m_render_widget->installEventFilter(this);
|
m_render_widget->installEventFilter(this);
|
||||||
|
@ -476,6 +482,10 @@ void MainWindow::ConnectRenderWidget()
|
||||||
m_rendering_to_main = false;
|
m_rendering_to_main = false;
|
||||||
m_render_widget->hide();
|
m_render_widget->hide();
|
||||||
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
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()
|
void MainWindow::ConnectHost()
|
||||||
|
@ -771,8 +781,12 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
|
QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowRenderWidget();
|
ShowRenderWidget();
|
||||||
|
|
||||||
|
if (SConfig::GetInstance().bFullscreen)
|
||||||
|
m_fullscreen_requested = true;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Prevents Windows from sleeping, turning off the display, or idling
|
// Prevents Windows from sleeping, turning off the display, or idling
|
||||||
EXECUTION_STATE shouldScreenSave =
|
EXECUTION_STATE shouldScreenSave =
|
||||||
|
@ -810,13 +824,6 @@ void MainWindow::SetFullScreenResolution(bool fullscreen)
|
||||||
|
|
||||||
void MainWindow::ShowRenderWidget()
|
void MainWindow::ShowRenderWidget()
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().bFullscreen && !m_render_widget->isFullScreen())
|
|
||||||
{
|
|
||||||
m_render_widget->showFullScreen();
|
|
||||||
SetFullScreenResolution(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetFullScreenResolution(false);
|
SetFullScreenResolution(false);
|
||||||
Host::GetInstance()->SetRenderFullscreen(false);
|
Host::GetInstance()->SetRenderFullscreen(false);
|
||||||
|
|
||||||
|
@ -871,6 +878,10 @@ void MainWindow::HideRenderWidget(bool reinit)
|
||||||
|
|
||||||
m_render_widget->installEventFilter(this);
|
m_render_widget->installEventFilter(this);
|
||||||
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@ private:
|
||||||
bool m_rendering_to_main;
|
bool m_rendering_to_main;
|
||||||
bool m_stop_requested = false;
|
bool m_stop_requested = false;
|
||||||
bool m_exit_requested = false;
|
bool m_exit_requested = false;
|
||||||
|
bool m_fullscreen_requested = false;
|
||||||
int m_state_slot = 1;
|
int m_state_slot = 1;
|
||||||
std::unique_ptr<BootParameters> m_pending_boot;
|
std::unique_ptr<BootParameters> m_pending_boot;
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
|
||||||
Qt::DirectConnection);
|
Qt::DirectConnection);
|
||||||
connect(this, &RenderWidget::SizeChanged, Host::GetInstance(), &Host::ResizeSurface,
|
connect(this, &RenderWidget::SizeChanged, Host::GetInstance(), &Host::ResizeSurface,
|
||||||
Qt::DirectConnection);
|
Qt::DirectConnection);
|
||||||
|
connect(this, &RenderWidget::FocusChanged, Host::GetInstance(), &Host::SetRenderFocus,
|
||||||
|
Qt::DirectConnection);
|
||||||
|
|
||||||
emit HandleChanged((void*)winId());
|
emit HandleChanged((void*)winId());
|
||||||
|
|
||||||
|
@ -145,14 +147,16 @@ bool RenderWidget::event(QEvent* event)
|
||||||
emit HandleChanged((void*)winId());
|
emit HandleChanged((void*)winId());
|
||||||
break;
|
break;
|
||||||
case QEvent::WindowActivate:
|
case QEvent::WindowActivate:
|
||||||
Host::GetInstance()->SetRenderFocus(true);
|
|
||||||
if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Paused)
|
if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Paused)
|
||||||
Core::SetState(Core::State::Running);
|
Core::SetState(Core::State::Running);
|
||||||
|
|
||||||
|
emit FocusChanged(true);
|
||||||
break;
|
break;
|
||||||
case QEvent::WindowDeactivate:
|
case QEvent::WindowDeactivate:
|
||||||
Host::GetInstance()->SetRenderFocus(false);
|
|
||||||
if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Running)
|
if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Running)
|
||||||
Core::SetState(Core::State::Paused);
|
Core::SetState(Core::State::Paused);
|
||||||
|
|
||||||
|
emit FocusChanged(false);
|
||||||
break;
|
break;
|
||||||
case QEvent::Resize:
|
case QEvent::Resize:
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@ signals:
|
||||||
void HandleChanged(void* handle);
|
void HandleChanged(void* handle);
|
||||||
void StateChanged(bool fullscreen);
|
void StateChanged(bool fullscreen);
|
||||||
void SizeChanged(int new_width, int new_height);
|
void SizeChanged(int new_width, int new_height);
|
||||||
|
void FocusChanged(bool focus);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void HandleCursorTimer();
|
void HandleCursorTimer();
|
||||||
|
|
Loading…
Reference in New Issue