make getLayout is not static and set css classes for short name keyboard layout in getLayout method

This commit is contained in:
dimti
2025-10-10 11:35:47 +03:00
parent cd820a100d
commit bdf501a8a5
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ class Language : public waybar::ALabel, public EventHandler {
std::string short_description; std::string short_description;
}; };
static auto getLayout(const std::string&) -> Layout; auto getLayout(const std::string&) -> Layout;
std::mutex mutex_; std::mutex mutex_;
const Bar& bar_; const Bar& bar_;
+4 -4
View File
@@ -82,9 +82,7 @@ void Language::onEvent(const std::string& ev) {
layoutName = waybar::util::sanitize_string(layoutName); layoutName = waybar::util::sanitize_string(layoutName);
label_.get_style_context()->remove_class(layout_.short_name);
layout_ = getLayout(layoutName); layout_ = getLayout(layoutName);
label_.get_style_context()->add_class(layout_.short_name);
spdlog::debug("hyprland language onevent with {}", layoutName); spdlog::debug("hyprland language onevent with {}", layoutName);
@@ -105,9 +103,7 @@ void Language::initLanguage() {
searcher = waybar::util::sanitize_string(searcher); searcher = waybar::util::sanitize_string(searcher);
label_.get_style_context()->remove_class(layout_.short_name);
layout_ = getLayout(searcher); layout_ = getLayout(searcher);
label_.get_style_context()->add_class(layout_.short_name);
spdlog::debug("hyprland language initLanguage found {}", layout_.full_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_context_parse_default_ruleset(context);
rxkb_layout* layout = rxkb_layout_first(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) { while (layout != nullptr) {
std::string nameOfLayout = rxkb_layout_get_description(layout); std::string nameOfLayout = rxkb_layout_get_description(layout);
@@ -141,6 +139,8 @@ auto Language::getLayout(const std::string& fullName) -> Layout {
rxkb_context_unref(context); 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; return info;
} }