From 884d3f1324b487f540646b839ef6e2364b4c69b0 Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Wed, 26 Jul 2023 14:00:00 +0200 Subject: [PATCH] SNI: Only reload a given senderName once Fix for: https://github.com/scorpion-26/gBar/issues/26 --- src/SNI.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/SNI.cpp b/src/SNI.cpp index c1cf16a..1e8965d 100644 --- a/src/SNI.cpp +++ b/src/SNI.cpp @@ -16,6 +16,7 @@ #include #include +#include namespace SNI { @@ -42,6 +43,7 @@ namespace SNI std::vector items; std::unordered_map clientsToQuery; + std::unordered_set reloadedNames; // Gtk stuff, TODO: Allow more than one instance // Simply removing the gtk_drawing_areas doesn't trigger proper redrawing @@ -281,6 +283,13 @@ namespace SNI static void ItemPropertyChanged(GDBusConnection*, const char* senderName, const char* object, const char*, const char*, GVariant*, void* name) { + if (reloadedNames.insert(senderName).second == false) + { + // senderName has already requested a change, ignore + LOG("SNI: " << senderName << " already signaled property change"); + return; + } + std::string nameStr = (const char*)name; LOG("SNI: Reloading " << (const char*)name << " " << object << " (Sender: " << senderName << ")"); // We don't care about *what* changed, just remove and reload @@ -347,6 +356,9 @@ namespace SNI LOG("SNI: Clearing old children"); parentBox->RemoveChild(iconBox); + // Allow further updates from the icon + reloadedNames.clear(); + auto container = Widget::Create(); container->SetSpacing({4, false}); container->SetOrientation(Utils::GetOrientation());