From da8fd864c62d0d52e0376213b7379d4c11f09c68 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:57:53 +0000 Subject: [PATCH] Simplify mutex locking in WindowCount module - Acquire lock once at start of update() and hold for entire function - Remove redundant lock from queryActiveWorkspace() since it's only called from update() This addresses code review feedback and makes the locking strategy clearer Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com> --- src/modules/hyprland/windowcount.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/hyprland/windowcount.cpp b/src/modules/hyprland/windowcount.cpp index 5d9ee1c3..487b0083 100644 --- a/src/modules/hyprland/windowcount.cpp +++ b/src/modules/hyprland/windowcount.cpp @@ -37,6 +37,8 @@ WindowCount::~WindowCount() { } auto WindowCount::update() -> void { + std::lock_guard lg(mutex_); + queryActiveWorkspace(); std::string format = config_["format"].asString(); @@ -44,8 +46,6 @@ auto WindowCount::update() -> void { std::string formatWindowed = config_["format-windowed"].asString(); std::string formatFullscreen = config_["format-fullscreen"].asString(); - std::lock_guard lg(mutex_); - setClass("empty", workspace_.windows == 0); setClass("fullscreen", workspace_.hasfullscreen); @@ -118,8 +118,6 @@ auto WindowCount::Workspace::parse(const Json::Value& value) -> WindowCount::Wor } void WindowCount::queryActiveWorkspace() { - std::lock_guard lg(mutex_); - if (separateOutputs_) { workspace_ = getActiveWorkspace(this->bar_.output->name); } else {