mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 05:17:40 -07:00
correctly propagate video settings changes to all windows
This commit is contained in:
parent
e576538268
commit
6d345cc1ea
@ -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<bool>());
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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<MainWindow *>(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<MainWindow *>(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();
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ public:
|
||||
void updateMPInterface(melonDS::MPInterfaceType type);
|
||||
|
||||
void loadRecentFilesMenu(bool loadcfg);
|
||||
//void updateVideoSettings(bool glchange);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user