Merge branch 'input-method-enable' of https://gitlab.com/flamingradian/unfettered-keyboard into HEAD

This commit is contained in:
Richard Acayan 2024-10-17 21:12:30 -04:00
commit 2eba66cca7
3 changed files with 26 additions and 6 deletions

View file

@ -110,3 +110,4 @@ Configuration example:
wayland: wayland:
height: 185 height: 185
input-method: true

View file

@ -16,6 +16,7 @@ pub struct Configuration {
repeat: u64, repeat: u64,
layout: String, layout: String,
wayland_height: i32, wayland_height: i32,
wayland_im_enable: bool,
} }
impl Configuration { impl Configuration {
@ -30,6 +31,13 @@ impl Configuration {
let height = height.expect("Wayland height should be a 32-bit signed integer"); let height = height.expect("Wayland height should be a 32-bit signed integer");
self.wayland_height = height; self.wayland_height = height;
} }
let im_enable = yaml.get(&Yaml::String(String::from("input-method")));
if let Some(im_enable) = im_enable {
let im_enable = im_enable.as_bool();
let im_enable = im_enable.expect("Wayland height should be a 32-bit signed integer");
self.wayland_im_enable = im_enable;
}
} }
pub fn load() -> Result<Self, LoadError> pub fn load() -> Result<Self, LoadError>
@ -39,6 +47,7 @@ impl Configuration {
repeat: 25, repeat: 25,
layout: String::from("latn_qwerty_us.xml"), layout: String::from("latn_qwerty_us.xml"),
wayland_height: 185, wayland_height: 185,
wayland_im_enable: true,
}; };
if let Ok(file) = File::open("/etc/unfettered-keyboard.yaml") { if let Ok(file) = File::open("/etc/unfettered-keyboard.yaml") {
@ -104,4 +113,10 @@ impl Configuration {
{ {
self.wayland_height self.wayland_height
} }
#[inline(always)]
pub fn wayland_im_enable(&self) -> bool
{
self.wayland_im_enable
}
} }

View file

@ -68,14 +68,18 @@ impl Dispatcher {
Err(_) => None, Err(_) => None,
}; };
let im_man = match globals.bind(&queue, 1..=1, ()) { let im_man = if cfg.wayland_im_enable() {
Ok(g) => Some(g),
Err(_) => None,
};
let _: Result<zwp_input_method_v1::ZwpInputMethodV1, BindError> let _: Result<zwp_input_method_v1::ZwpInputMethodV1, BindError>
= globals.bind(&queue, 1..=1, ()); = globals.bind(&queue, 1..=1, ());
match globals.bind(&queue, 1..=1, ()) {
Ok(g) => Some(g),
Err(_) => None,
}
} else {
None
};
let frac_scale_man = match globals.bind(&queue, 1..=1, ()) { let frac_scale_man = match globals.bind(&queue, 1..=1, ()) {
Ok(g) => Some(g), Ok(g) => Some(g),
Err(_) => None, Err(_) => None,