mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Use already existing queryActiveWorkspace()
This commit is contained in:
parent
c4bace504c
commit
c5f1771375
@ -26,7 +26,7 @@ class Window : public waybar::ALabel, public EventHandler {
|
|||||||
|
|
||||||
struct WindowData {
|
struct WindowData {
|
||||||
bool floating;
|
bool floating;
|
||||||
int monitor;
|
int monitor = -1;
|
||||||
std::string class_name;
|
std::string class_name;
|
||||||
std::string initial_class_name;
|
std::string initial_class_name;
|
||||||
std::string title;
|
std::string title;
|
||||||
@ -46,8 +46,6 @@ class Window : public waybar::ALabel, public EventHandler {
|
|||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
const Bar& bar_;
|
const Bar& bar_;
|
||||||
util::JsonParser parser_;
|
util::JsonParser parser_;
|
||||||
std::string last_window_address_;
|
|
||||||
std::string last_title_;
|
|
||||||
WindowData window_data_;
|
WindowData window_data_;
|
||||||
Workspace workspace_;
|
Workspace workspace_;
|
||||||
std::string solo_class_;
|
std::string solo_class_;
|
||||||
|
@ -46,18 +46,13 @@ auto Window::update() -> void {
|
|||||||
std::string window_name = waybar::util::sanitize_string(workspace_.last_window_title);
|
std::string window_name = waybar::util::sanitize_string(workspace_.last_window_title);
|
||||||
std::string window_address = workspace_.last_window;
|
std::string window_address = workspace_.last_window;
|
||||||
|
|
||||||
if (window_name != last_title_) {
|
if (window_name != window_data_.title) {
|
||||||
if (window_name.empty()) {
|
if (window_name.empty()) {
|
||||||
label_.get_style_context()->add_class("empty");
|
label_.get_style_context()->add_class("empty");
|
||||||
} else {
|
} else {
|
||||||
label_.get_style_context()->remove_class("empty");
|
label_.get_style_context()->remove_class("empty");
|
||||||
}
|
}
|
||||||
last_title_ = window_name;
|
window_data_.title = window_name;
|
||||||
}
|
|
||||||
|
|
||||||
if (window_address != last_window_address_) {
|
|
||||||
last_window_address_ = window_address;
|
|
||||||
window_data_ = getWindowData(window_address);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!format_.empty()) {
|
if (!format_.empty()) {
|
||||||
@ -165,6 +160,7 @@ void Window::queryActiveWorkspace() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window_data_ = WindowData::parse(*active_window);
|
||||||
std::vector<Json::Value> workspace_windows;
|
std::vector<Json::Value> workspace_windows;
|
||||||
std::copy_if(clients.begin(), clients.end(), std::back_inserter(workspace_windows),
|
std::copy_if(clients.begin(), clients.end(), std::back_inserter(workspace_windows),
|
||||||
[&](Json::Value window) {
|
[&](Json::Value window) {
|
||||||
@ -187,11 +183,12 @@ void Window::queryActiveWorkspace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (solo_) {
|
if (solo_) {
|
||||||
solo_class_ = (*active_window)["class"].asString();
|
solo_class_ = window_data_.class_name;
|
||||||
} else {
|
} else {
|
||||||
solo_class_ = "";
|
solo_class_ = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
window_data_ = WindowData{};
|
||||||
all_floating_ = false;
|
all_floating_ = false;
|
||||||
hidden_ = false;
|
hidden_ = false;
|
||||||
fullscreen_ = false;
|
fullscreen_ = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user