Let OBS handle dock restoration on first startup and cleanup on shutdown

The "manual" attempt at restoring the docks should only be performed on
scene collection change as OBS will already take care of this on
starutp.

Do not delete the macro dock widgets on shutdown so OBS is able to save
their location and size properly.
This commit is contained in:
WarmUpTill 2023-05-29 15:33:48 +02:00 committed by WarmUpTill
parent dea4ff47cd
commit 65545d85ba
3 changed files with 17 additions and 8 deletions

View File

@ -516,6 +516,7 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
// Reset on startup and scene collection change
switcher->lastOpenedTab = -1;
startupLoadDone = true;
}
void SwitcherData::SaveSettings(obs_data_t *obj)

View File

@ -30,7 +30,12 @@ Macro::~Macro()
_die = true;
Stop();
ClearHotkeys();
RemoveDock();
// Keep the dock widgets in case of shutdown so they can be rostored by
// OBS on startup
if (!switcher->obsIsShuttingDown) {
RemoveDock();
}
}
std::shared_ptr<Macro>
@ -705,14 +710,16 @@ void Macro::EnableDock(bool value)
// geometry set here.
// The function calls here are only intended to attempt to restore the
// dock status when switching scene collections.
_dock->setVisible(_dockIsVisible);
if (window->dockWidgetArea(_dock) != _dockArea) {
window->addDockWidget(_dockArea, _dock);
if (switcher->startupLoadDone) {
_dock->setVisible(_dockIsVisible);
if (window->dockWidgetArea(_dock) != _dockArea) {
window->addDockWidget(_dockArea, _dock);
}
if (_dock->isFloating() != _dockIsFloating) {
_dock->setFloating(_dockIsFloating);
}
_dock->restoreGeometry(_dockGeo);
}
if (_dock->isFloating() != _dockIsFloating) {
_dock->setFloating(_dockIsFloating);
}
_dock->restoreGeometry(_dockGeo);
_registerDock = value;
}

View File

@ -124,6 +124,7 @@ public:
bool firstInterval = true;
bool firstIntervalAfterStop = true;
int shutdownConditionCount = 0;
bool startupLoadDone = false;
obs_source_t *waitScene = nullptr;
OBSWeakSource currentScene = nullptr;