diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index a848fc3e..7efa6509 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -241,12 +241,12 @@ void EmuInstance::deleteAllWindows() } -void EmuInstance::broadcastCommand(int cmd) +void EmuInstance::broadcastCommand(int cmd, QVariant param) { - broadcastInstanceCommand(cmd, instanceID); + broadcastInstanceCommand(cmd, param, instanceID); } -void EmuInstance::handleCommand(int cmd) +void EmuInstance::handleCommand(int cmd, QVariant& param) { switch (cmd) { @@ -265,6 +265,10 @@ void EmuInstance::handleCommand(int cmd) windowList[i]->loadRecentFilesMenu(true); } break; + + /*case InstCmd_UpdateVideoSettings: + mainWindow->updateVideoSettings(param.value()); + break;*/ } } diff --git a/src/frontend/qt_sdl/EmuInstance.h b/src/frontend/qt_sdl/EmuInstance.h index 61090496..a79b4f75 100644 --- a/src/frontend/qt_sdl/EmuInstance.h +++ b/src/frontend/qt_sdl/EmuInstance.h @@ -92,8 +92,8 @@ public: Config::Table& getGlobalConfig() { return globalCfg; } Config::Table& getLocalConfig() { return localCfg; } - void broadcastCommand(int cmd); - void handleCommand(int cmd); + void broadcastCommand(int cmd, QVariant param = QVariant()); + void handleCommand(int cmd, QVariant& param); std::string instanceFileSuffix(); diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index 442274b5..fef51217 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -2147,14 +2147,11 @@ void MainWindow::onEmuReset() void MainWindow::onUpdateVideoSettings(bool glchange) { - if (windowID != 0) - { - MainWindow* parentwin = (MainWindow*)parentWidget(); - if (parentwin) - parentwin->onUpdateVideoSettings(glchange); - - return; - } + // if we have a parent window: pass the message over to the parent + // the topmost parent takes care of updating all the windows + MainWindow* parentwin = (MainWindow*)parentWidget(); + if (parentwin) + return parentwin->onUpdateVideoSettings(glchange); bool hadOGL = hasOGL; if (glchange) @@ -2170,18 +2167,33 @@ void MainWindow::onUpdateVideoSettings(bool glchange) if (glchange) { if (hasOGL) emuThread->initContext(windowID); + } - if (windowID == 0) + // update any child windows we have + auto childwins = findChildren(nullptr, Qt::FindDirectChildrenOnly); + for (auto child: childwins) + { + // child windows may belong to a different instance + // in that case we need to signal their thread appropriately + auto thread = child->getEmuInstance()->getEmuThread(); + + if (glchange) { - auto childwins = findChildren(nullptr, Qt::FindDirectChildrenOnly); - for (auto child: childwins) - { - if (hadOGL) emuThread->deinitContext(child->windowID); - child->createScreenPanel(); - if (hasOGL) emuThread->initContext(child->windowID); - } + if (hadOGL) thread->deinitContext(child->windowID); + child->createScreenPanel(); } + if (child->getWindowID() == 0) + thread->updateVideoSettings(); + + if (glchange) + { + if (hasOGL) thread->initContext(child->windowID); + } + } + + if (glchange) + { emuThread->emuUnpause(); } } diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 73bb84bb..64f17841 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -135,6 +135,7 @@ public: void updateMPInterface(melonDS::MPInterfaceType type); void loadRecentFilesMenu(bool loadcfg); + //void updateVideoSettings(bool glchange); protected: void keyPressEvent(QKeyEvent* event) override; diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 69485a8e..d940340a 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -168,14 +168,14 @@ int numEmuInstances() } -void broadcastInstanceCommand(int cmd, int sourceinst) +void broadcastInstanceCommand(int cmd, QVariant& param, int sourceinst) { for (int i = 0; i < kMaxEmuInstances; i++) { if (i == sourceinst) continue; if (!emuInstances[i]) continue; - emuInstances[i]->handleCommand(cmd); + emuInstances[i]->handleCommand(cmd, param); } } diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index cd5a08f1..e0d38963 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -37,6 +37,7 @@ enum InstCmd_Unpause, InstCmd_UpdateRecentFiles, + //InstCmd_UpdateVideoSettings, }; class MelonApplication : public QApplication @@ -58,7 +59,7 @@ void deleteEmuInstance(int id); void deleteAllEmuInstances(int first = 0); int numEmuInstances(); -void broadcastInstanceCommand(int cmd, int sourceinst); +void broadcastInstanceCommand(int cmd, QVariant& param, int sourceinst); void setMPInterface(melonDS::MPInterfaceType type);