wayland: keyboard: track input method done events

This commit is contained in:
Richard Acayan 2024-08-04 21:38:14 -04:00
parent 551381f0b6
commit d3a17813c0
4 changed files with 36 additions and 1 deletions

View file

@ -184,6 +184,18 @@ impl<D: Display, K: Keyboard> Button<D, K> {
&self.layout
}
#[inline(always)]
pub fn keyboard(&self) -> &K
{
&self.kbd
}
#[inline(always)]
pub fn keyboard_mut(&mut self) -> &mut K
{
&mut self.kbd
}
#[inline(always)]
pub fn mod_state(&self) -> &[ModState; MODIFIERS_MAX]
{

View file

@ -450,7 +450,9 @@ impl Dispatch<zwp_input_method_v2::ZwpInputMethodV2, ()> for Dispatcher {
zwp_input_method_v2::Event::TextChangeCause { .. } => (),
zwp_input_method_v2::Event::ContentType { .. } => (),
zwp_input_method_v2::Event::SurroundingText { .. } => (),
zwp_input_method_v2::Event::Done => (),
zwp_input_method_v2::Event::Done => {
ctx.seat.keyboard_mut().done();
},
_ => eprintln!("warn: unknown zwp_input_method_v2 event emitted"),
}
}

View file

@ -26,6 +26,8 @@ pub struct VirtualKeyboard {
keymap: File,
keymap_id: u8,
im_serial: u32,
keycodes: HashMap<Keysym, u8>,
pressed: [Keysym; 248],
mod_state: u32,
@ -48,6 +50,8 @@ impl VirtualKeyboard {
keymap,
keymap_id: 1,
im_serial: 0,
keycodes: HashMap::with_capacity(248),
pressed: [Keysym::NoSymbol; 248],
mod_state: 0,
@ -77,6 +81,11 @@ impl VirtualKeyboard {
keycode).unwrap();
}
}
pub fn done(&mut self)
{
self.im_serial += 1;
}
}
impl Keyboard for VirtualKeyboard {

View file

@ -91,6 +91,18 @@ impl<D: Display, K: Keyboard,
self.button.layout()
}
#[inline(always)]
pub fn keyboard(&self) -> &K
{
self.button.keyboard()
}
#[inline(always)]
pub fn keyboard_mut(&mut self) -> &mut K
{
self.button.keyboard_mut()
}
#[inline(always)]
pub fn mod_state(&self) -> &[ModState]
{