fix title not showing for special workspaces (seperate outputs: false

pull/2965/head
Jannik 2024-02-24 18:16:43 +01:00
parent 0cbb280de6
commit 9f5c27c6e0
No known key found for this signature in database
2 changed files with 4 additions and 10 deletions

View File

@ -42,7 +42,6 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
}; };
auto getActiveWorkspace(const std::string&) -> Workspace; auto getActiveWorkspace(const std::string&) -> Workspace;
auto getActiveWorkspace() -> Workspace;
void onEvent(const std::string&) override; void onEvent(const std::string&) override;
void queryActiveWorkspace(); void queryActiveWorkspace();
void setClass(const std::string&, bool enable); void setClass(const std::string&, bool enable);

View File

@ -84,17 +84,12 @@ auto Window::update() -> void {
AAppIconLabel::update(); AAppIconLabel::update();
} }
auto Window::getActiveWorkspace() -> Workspace { auto Window::getActiveWorkspace(const std::string& monitorName = "") -> Workspace {
const auto workspace = gIPC->getSocket1JsonReply("activeworkspace");
assert(workspace.isObject());
return Workspace::parse(workspace);
}
auto Window::getActiveWorkspace(const std::string& monitorName) -> Workspace {
const auto monitors = gIPC->getSocket1JsonReply("monitors"); const auto monitors = gIPC->getSocket1JsonReply("monitors");
assert(monitors.isArray()); assert(monitors.isArray());
auto monitor = std::find_if(monitors.begin(), monitors.end(), auto monitor = std::find_if(monitors.begin(), monitors.end(), [&](Json::Value monitor) {
[&](Json::Value monitor) { return monitor["name"] == monitorName; }); return monitorName == "" ? monitor["focused"].asBool() : monitor["name"] == monitorName;
});
if (monitor == std::end(monitors)) { if (monitor == std::end(monitors)) {
spdlog::warn("Monitor not found: {}", monitorName); spdlog::warn("Monitor not found: {}", monitorName);
return Workspace{-1, 0, "", ""}; return Workspace{-1, 0, "", ""};