From 4cd29eec3bbf0253cb0a09a401a254623273ded3 Mon Sep 17 00:00:00 2001 From: Richard Acayan Date: Fri, 27 Sep 2024 21:54:21 -0400 Subject: [PATCH 1/2] core: config: add config option to enable the wayland input method Having multiple input methods at once causes behaviour defined by the Wayland compositor. In a recent update by Phoc, the most recently started input method would take priority to demonstrate the instability. Add a configuration option so the Wayland input method can be disabled to accommodate a second input method. Also update the README with the new option. --- README.md | 1 + src/core/config.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 954811a..7b30b37 100644 --- a/README.md +++ b/README.md @@ -110,3 +110,4 @@ Configuration example: wayland: height: 185 + input-method: true diff --git a/src/core/config.rs b/src/core/config.rs index 853f53f..42c8832 100644 --- a/src/core/config.rs +++ b/src/core/config.rs @@ -16,6 +16,7 @@ pub struct Configuration { repeat: u64, layout: String, wayland_height: i32, + wayland_im_enable: bool, } impl Configuration { @@ -30,6 +31,13 @@ impl Configuration { let height = height.expect("Wayland height should be a 32-bit signed integer"); 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 @@ -39,6 +47,7 @@ impl Configuration { repeat: 25, layout: String::from("latn_qwerty_us.xml"), wayland_height: 185, + wayland_im_enable: true, }; if let Ok(file) = File::open("/etc/unfettered-keyboard.yaml") { @@ -106,4 +115,10 @@ impl Configuration { { self.wayland_height } + + #[inline(always)] + pub fn wayland_im_enable(&self) -> bool + { + self.wayland_im_enable + } } From 7276aa9f91506a37d5627339e61b7d3c412023cf Mon Sep 17 00:00:00 2001 From: Richard Acayan Date: Fri, 27 Sep 2024 22:05:41 -0400 Subject: [PATCH 2/2] wayland: only bind to input method when enabled Having multiple input methods at once causes behaviour defined by the Wayland compositor. In a recent update by Phoc, the most recently started input method would take priority to demonstrate the instability. Since the keyboard driver for Wayland can handle a emitting input without an input method, only try to bind to an input method when it is enabled. --- src/wayland/dispatcher.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/wayland/dispatcher.rs b/src/wayland/dispatcher.rs index 407f1db..6662569 100644 --- a/src/wayland/dispatcher.rs +++ b/src/wayland/dispatcher.rs @@ -68,13 +68,17 @@ impl Dispatcher { Err(_) => None, }; - let im_man = match globals.bind(&queue, 1..=1, ()) { - Ok(g) => Some(g), - Err(_) => None, - }; + let im_man = if cfg.wayland_im_enable() { + let _: Result + = globals.bind(&queue, 1..=1, ()); - let _: Result - = 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, ()) { Ok(g) => Some(g),