From 2e6bf549a05d1f4c72aed4b473626ccf9cd83cd0 Mon Sep 17 00:00:00 2001 From: dimti Date: Fri, 10 Oct 2025 11:52:59 +0300 Subject: [PATCH] Change label css classes in initial and on event language class method. Used in getLabel - make a strange behaviour --- src/modules/hyprland/language.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/hyprland/language.cpp b/src/modules/hyprland/language.cpp index 9aa97e81..3dd5aef7 100644 --- a/src/modules/hyprland/language.cpp +++ b/src/modules/hyprland/language.cpp @@ -82,7 +82,11 @@ void Language::onEvent(const std::string& ev) { layoutName = waybar::util::sanitize_string(layoutName); + label_.get_style_context()->remove_class(layout_.short_name); + spdlog::debug("hyprland language try to remove currently short_name css class {}", layout_.short_name); layout_ = getLayout(layoutName); + label_.get_style_context()->add_class(layout_.short_name); + spdlog::debug("hyprland language add new short_name css class {}", layout_.short_name); spdlog::debug("hyprland language onevent with {}", layoutName); @@ -103,7 +107,11 @@ void Language::initLanguage() { searcher = waybar::util::sanitize_string(searcher); + label_.get_style_context()->remove_class(layout_.short_name); + spdlog::debug("hyprland language try to remove currently short_name css class {}", layout_.short_name); layout_ = getLayout(searcher); + label_.get_style_context()->add_class(layout_.short_name); + spdlog::debug("hyprland language add new short_name css class {}", layout_.short_name); spdlog::debug("hyprland language initLanguage found {}", layout_.full_name); @@ -118,8 +126,6 @@ auto Language::getLayout(const std::string& fullName) -> Layout { rxkb_context_parse_default_ruleset(context); rxkb_layout* layout = rxkb_layout_first(context); - label_.get_style_context()->remove_class(layout_.short_name); - spdlog::debug("hyprland language try to remove currently short_name css class {}", layout_.short_name); while (layout != nullptr) { std::string nameOfLayout = rxkb_layout_get_description(layout); @@ -139,8 +145,6 @@ auto Language::getLayout(const std::string& fullName) -> Layout { rxkb_context_unref(context); - label_.get_style_context()->add_class(info.short_name); - spdlog::debug("hyprland language add new short_name css class {}", info.short_name); return info; }