fix: hide icon if window is unfocused

pull/2973/head
Azazel 2024-02-26 21:00:16 +00:00
parent a7d8b1bacf
commit c59bb509bd
2 changed files with 11 additions and 0 deletions

View File

@ -59,6 +59,7 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
bool allFloating_; bool allFloating_;
bool swallowing_; bool swallowing_;
bool fullscreen_; bool fullscreen_;
bool focused_;
}; };
} // namespace waybar::modules::hyprland } // namespace waybar::modules::hyprland

View File

@ -62,6 +62,12 @@ auto Window::update() -> void {
label_.hide(); label_.hide();
} }
if (focused_) {
image_.show();
} else {
image_.hide();
}
setClass("empty", workspace_.windows == 0); setClass("empty", workspace_.windows == 0);
setClass("solo", solo_); setClass("solo", solo_);
setClass("floating", allFloating_); setClass("floating", allFloating_);
@ -137,13 +143,16 @@ void Window::queryActiveWorkspace() {
workspace_ = getActiveWorkspace(); workspace_ = getActiveWorkspace();
} }
focused_ = true;
if (workspace_.windows > 0) { if (workspace_.windows > 0) {
const auto clients = gIPC->getSocket1JsonReply("clients"); const auto clients = gIPC->getSocket1JsonReply("clients");
assert(clients.isArray()); assert(clients.isArray());
auto activeWindow = std::find_if(clients.begin(), clients.end(), [&](Json::Value window) { auto activeWindow = std::find_if(clients.begin(), clients.end(), [&](Json::Value window) {
return window["address"] == workspace_.last_window; return window["address"] == workspace_.last_window;
}); });
if (activeWindow == std::end(clients)) { if (activeWindow == std::end(clients)) {
focused_ = false;
return; return;
} }
@ -185,6 +194,7 @@ void Window::queryActiveWorkspace() {
soloClass_ = ""; soloClass_ = "";
} }
} else { } else {
focused_ = false;
windowData_ = WindowData{}; windowData_ = WindowData{};
allFloating_ = false; allFloating_ = false;
swallowing_ = false; swallowing_ = false;