From 4ae4397547f7703d6425cecb61df05be673a9258 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 27 Oct 2024 02:42:27 +0200 Subject: [PATCH] properly update display type across all windows (remind me to also propagate changes across instances) --- src/frontend/qt_sdl/EmuThread.cpp | 4 ++-- src/frontend/qt_sdl/Window.cpp | 24 +++++++++++++++++++++--- src/frontend/qt_sdl/Window.h | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp index 07e03e0f..1bf22c36 100644 --- a/src/frontend/qt_sdl/EmuThread.cpp +++ b/src/frontend/qt_sdl/EmuThread.cpp @@ -70,7 +70,7 @@ EmuThread::EmuThread(EmuInstance* inst, QObject* parent) : QThread(parent) void EmuThread::attachWindow(MainWindow* window) { - connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); + //connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); connect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString))); connect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); @@ -89,7 +89,7 @@ void EmuThread::attachWindow(MainWindow* window) void EmuThread::detachWindow(MainWindow* window) { - disconnect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); + //disconnect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); disconnect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString))); disconnect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index 4a5fa439..16e30081 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -701,6 +701,7 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : } show(); + panel = nullptr; createScreenPanel(); if (hasMenu) @@ -827,6 +828,9 @@ void MainWindow::closeEvent(QCloseEvent* event) void MainWindow::createScreenPanel() { + if (panel) delete panel; + panel = nullptr; + hasOGL = globalCfg.GetBool("Screen.UseGL") || (globalCfg.GetInt("3D.Renderer") != renderer3D_Software); @@ -852,6 +856,8 @@ void MainWindow::createScreenPanel() actScreenFiltering->setEnabled(hasOGL); panel->osdSetEnabled(showOSD); + connect(emuThread, SIGNAL(windowUpdate()), panel, SLOT(repaint())); + connect(this, SIGNAL(screenLayoutChange()), panel, SLOT(onScreenLayoutChanged())); emit screenLayoutChange(); } @@ -2115,14 +2121,17 @@ void MainWindow::onEmuReset() void MainWindow::onUpdateVideoSettings(bool glchange) { + MainWindow* parentwin = (MainWindow*)parentWidget(); + if (parentwin) + return parentwin->onUpdateVideoSettings(glchange); + + bool hadOGL = hasOGL; if (glchange) { emuThread->emuPause(); - if (hasOGL) emuThread->deinitContext(windowID); + if (hadOGL) emuThread->deinitContext(windowID); - delete panel; createScreenPanel(); - connect(emuThread, SIGNAL(windowUpdate()), panel, SLOT(repaint())); } emuThread->updateVideoSettings(); @@ -2130,6 +2139,15 @@ void MainWindow::onUpdateVideoSettings(bool glchange) if (glchange) { if (hasOGL) emuThread->initContext(windowID); + + auto childwins = findChildren(Qt::FindDirectChildrenOnly); + for (auto child : childwins) + { + if (hadOGL) emuThread->deinitContext(child->windowID); + child->createScreenPanel(); + if (hasOGL) emuThread->initContext(child->windowID); + } + emuThread->emuUnpause(); } } diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 32ba5dd2..17575b53 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -110,6 +110,7 @@ public: EmuInstance* getEmuInstance() { return emuInstance; } Config::Table& getWindowConfig() { return windowCfg; } + int getID() { return windowID; } bool winHasMenu() { return hasMenu; }