From bdf501a8a5d7377491f00acabe2df85449697cbd Mon Sep 17 00:00:00 2001 From: dimti Date: Fri, 10 Oct 2025 11:35:47 +0300 Subject: [PATCH] make getLayout is not static and set css classes for short name keyboard layout in getLayout method --- include/modules/hyprland/language.hpp | 2 +- src/modules/hyprland/language.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/modules/hyprland/language.hpp b/include/modules/hyprland/language.hpp index ec59e5c3..d1469f60 100644 --- a/include/modules/hyprland/language.hpp +++ b/include/modules/hyprland/language.hpp @@ -30,7 +30,7 @@ class Language : public waybar::ALabel, public EventHandler { std::string short_description; }; - static auto getLayout(const std::string&) -> Layout; + auto getLayout(const std::string&) -> Layout; std::mutex mutex_; const Bar& bar_; diff --git a/src/modules/hyprland/language.cpp b/src/modules/hyprland/language.cpp index dd966b17..9aa97e81 100644 --- a/src/modules/hyprland/language.cpp +++ b/src/modules/hyprland/language.cpp @@ -82,9 +82,7 @@ void Language::onEvent(const std::string& ev) { layoutName = waybar::util::sanitize_string(layoutName); - label_.get_style_context()->remove_class(layout_.short_name); layout_ = getLayout(layoutName); - label_.get_style_context()->add_class(layout_.short_name); spdlog::debug("hyprland language onevent with {}", layoutName); @@ -105,9 +103,7 @@ void Language::initLanguage() { searcher = waybar::util::sanitize_string(searcher); - label_.get_style_context()->remove_class(layout_.short_name); layout_ = getLayout(searcher); - label_.get_style_context()->add_class(layout_.short_name); spdlog::debug("hyprland language initLanguage found {}", layout_.full_name); @@ -122,6 +118,8 @@ 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); @@ -141,6 +139,8 @@ 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; }