diff --git a/src/cli/input.rs b/src/cli/input.rs index aaf75aa5..ee253ebf 100644 --- a/src/cli/input.rs +++ b/src/cli/input.rs @@ -83,6 +83,28 @@ pub enum SeatCommand { UseHardwareCursor(UseHardwareCursorArgs), /// Set the size of the cursor. SetCursorSize(SetCursorSizeArgs), + /// Configure the simple, XCompose based input method. + SimpleIm(SimpleImArgs), +} + +#[derive(Args, Debug, Clone)] +pub struct SimpleImArgs { + #[clap(subcommand)] + pub command: SimpleImCommand, +} + +#[derive(Subcommand, Debug, Clone)] +pub enum SimpleImCommand { + /// Enable the simple IM. + /// + /// Even if the IM is enabled, it will not be used if an external IM is running. + Enable, + /// Disable the simple IM. + Disable, + /// Reload the simple IM. + /// + /// This is useful if you change the XCompose files after starting the compositor. + Reload, } impl Default for SeatCommand { @@ -460,6 +482,27 @@ impl Input { size: a.size, }); } + SeatCommand::SimpleIm(a) => match a.command { + SimpleImCommand::Enable | SimpleImCommand::Disable => { + self.handle_error(input, |e| { + eprintln!("Could not enable/disable the simple IM: {}", e); + }); + tc.send(jay_input::SetSimpleImEnabled { + self_id: input, + seat: &args.seat, + enabled: matches!(a.command, SimpleImCommand::Enable) as _, + }); + } + SimpleImCommand::Reload => { + self.handle_error(input, |e| { + eprintln!("Could not reload the simple IM: {}", e); + }); + tc.send(jay_input::ReloadSimpleIm { + self_id: input, + seat: &args.seat, + }); + } + }, } tc.round_trip().await; } diff --git a/src/ifs/jay_compositor.rs b/src/ifs/jay_compositor.rs index 05aa3064..7e1dde99 100644 --- a/src/ifs/jay_compositor.rs +++ b/src/ifs/jay_compositor.rs @@ -79,7 +79,7 @@ impl Global for JayCompositorGlobal { } fn version(&self) -> u32 { - 21 + 22 } fn required_caps(&self) -> ClientCaps { diff --git a/src/ifs/jay_input.rs b/src/ifs/jay_input.rs index dbcb75e3..531d2cd3 100644 --- a/src/ifs/jay_input.rs +++ b/src/ifs/jay_input.rs @@ -515,6 +515,30 @@ impl JayInputRequestHandler for JayInput { Ok(()) }) } + + fn set_simple_im_enabled( + &self, + req: SetSimpleImEnabled<'_>, + _slf: &Rc, + ) -> Result<(), Self::Error> { + self.or_error(|| { + let seat = self.seat(req.seat)?; + seat.set_simple_im_enabled(req.enabled != 0); + Ok(()) + }) + } + + fn reload_simple_im( + &self, + req: ReloadSimpleIm<'_>, + _slf: &Rc, + ) -> Result<(), Self::Error> { + self.or_error(|| { + let seat = self.seat(req.seat)?; + seat.reload_simple_im(); + Ok(()) + }) + } } object_base! { diff --git a/src/tools/tool_client.rs b/src/tools/tool_client.rs index 82f013ba..7a66b935 100644 --- a/src/tools/tool_client.rs +++ b/src/tools/tool_client.rs @@ -335,7 +335,7 @@ impl ToolClient { self_id: s.registry, name: s.jay_compositor.0, interface: JayCompositor.name(), - version: s.jay_compositor.1.min(21), + version: s.jay_compositor.1.min(22), id: id.into(), }); self.jay_compositor.set(Some(id)); diff --git a/wire/jay_input.txt b/wire/jay_input.txt index f94b95ce..2f81bb75 100644 --- a/wire/jay_input.txt +++ b/wire/jay_input.txt @@ -134,6 +134,15 @@ request set_middle_button_emulation (since = 19) { enabled: u32, } +request set_simple_im_enabled (since = 22) { + seat: str, + enabled: u32, +} + +request reload_simple_im (since = 22) { + seat: str, +} + # events event seat {