From 0cbb280de635aa3ddcdbb416d8ebd55a1fb82b15 Mon Sep 17 00:00:00 2001 From: Jannik Date: Sat, 24 Feb 2024 15:00:39 +0100 Subject: [PATCH 1/2] fix title not showing for special workspaces (seperate outputs: true) --- src/modules/hyprland/window.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/hyprland/window.cpp b/src/modules/hyprland/window.cpp index 1af02b559..eb659b13a 100644 --- a/src/modules/hyprland/window.cpp +++ b/src/modules/hyprland/window.cpp @@ -99,7 +99,8 @@ auto Window::getActiveWorkspace(const std::string& monitorName) -> Workspace { spdlog::warn("Monitor not found: {}", monitorName); return Workspace{-1, 0, "", ""}; } - const int id = (*monitor)["activeWorkspace"]["id"].asInt(); + const int special_id = (*monitor)["specialWorkspace"]["id"].asInt(); + const int id = special_id != 0 ? special_id : (*monitor)["activeWorkspace"]["id"].asInt(); const auto workspaces = gIPC->getSocket1JsonReply("workspaces"); assert(workspaces.isArray()); From 9f5c27c6e06e51853b55f68043521d1677e4d048 Mon Sep 17 00:00:00 2001 From: Jannik Date: Sat, 24 Feb 2024 18:16:43 +0100 Subject: [PATCH 2/2] fix title not showing for special workspaces (seperate outputs: false --- include/modules/hyprland/window.hpp | 1 - src/modules/hyprland/window.cpp | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/include/modules/hyprland/window.hpp b/include/modules/hyprland/window.hpp index ea4d83b2e..4cc16ffb0 100644 --- a/include/modules/hyprland/window.hpp +++ b/include/modules/hyprland/window.hpp @@ -42,7 +42,6 @@ class Window : public waybar::AAppIconLabel, public EventHandler { }; auto getActiveWorkspace(const std::string&) -> Workspace; - auto getActiveWorkspace() -> Workspace; void onEvent(const std::string&) override; void queryActiveWorkspace(); void setClass(const std::string&, bool enable); diff --git a/src/modules/hyprland/window.cpp b/src/modules/hyprland/window.cpp index eb659b13a..fca8b9ab5 100644 --- a/src/modules/hyprland/window.cpp +++ b/src/modules/hyprland/window.cpp @@ -84,17 +84,12 @@ auto Window::update() -> void { AAppIconLabel::update(); } -auto Window::getActiveWorkspace() -> Workspace { - const auto workspace = gIPC->getSocket1JsonReply("activeworkspace"); - assert(workspace.isObject()); - return Workspace::parse(workspace); -} - -auto Window::getActiveWorkspace(const std::string& monitorName) -> Workspace { +auto Window::getActiveWorkspace(const std::string& monitorName = "") -> Workspace { const auto monitors = gIPC->getSocket1JsonReply("monitors"); assert(monitors.isArray()); - auto monitor = std::find_if(monitors.begin(), monitors.end(), - [&](Json::Value monitor) { return monitor["name"] == monitorName; }); + auto monitor = std::find_if(monitors.begin(), monitors.end(), [&](Json::Value monitor) { + return monitorName == "" ? monitor["focused"].asBool() : monitor["name"] == monitorName; + }); if (monitor == std::end(monitors)) { spdlog::warn("Monitor not found: {}", monitorName); return Workspace{-1, 0, "", ""};