fix(Window): avoid multiple same classes

This commit is contained in:
Alex 2019-05-13 10:56:48 +02:00
parent d5a9eccb7b
commit 62f8af8a39
2 changed files with 8 additions and 5 deletions

View File

@ -32,8 +32,7 @@ window#waybar.termite {
} }
window#waybar.chromium { window#waybar.chromium {
background-color: #DEE1E6; background-color: #000000;
color: #000000;
border: none; border: none;
} }

View File

@ -32,11 +32,15 @@ void Window::onCmd(const struct Ipc::ipc_response& res) {
} }
if (nb == 0) { if (nb == 0) {
bar_.window.get_style_context()->remove_class("solo"); bar_.window.get_style_context()->remove_class("solo");
bar_.window.get_style_context()->add_class("empty"); if (!bar_.window.get_style_context()->has_class("empty")) {
bar_.window.get_style_context()->add_class("empty");
}
} else if (nb == 1) { } else if (nb == 1) {
bar_.window.get_style_context()->remove_class("empty"); bar_.window.get_style_context()->remove_class("empty");
bar_.window.get_style_context()->add_class("solo"); if (!bar_.window.get_style_context()->has_class("solo")) {
if (!app_id.empty()) { bar_.window.get_style_context()->add_class("solo");
}
if (!app_id.empty() && !bar_.window.get_style_context()->has_class(app_id)) {
bar_.window.get_style_context()->add_class(app_id); bar_.window.get_style_context()->add_class(app_id);
} }
} else { } else {