fcitx: capture variant by regex

This commit is contained in:
galister
2025-12-16 11:21:56 +09:00
parent c19c9da5f0
commit 2b3cdc3c8b
2 changed files with 23 additions and 9 deletions

View File

@@ -578,10 +578,18 @@ pub struct XkbKeymap {
}
impl XkbKeymap {
pub fn from_layout_str(layout: &str) -> Option<Self> {
pub fn from_layout_variant(layout: &str, variant: &str) -> Option<Self> {
let context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
xkb::Keymap::new_from_names(&context, "", "", layout, "", None, xkb::COMPILE_NO_FLAGS)
.map(|inner| XkbKeymap { inner })
xkb::Keymap::new_from_names(
&context,
"",
"",
layout,
variant,
None,
xkb::COMPILE_NO_FLAGS,
)
.map(|inner| XkbKeymap { inner })
}
pub fn get_name(&self) -> Option<&str> {