Qt: Fix fullscreen

This commit is contained in:
spycrab 2018-03-21 20:53:37 +01:00
parent 9cf22aec04
commit 8ead5be9f2
5 changed files with 25 additions and 11 deletions

View File

@ -247,6 +247,9 @@ void CodeWidget::Update()
void CodeWidget::UpdateCallstack()
{
if (Core::GetState() == Core::State::Starting)
return;
m_callstack_list->clear();
std::vector<Dolphin_Debugger::CallstackEntry> stack;

View File

@ -565,7 +565,7 @@ void MainWindow::FullScreen()
// settings. If it's set to be fullscreen then it just remakes the window,
// which probably isn't ideal.
bool was_fullscreen = m_render_widget->isFullScreen();
HideRenderWidget();
HideRenderWidget(false);
if (was_fullscreen)
ShowRenderWidget();
else
@ -629,7 +629,7 @@ void MainWindow::ShowRenderWidget()
{
// Otherwise, just show it.
m_rendering_to_main = false;
if (SConfig::GetInstance().bFullscreen)
if (SConfig::GetInstance().bFullscreen && !m_render_widget->isFullScreen())
{
m_render_widget->showFullScreen();
}
@ -641,7 +641,7 @@ void MainWindow::ShowRenderWidget()
}
}
void MainWindow::HideRenderWidget()
void MainWindow::HideRenderWidget(bool reinit)
{
if (m_rendering_to_main)
{
@ -654,19 +654,23 @@ void MainWindow::HideRenderWidget()
setWindowTitle(QString::fromStdString(Common::scm_rev_str));
}
m_render_widget->hide();
// The following code works around a driver bug that would lead to Dolphin crashing when changing
// graphics backends (e.g. OpenGL to Vulkan). To avoid this the render widget is (safely)
// recreated
disconnect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
if (reinit)
{
disconnect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
m_render_widget->hide();
m_render_widget->removeEventFilter(this);
m_render_widget->deleteLater();
m_render_widget->removeEventFilter(this);
m_render_widget->deleteLater();
m_render_widget = new RenderWidget;
m_render_widget = new RenderWidget;
m_render_widget->installEventFilter(this);
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
m_render_widget->installEventFilter(this);
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
}
}
void MainWindow::ShowControllersWindow()

View File

@ -100,7 +100,7 @@ private:
void StartGame(const std::string& path, const std::optional<std::string>& savestate_path = {});
void StartGame(std::unique_ptr<BootParameters>&& parameters);
void ShowRenderWidget();
void HideRenderWidget();
void HideRenderWidget(bool reinit = true);
void ShowSettingsWindow();
void ShowGeneralWindow();

View File

@ -49,6 +49,12 @@ void RenderWidget::HandleCursorTimer()
setCursor(Qt::BlankCursor);
}
void RenderWidget::showFullScreen()
{
QWidget::showFullScreen();
emit SizeChanged(width(), height());
}
bool RenderWidget::event(QEvent* event)
{
switch (event->type())

View File

@ -17,6 +17,7 @@ public:
explicit RenderWidget(QWidget* parent = nullptr);
bool event(QEvent* event) override;
void showFullScreen();
signals:
void EscapePressed();