From 45832fcbe36b721b742d38c311072ecbaab73407 Mon Sep 17 00:00:00 2001 From: Alexis Date: Thu, 9 Aug 2018 12:25:01 +0200 Subject: [PATCH] fix(workspaces): reorder child if needed on focus --- src/modules/workspaces.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/workspaces.cpp b/src/modules/workspaces.cpp index 340921b6..5ba7e24c 100644 --- a/src/modules/workspaces.cpp +++ b/src/modules/workspaces.cpp @@ -50,11 +50,13 @@ void waybar::modules::Workspaces::updateThread() auto waybar::modules::Workspaces::update() -> void { Json::Value workspaces = _getWorkspaces(); + bool hided = false; for (auto it = _buttons.begin(); it != _buttons.end(); ++it) { auto ws = std::find_if(workspaces.begin(), workspaces.end(), [it](auto node) -> bool { return node["num"].asInt() == it->first; }); if (ws == workspaces.end()) { it->second.hide(); + hided = true; } } for (auto node : workspaces) { @@ -69,6 +71,9 @@ auto waybar::modules::Workspaces::update() -> void } else if (!styleContext->has_class("current") && isCurrent) { styleContext->add_class("current"); } + if (hided) { + _box->reorder_child(it->second, node["num"].asInt() - 1); + } it->second.show(); } }