-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
frontend: Hide Twitch docks on minimized start #13368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1152,6 +1152,7 @@ void OBSBasic::OBSInit() | |
| bool sysTrayWhenStarted = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SysTrayWhenStarted"); | ||
| bool hideWindowOnStart = QSystemTrayIcon::isSystemTrayAvailable() && sysTrayEnabled && | ||
| (opt_minimize_tray || sysTrayWhenStarted); | ||
| deferExtraDockVisibility = hideWindowOnStart; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reuse the same startup-hidden condition so docks know OBS is intentionally hidden, not just mid-startup. |
||
|
|
||
| #ifdef _WIN32 | ||
| SetWin32DropStyle(this); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ | |
|
|
||
| #include <qt-wrappers.hpp> | ||
|
|
||
| #include <QShowEvent> | ||
|
|
||
| void setupDockAction(QDockWidget *dock) | ||
| { | ||
| QAction *action = dock->toggleViewAction(); | ||
|
|
@@ -160,8 +162,10 @@ void OBSBasic::AddDockWidget(QDockWidget *dock, Qt::DockWidgetArea area, bool ex | |
| else | ||
| ui->menuDocks->addAction(dock->toggleViewAction()); | ||
|
|
||
| if (extraBrowser) | ||
| if (extraBrowser) { | ||
| DeferExtraDockVisibility(dock); | ||
| return; | ||
| } | ||
| #else | ||
| UNUSED_PARAMETER(extraBrowser); | ||
|
|
||
|
|
@@ -170,6 +174,7 @@ void OBSBasic::AddDockWidget(QDockWidget *dock, Qt::DockWidgetArea area, bool ex | |
|
|
||
| extraDockNames.push_back(dock->objectName()); | ||
| extraDocks.push_back(std::shared_ptr<QDockWidget>(dock)); | ||
| DeferExtraDockVisibility(dock); | ||
| } | ||
|
|
||
| void OBSBasic::RemoveDockWidget(const QString &name) | ||
|
|
@@ -218,6 +223,67 @@ void OBSBasic::AddCustomDockWidget(QDockWidget *dock) | |
|
|
||
| extraCustomDockNames.push_back(dock->objectName()); | ||
| extraCustomDocks.push_back(dock); | ||
| DeferExtraDockVisibility(dock); | ||
| } | ||
|
|
||
| void OBSBasic::DeferExtraDockVisibility(QDockWidget *dock) | ||
| { | ||
| if (!deferExtraDockVisibility || !dock) | ||
| return; | ||
|
|
||
| for (auto &deferredDock : deferredExtraDockVisibility) { | ||
| if (deferredDock.first == dock) | ||
| return; | ||
| } | ||
|
|
||
| deferredExtraDockVisibility.append({dock, dock->isVisible()}); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Record the restored visibility before hiding, so floating docks come back exactly as saved once OBS is shown. |
||
|
|
||
| // When OBS starts hidden to tray, restoreState() can make floating | ||
| // extra docks visible before the main window is ever shown. | ||
| connect(dock, &QDockWidget::visibilityChanged, this, [this, dock](bool visible) { | ||
| if (!deferExtraDockVisibility || hidingDeferredExtraDock) | ||
| return; | ||
|
|
||
| for (auto &deferredDock : deferredExtraDockVisibility) { | ||
| if (deferredDock.first != dock) | ||
| continue; | ||
|
|
||
| deferredDock.second = visible; | ||
| if (visible && !isVisible()) { | ||
| hidingDeferredExtraDock = true; | ||
| dock->setVisible(false); | ||
| hidingDeferredExtraDock = false; | ||
| } | ||
| return; | ||
| } | ||
| }); | ||
|
|
||
| if (dock->isVisible() && !isVisible()) { | ||
| hidingDeferredExtraDock = true; | ||
| dock->setVisible(false); | ||
| hidingDeferredExtraDock = false; | ||
| } | ||
| } | ||
|
|
||
| void OBSBasic::RestoreDeferredExtraDockVisibility() | ||
| { | ||
| if (!deferExtraDockVisibility) | ||
| return; | ||
|
|
||
| deferExtraDockVisibility = false; | ||
|
|
||
| for (auto &deferredDock : deferredExtraDockVisibility) { | ||
| if (deferredDock.first) | ||
| deferredDock.first->setVisible(deferredDock.second); | ||
| } | ||
|
|
||
| deferredExtraDockVisibility.clear(); | ||
| } | ||
|
|
||
| void OBSBasic::showEvent(QShowEvent *event) | ||
| { | ||
| OBSMainWindow::showEvent(event); | ||
| RestoreDeferredExtraDockVisibility(); | ||
| } | ||
|
|
||
| void OBSBasic::setDockCornersVertical(bool vertical) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Twitch loads these panes late, so we still need to restore their saved layout before the generic dock hiding kicks in.