Qt: Restore fullscreen resolution when regaining focus
This commit is contained in:
parent
6c19b5947b
commit
0273cae3a2
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue