From 62f8af8a39134326bb41c4923e9e1fe7aafbd4c6 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 13 May 2019 10:56:48 +0200 Subject: [PATCH] fix(Window): avoid multiple same classes --- resources/style.css | 3 +-- src/modules/sway/window.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/resources/style.css b/resources/style.css index ea88131..c008bfb 100644 --- a/resources/style.css +++ b/resources/style.css @@ -32,8 +32,7 @@ window#waybar.termite { } window#waybar.chromium { - background-color: #DEE1E6; - color: #000000; + background-color: #000000; border: none; } diff --git a/src/modules/sway/window.cpp b/src/modules/sway/window.cpp index 2bccb60..6caa16c 100644 --- a/src/modules/sway/window.cpp +++ b/src/modules/sway/window.cpp @@ -32,11 +32,15 @@ void Window::onCmd(const struct Ipc::ipc_response& res) { } if (nb == 0) { 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) { bar_.window.get_style_context()->remove_class("empty"); - bar_.window.get_style_context()->add_class("solo"); - if (!app_id.empty()) { + if (!bar_.window.get_style_context()->has_class("solo")) { + 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); } } else {