diff options
author | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2021-12-09 01:57:02 +0100 |
---|---|---|
committer | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2021-12-09 01:57:02 +0100 |
commit | f1c9b42b455d1dcbb5b841a4bc3c48168092689b (patch) | |
tree | c000ab7b20dd61c3f8af666708c6f06304e45bca /src | |
parent | 14c6bba21f7f018035ad017c8a6d771a94243d18 (diff) |
ScreenPanelNative: Don't try to render the framebuffer if the emulator is not actually active.
This fixes an issue where the window draws with a gray background in macOS, and is see-through on Wayland-based desktops.
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 38 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.h | 1 |
2 files changed, 24 insertions, 15 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 332e3e1..bf7c261 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -714,6 +714,11 @@ bool EmuThread::emuIsRunning() return (EmuRunning == 1); } +bool EmuThread::emuIsActive() +{ + return (RunningSomething == 1); +} + void ScreenHandler::screenSetupLayout(int w, int h) { @@ -942,26 +947,29 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event) // fill background painter.fillRect(event->rect(), QColor::fromRgb(0, 0, 0)); - emuThread->FrontBufferLock.lock(); - int frontbuf = emuThread->FrontBuffer; - if (!GPU::Framebuffer[frontbuf][0] || !GPU::Framebuffer[frontbuf][1]) + if (emuThread->emuIsActive()) { - emuThread->FrontBufferLock.unlock(); - return; - } + emuThread->FrontBufferLock.lock(); + int frontbuf = emuThread->FrontBuffer; + if (!GPU::Framebuffer[frontbuf][0] || !GPU::Framebuffer[frontbuf][1]) + { + emuThread->FrontBufferLock.unlock(); + return; + } - memcpy(screen[0].scanLine(0), GPU::Framebuffer[frontbuf][0], 256*192*4); - memcpy(screen[1].scanLine(0), GPU::Framebuffer[frontbuf][1], 256*192*4); - emuThread->FrontBufferLock.unlock(); + memcpy(screen[0].scanLine(0), GPU::Framebuffer[frontbuf][0], 256 * 192 * 4); + memcpy(screen[1].scanLine(0), GPU::Framebuffer[frontbuf][1], 256 * 192 * 4); + emuThread->FrontBufferLock.unlock(); - painter.setRenderHint(QPainter::SmoothPixmapTransform, Config::ScreenFilter!=0); + painter.setRenderHint(QPainter::SmoothPixmapTransform, Config::ScreenFilter != 0); - QRect screenrc(0, 0, 256, 192); + QRect screenrc(0, 0, 256, 192); - for (int i = 0; i < numScreens; i++) - { - painter.setTransform(screenTrans[i]); - painter.drawImage(screenrc, screen[screenKind[i]]); + for (int i = 0; i < numScreens; i++) + { + painter.setTransform(screenTrans[i]); + painter.drawImage(screenrc, screen[screenKind[i]]); + } } OSD::Update(nullptr); diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index 0f9034f..0b5e917 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -59,6 +59,7 @@ public: void emuFrameStep(); bool emuIsRunning(); + bool emuIsActive(); int FrontBuffer = 0; QMutex FrontBufferLock; |