From 0cb27cc42cfbfee78b16ea436ca60cd9d2bd6086 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 22 Apr 2019 20:29:04 -0700 Subject: [PATCH] Fix the screen going black on pause after changing windows More info: https://zeduckmaster.frama.io/2016/how-to-create-a-custom-rendering-in-a-qt5-widget/ --- Source/Core/DolphinQt/RenderWidget.cpp | 9 ++++++++- Source/Core/DolphinQt/RenderWidget.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/RenderWidget.cpp b/Source/Core/DolphinQt/RenderWidget.cpp index 45427c1a60..1d2ffddc0f 100644 --- a/Source/Core/DolphinQt/RenderWidget.cpp +++ b/Source/Core/DolphinQt/RenderWidget.cpp @@ -52,6 +52,7 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent) }); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) { + // Stop filling the background once emulation starts, but fill it until then (Bug 10958) SetFillBackground(Config::Get(Config::MAIN_RENDER_TO_MAIN) && state == Core::State::Uninitialized); if (state == Core::State::Running) @@ -90,9 +91,15 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent) void RenderWidget::SetFillBackground(bool fill) { + setAutoFillBackground(fill); setAttribute(Qt::WA_OpaquePaintEvent, !fill); setAttribute(Qt::WA_NoSystemBackground, !fill); - setAutoFillBackground(fill); + setAttribute(Qt::WA_PaintOnScreen, !fill); +} + +QPaintEngine* RenderWidget::paintEngine() const +{ + return autoFillBackground() ? QWidget::paintEngine() : nullptr; } void RenderWidget::dragEnterEvent(QDragEnterEvent* event) diff --git a/Source/Core/DolphinQt/RenderWidget.h b/Source/Core/DolphinQt/RenderWidget.h index df4f34d93e..818e9209ab 100644 --- a/Source/Core/DolphinQt/RenderWidget.h +++ b/Source/Core/DolphinQt/RenderWidget.h @@ -19,6 +19,7 @@ public: bool event(QEvent* event) override; void showFullScreen(); + QPaintEngine* paintEngine() const override; signals: void EscapePressed();