From 30c4f08773e5608ac886251024fadace3dcdcea9 Mon Sep 17 00:00:00 2001 From: gardenapple Date: Tue, 20 Jun 2023 03:23:03 +0300 Subject: [PATCH] hyprland/window: Correct application of .solo class --- include/modules/hyprland/window.hpp | 3 ++- src/modules/hyprland/window.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/modules/hyprland/window.hpp b/include/modules/hyprland/window.hpp index 19aff50a..950be05f 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 47c68bb5..ba476e93 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; }