From 27f913843a08f346df4b8027572e92c8a24a9dde Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Sun, 23 Aug 2020 10:30:19 -0700 Subject: [PATCH 1/2] UI: Add OBSBasic::ClearProjectors() Allows the ability to clear projectors via a function rather than have to manually iterate any time one needs to clear the projectors --- UI/window-basic-main.cpp | 17 +++++++++++------ UI/window-basic-main.hpp | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index b9fa4c52e..a2ed34ea1 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -4076,6 +4076,16 @@ void OBSBasic::EnumDialogs() } } +void OBSBasic::ClearProjectors() +{ + for (size_t i = 0; i < projectors.size(); i++) { + if (projectors[i]) + delete projectors[i]; + } + + projectors.clear(); +} + void OBSBasic::ClearSceneData() { disableSaving++; @@ -4088,12 +4098,7 @@ void OBSBasic::ClearSceneData() ClearQuickTransitions(); ui->transitions->clear(); - for (size_t i = 0; i < projectors.size(); i++) { - if (projectors[i]) - delete projectors[i]; - } - - projectors.clear(); + ClearProjectors(); obs_set_output_source(0, nullptr); obs_set_output_source(1, nullptr); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 289664538..06cbdfe54 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -347,6 +347,7 @@ private: void CloseDialogs(); void ClearSceneData(); + void ClearProjectors(); void Nudge(int dist, MoveDir dir); From 227f80ac48e74a257defc34a82617a0da9c0ffa0 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Sun, 23 Aug 2020 05:12:46 -0500 Subject: [PATCH 2/2] UI: Fix always on top w/ projectors on Linux Apparently, on Linux, you cannot update the window flags while it is still open, so just close the projectors and reopen them again when the setting changes. --- UI/window-basic-main.cpp | 9 +++++++++ UI/window-basic-main.hpp | 1 + UI/window-basic-settings.cpp | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index a2ed34ea1..b8bd743cd 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -8269,6 +8269,15 @@ void OBSBasic::UpdateProjectorAlwaysOnTop(bool top) SetAlwaysOnTop(projectors[i], top); } +void OBSBasic::ResetProjectors() +{ + obs_data_array_t *savedProjectorList = SaveProjectors(); + ClearProjectors(); + LoadSavedProjectors(savedProjectorList); + OpenSavedProjectors(); + obs_data_array_release(savedProjectorList); +} + void OBSBasic::on_sourcePropertiesButton_clicked() { on_actionSourceProperties_triggered(); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 06cbdfe54..c70dc8e08 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -531,6 +531,7 @@ private: void UpdateProjectorHideCursor(); void UpdateProjectorAlwaysOnTop(bool top); + void ResetProjectors(); QPointer screenshotData; diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 96453a07a..fd0fb9b9a 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -2958,8 +2958,12 @@ void OBSBasicSettings::SaveGeneralSettings() config_set_bool(GetGlobalConfig(), "BasicWindow", "ProjectorAlwaysOnTop", ui->projectorAlwaysOnTop->isChecked()); +#if defined(_WIN32) || defined(__APPLE__) main->UpdateProjectorAlwaysOnTop( ui->projectorAlwaysOnTop->isChecked()); +#else + main->ResetProjectors(); +#endif } if (WidgetChanged(ui->recordWhenStreaming))