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>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-04 08:57:53 +00:00
parent c1240a98aa
commit da8fd864c6

View File

@ -37,6 +37,8 @@ WindowCount::~WindowCount() {
}
auto WindowCount::update() -> void {
std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> lg(mutex_);
if (separateOutputs_) {
workspace_ = getActiveWorkspace(this->bar_.output->name);
} else {