Initial Ei protocol support
This commit is contained in:
parent
861b732671
commit
e939a72b30
3 changed files with 50 additions and 0 deletions
|
|
@ -97,6 +97,7 @@ features = [
|
|||
"backend_drm",
|
||||
"backend_gbm",
|
||||
"backend_egl",
|
||||
"backend_libei",
|
||||
"backend_libinput",
|
||||
"backend_session_libseat",
|
||||
"backend_udev",
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ pub mod dbus;
|
|||
pub mod debug;
|
||||
pub mod hooks;
|
||||
pub mod input;
|
||||
pub mod libei;
|
||||
mod logger;
|
||||
pub mod session;
|
||||
pub mod shell;
|
||||
|
|
@ -179,6 +180,8 @@ pub fn run(hooks: crate::hooks::Hooks) -> Result<(), Box<dyn Error>> {
|
|||
// init backend
|
||||
backend::init_backend_auto(&display, &mut event_loop, &mut state)?;
|
||||
|
||||
libei::listen_eis(&event_loop.handle());
|
||||
|
||||
if let Err(err) = theme::watch_theme(event_loop.handle()) {
|
||||
warn!(?err, "Failed to watch theme");
|
||||
}
|
||||
|
|
|
|||
46
src/libei.rs
Normal file
46
src/libei.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
use reis::calloop::EisListenerSource;
|
||||
use reis::eis;
|
||||
use smithay::reexports::reis;
|
||||
|
||||
use smithay::backend::libei::{EiInput, EiInputEvent};
|
||||
use smithay::input::keyboard::XkbConfig;
|
||||
use smithay::reexports::calloop;
|
||||
|
||||
use crate::state::State;
|
||||
|
||||
pub fn listen_eis(handle: &calloop::LoopHandle<'static, State>) {
|
||||
let listener = match eis::Listener::bind_auto() {
|
||||
Ok(listener) => listener,
|
||||
Err(err) => {
|
||||
tracing::error!("Failed to bind EI listener socket: {}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
unsafe { std::env::set_var("LIBEI_SOCKET", listener.path()) };
|
||||
|
||||
let listener_source = EisListenerSource::new(listener);
|
||||
let handle_clone = handle.clone();
|
||||
handle
|
||||
.insert_source(listener_source, move |context, _, _| {
|
||||
let source = EiInput::new(context);
|
||||
handle_clone
|
||||
.insert_source(source, |event, connection, data| match event {
|
||||
EiInputEvent::Connected => {
|
||||
let seat = connection.add_seat("default");
|
||||
// TODO config
|
||||
let _ = seat.add_keyboard("virtual keyboard", XkbConfig::default());
|
||||
seat.add_pointer("virtual pointer");
|
||||
seat.add_pointer_absolute("virtual absoulte pointer");
|
||||
seat.add_touch("virtual touch");
|
||||
}
|
||||
EiInputEvent::Disconnected => {}
|
||||
EiInputEvent::Event(event) => {
|
||||
data.process_input_event(event);
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
Ok(calloop::PostAction::Continue)
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue