From e73ea8d608e54dca4c99616444343a7c24340e61 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:37:10 +0200 Subject: [PATCH] Fixed cases where the module would be hidden when it should be visible --- include/modules/privacy/privacy.hpp | 1 + src/modules/privacy/privacy.cpp | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/modules/privacy/privacy.hpp b/include/modules/privacy/privacy.hpp index 3ec767a6..b14cf452 100644 --- a/include/modules/privacy/privacy.hpp +++ b/include/modules/privacy/privacy.hpp @@ -30,6 +30,7 @@ class Privacy : public AModule { PrivacyItem privacy_item_audio_input; PrivacyItem privacy_item_audio_output; + std::mutex mutex_; sigc::connection visibility_conn; // Config diff --git a/src/modules/privacy/privacy.cpp b/src/modules/privacy/privacy.cpp index ea97b352..56fd6d88 100644 --- a/src/modules/privacy/privacy.cpp +++ b/src/modules/privacy/privacy.cpp @@ -67,6 +67,7 @@ Privacy::Privacy(const std::string& id, const Json::Value& config, const std::st } void Privacy::onPrivacyNodesChanged() { + mutex_.lock(); nodes_audio_out.clear(); nodes_audio_in.clear(); nodes_screenshare.clear(); @@ -100,6 +101,7 @@ void Privacy::onPrivacyNodesChanged() { } } + mutex_.unlock(); dp.emit(); } @@ -121,13 +123,17 @@ auto Privacy::update() -> void { if (is_visible) { event_box_.set_visible(true); } else { - visibility_conn = Glib::signal_timeout().connect(sigc::track_obj( - [this] { - event_box_.set_visible(false); - return false; - }, - *this), - transition_duration); + visibility_conn = Glib::signal_timeout().connect( + sigc::track_obj( + [this] { + bool screenshare = !nodes_screenshare.empty(); + bool audio_in = !nodes_audio_in.empty(); + bool audio_out = !nodes_audio_out.empty(); + event_box_.set_visible(screenshare || audio_in || audio_out); + return false; + }, + *this), + transition_duration); } }