Use already existing queryActiveWorkspace()

This commit is contained in:
MisterPine 2023-07-08 22:05:15 +02:00
parent c4bace504c
commit c5f1771375
No known key found for this signature in database
GPG Key ID: 5481659D1D983422
2 changed files with 6 additions and 11 deletions

View File

@ -26,7 +26,7 @@ class Window : public waybar::ALabel, public EventHandler {
struct WindowData {
bool floating;
int monitor;
int monitor = -1;
std::string class_name;
std::string initial_class_name;
std::string title;
@ -46,8 +46,6 @@ class Window : public waybar::ALabel, public EventHandler {
std::mutex mutex_;
const Bar& bar_;
util::JsonParser parser_;
std::string last_window_address_;
std::string last_title_;
WindowData window_data_;
Workspace workspace_;
std::string solo_class_;

View File

@ -46,18 +46,13 @@ auto Window::update() -> void {
std::string window_name = waybar::util::sanitize_string(workspace_.last_window_title);
std::string window_address = workspace_.last_window;
if (window_name != last_title_) {
if (window_name != window_data_.title) {
if (window_name.empty()) {
label_.get_style_context()->add_class("empty");
} else {
label_.get_style_context()->remove_class("empty");
}
last_title_ = window_name;
}
if (window_address != last_window_address_) {
last_window_address_ = window_address;
window_data_ = getWindowData(window_address);
window_data_.title = window_name;
}
if (!format_.empty()) {
@ -165,6 +160,7 @@ void Window::queryActiveWorkspace() {
return;
}
window_data_ = WindowData::parse(*active_window);
std::vector<Json::Value> workspace_windows;
std::copy_if(clients.begin(), clients.end(), std::back_inserter(workspace_windows),
[&](Json::Value window) {
@ -187,11 +183,12 @@ void Window::queryActiveWorkspace() {
}
if (solo_) {
solo_class_ = (*active_window)["class"].asString();
solo_class_ = window_data_.class_name;
} else {
solo_class_ = "";
}
} else {
window_data_ = WindowData{};
all_floating_ = false;
hidden_ = false;
fullscreen_ = false;