diff --git a/include/modules/hyprland/window.hpp b/include/modules/hyprland/window.hpp index 19aff50..950be05 100644 --- a/include/modules/hyprland/window.hpp +++ b/include/modules/hyprland/window.hpp @@ -38,8 +38,9 @@ class Window : public waybar::ALabel, public EventHandler { Workspace workspace_; std::string solo_class_; std::string last_solo_class_; - bool fullscreen_; + bool solo_; bool all_floating_; + bool fullscreen_; }; } // namespace waybar::modules::hyprland diff --git a/src/modules/hyprland/window.cpp b/src/modules/hyprland/window.cpp index 47c68bb..ba476e9 100644 --- a/src/modules/hyprland/window.cpp +++ b/src/modules/hyprland/window.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "modules/hyprland/backend.hpp" #include "util/json.hpp" @@ -64,7 +65,7 @@ auto Window::update() -> void { setClass("empty", workspace_.windows == 0); - setClass("solo", workspace_.windows == 1); + setClass("solo", solo_); setClass("fullscreen", fullscreen_); setClass("floating", all_floating_); @@ -149,12 +150,18 @@ void Window::queryActiveWorkspace() { } else { solo_class_ = ""; } - all_floating_ = std::all_of(json.begin(), json.end(), - [&](Json::Value window) { return window["floating"].asBool() || - window["workspace"]["id"] != workspace_.id; }); + std::vector workspace_windows; + std::copy_if(json.begin(), json.end(), std::back_inserter(workspace_windows), + [&](Json::Value window) { return window["workspace"]["id"] == workspace_.id && + window["mapped"].asBool(); }); + solo_ = 1 == std::count_if(workspace_windows.begin(), workspace_windows.end(), + [&](Json::Value window) { return !window["floating"].asBool(); }); + all_floating_ = std::all_of(workspace_windows.begin(), workspace_windows.end(), + [&](Json::Value window) { return window["floating"].asBool(); }); fullscreen_ = (*active_window)["fullscreen"].asBool(); } else { solo_class_ = ""; + solo_ = false; all_floating_ = false; fullscreen_ = false; }