Hyprland IPC improvements

Fixes IPC being blocked at shutdown
This commit is contained in:
zjeffer
2025-02-19 00:58:08 +01:00
parent c32d5e3883
commit 5b8839ab5c
12 changed files with 188 additions and 154 deletions

View File

@@ -7,15 +7,11 @@
namespace waybar::modules::hyprland {
Submap::Submap(const std::string& id, const Bar& bar, const Json::Value& config)
: ALabel(config, "submap", id, "{}", 0, true), bar_(bar) {
: ALabel(config, "submap", id, "{}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
modulesReady = true;
parseConfig(config);
if (!gIPC) {
gIPC = std::make_unique<IPC>();
}
label_.hide();
ALabel::update();
@@ -27,12 +23,12 @@ Submap::Submap(const std::string& id, const Bar& bar, const Json::Value& config)
}
// register for hyprland ipc
gIPC->registerForIPC("submap", this);
m_ipc.registerForIPC("submap", this);
dp.emit();
}
Submap::~Submap() {
gIPC->unregisterForIPC(this);
m_ipc.unregisterForIPC(this);
// wait for possible event handler to finish
std::lock_guard<std::mutex> lg(mutex_);
}