diff --git a/include/modules/hyprland/window.hpp b/include/modules/hyprland/window.hpp index 5316c0e..fd68b04 100644 --- a/include/modules/hyprland/window.hpp +++ b/include/modules/hyprland/window.hpp @@ -31,6 +31,8 @@ class Window : public waybar::AAppIconLabel, public EventHandler { std::string initial_class_name; std::string title; std::string initial_title; + bool fullscreen; + bool grouped; static auto parse(const Json::Value&) -> WindowData; }; @@ -51,7 +53,7 @@ class Window : public waybar::AAppIconLabel, public EventHandler { std::string last_solo_class_; bool solo_; bool all_floating_; - bool hidden_; + bool swallowing_; bool fullscreen_; }; diff --git a/man/waybar-hyprland-window.5.scd b/man/waybar-hyprland-window.5.scd index b8b25ce..64e48e4 100644 --- a/man/waybar-hyprland-window.5.scd +++ b/man/waybar-hyprland-window.5.scd @@ -76,5 +76,4 @@ window widget: - *window#waybar.floating* When there are only floating windows in the workspace - *window#waybar.fullscreen* When there is a fullscreen window in the workspace; useful with Hyprland's *fullscreen, 1* mode -- *window#waybar.hidden-window* When there are hidden windows in the workspace; - can occur due to window swallowing, *fullscreen, 1* mode, or grouped windows +- *window#waybar.swallowing* When there is a swallowed window in the workspace diff --git a/src/modules/hyprland/window.cpp b/src/modules/hyprland/window.cpp index 7519e80..d01ac9d 100644 --- a/src/modules/hyprland/window.cpp +++ b/src/modules/hyprland/window.cpp @@ -72,7 +72,7 @@ auto Window::update() -> void { setClass("empty", workspace_.windows == 0); setClass("solo", solo_); setClass("floating", all_floating_); - setClass("hidden-window", hidden_); + setClass("swallowing", swallowing_); setClass("fullscreen", fullscreen_); if (!last_solo_class_.empty() && solo_class_ != last_solo_class_) { @@ -125,9 +125,10 @@ auto Window::Workspace::parse(const Json::Value& value) -> Window::Workspace { } auto Window::WindowData::parse(const Json::Value& value) -> Window::WindowData { - return WindowData{value["floating"].asBool(), value["monitor"].asInt(), - value["class"].asString(), value["initialClass"].asString(), - value["title"].asString(), value["initialTitle"].asString()}; + return WindowData{value["floating"].asBool(), value["monitor"].asInt(), + value["class"].asString(), value["initialClass"].asString(), + value["title"].asString(), value["initialTitle"].asString(), + value["fullscreen"].asBool(), !value["grouped"].empty()}; } void Window::queryActiveWorkspace() { @@ -156,8 +157,8 @@ void Window::queryActiveWorkspace() { [&](Json::Value window) { return window["workspace"]["id"] == workspace_.id && window["mapped"].asBool(); }); - hidden_ = std::any_of(workspace_windows.begin(), workspace_windows.end(), - [&](Json::Value window) { return window["hidden"].asBool(); }); + swallowing_ = std::any_of(workspace_windows.begin(), workspace_windows.end(), + [&](Json::Value window) { return !window["swallowing"].isNull(); }); std::vector visible_windows; std::copy_if(workspace_windows.begin(), workspace_windows.end(), std::back_inserter(visible_windows), @@ -166,12 +167,19 @@ void Window::queryActiveWorkspace() { [&](Json::Value window) { return !window["floating"].asBool(); }); all_floating_ = std::all_of(visible_windows.begin(), visible_windows.end(), [&](Json::Value window) { return window["floating"].asBool(); }); - fullscreen_ = (*active_window)["fullscreen"].asBool(); + fullscreen_ = window_data_.fullscreen; + // Fullscreen windows look like they are solo if (fullscreen_) { solo_ = true; } + // Grouped windows have a tab bar and therefore don't look fullscreen or solo + if (window_data_.grouped) { + fullscreen_ = false; + solo_ = false; + } + if (solo_) { solo_class_ = window_data_.class_name; } else { @@ -180,7 +188,7 @@ void Window::queryActiveWorkspace() { } else { window_data_ = WindowData{}; all_floating_ = false; - hidden_ = false; + swallowing_ = false; fullscreen_ = false; solo_ = false; solo_class_ = "";