wayland: add optional reis emulated input support
Add support for the Emulated Input protocol using the Rust library.
This commit is contained in:
parent
89c96c511a
commit
030ca29ddd
1 changed files with 93 additions and 0 deletions
|
|
@ -24,6 +24,13 @@ use crate::wayland::viewporter::wp_viewporter;
|
|||
use crate::wayland::viewporter::wp_viewport;
|
||||
use crate::wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_manager_v1;
|
||||
use crate::wayland::virtual_keyboard_unstable_v1::zwp_virtual_keyboard_v1;
|
||||
use reis::PendingRequestResult;
|
||||
use reis::ei::Context;
|
||||
use reis::ei::Event;
|
||||
use reis::ei::connection;
|
||||
use reis::ei::device;
|
||||
use reis::ei::keyboard;
|
||||
use reis::ei::seat;
|
||||
use std::io::Error;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
|
@ -49,6 +56,8 @@ pub struct Dispatcher {
|
|||
seat: Seat<Surface<Self>, VirtualKeyboard, Self>,
|
||||
gfx: Arc<Mutex<Graphics<Surface<Self>>>>,
|
||||
osk: Option<VisibilityManager>,
|
||||
|
||||
libei_caps: u64,
|
||||
}
|
||||
|
||||
impl Dispatcher {
|
||||
|
|
@ -106,6 +115,8 @@ impl Dispatcher {
|
|||
seat,
|
||||
gfx,
|
||||
osk: None,
|
||||
|
||||
libei_caps: 0,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -156,6 +167,88 @@ impl Dispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Dispatcher {
|
||||
fn dispatch_ei_connection(&mut self,
|
||||
_conn: connection::Connection,
|
||||
evt: connection::Event)
|
||||
{
|
||||
match evt {
|
||||
connection::Event::Ping { ping } => {
|
||||
ping.done(0);
|
||||
},
|
||||
connection::Event::Seat { .. } => (),
|
||||
_ => eprintln!("warn: unknown ei_connection event emitted"),
|
||||
};
|
||||
}
|
||||
|
||||
fn dispatch_ei_device(&mut self,
|
||||
dev: device::Device,
|
||||
evt: device::Event)
|
||||
{
|
||||
match evt {
|
||||
device::Event::DeviceType { .. } => (),
|
||||
device::Event::Done => (),
|
||||
device::Event::Frame { serial, .. } => {
|
||||
self.seat.keyboard_mut().set_ei_serial(serial);
|
||||
},
|
||||
device::Event::Interface { object } => {
|
||||
if let Some(kbd) = object.downcast() {
|
||||
self.seat.keyboard_mut().set_ei_keyboard(dev, kbd);
|
||||
}
|
||||
},
|
||||
device::Event::Name { .. } => (),
|
||||
device::Event::Resumed { serial } => {
|
||||
self.seat.keyboard_mut().set_ei_serial(serial);
|
||||
dev.start_emulating(serial, 0);
|
||||
},
|
||||
_ => eprintln!("warn: unknown ei_device event emitted"),
|
||||
};
|
||||
}
|
||||
|
||||
fn dispatch_ei_keyboard(&mut self, _kbd: keyboard::Keyboard, evt: keyboard::Event)
|
||||
{
|
||||
match evt {
|
||||
_ => eprintln!("warn: unknown ei_keyboard event emitted"),
|
||||
};
|
||||
}
|
||||
|
||||
fn dispatch_ei_seat(&mut self, seat: seat::Seat, evt: seat::Event)
|
||||
{
|
||||
match evt {
|
||||
seat::Event::Capability { mask, interface } => {
|
||||
if interface == "ei_keyboard" {
|
||||
self.libei_caps |= mask;
|
||||
}
|
||||
},
|
||||
seat::Event::Done => {
|
||||
seat.bind(self.libei_caps);
|
||||
},
|
||||
seat::Event::Device { .. } => (),
|
||||
seat::Event::Name { .. } => (),
|
||||
_ => eprintln!("warn: unknown ei_seat event emitted"),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn dispatch_ei(&mut self, ctx: &Context)
|
||||
{
|
||||
while let Some(evt) = ctx.pending_event() {
|
||||
let evt = match evt {
|
||||
PendingRequestResult::Request(e) => e,
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
match evt {
|
||||
Event::Connection(c, e) => self.dispatch_ei_connection(c, e),
|
||||
Event::Device(d, e) => self.dispatch_ei_device(d, e),
|
||||
Event::Keyboard(k, e) => self.dispatch_ei_keyboard(k, e),
|
||||
Event::Seat(s, e) => self.dispatch_ei_seat(s, e),
|
||||
_ => eprintln!("warn: unknown libei event emitted"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<wl_buffer::WlBuffer, u32> for Dispatcher {
|
||||
fn event(ctx: &mut Dispatcher,
|
||||
_buf: &wl_buffer::WlBuffer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue