diff --git a/Cargo.lock b/Cargo.lock index 5aafabe1a..861c81ddb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3136,9 +3136,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "log-panics" @@ -4540,6 +4540,18 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +[[package]] +name = "reis" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abba0904a3d6c68c847b69eab28e8566be30d5a45805f69f9e8073f23500a710" +dependencies = [ + "calloop 0.14.3", + "enumflags2", + "log", + "rustix 1.1.2", +] + [[package]] name = "renderdoc-sys" version = "1.1.0" @@ -4992,7 +5004,7 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "smithay" version = "0.7.0" -source = "git+https://github.com/smithay/smithay.git?rev=3d3f9e3#3d3f9e359352d95cffd1e53287d57df427fcbd34" +source = "git+https://github.com/ids1024/smithay?branch=reis#587a092e79d716d097efefab07c52dc936eb317d" dependencies = [ "aliasable", "appendlist", @@ -5021,6 +5033,7 @@ dependencies = [ "pkg-config", "profiling", "rand 0.9.2", + "reis", "rustix 1.1.2", "scopeguard", "sha2", diff --git a/Cargo.toml b/Cargo.toml index 4218c5601..82b619a79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,6 +107,7 @@ features = [ "backend_winit", "backend_vulkan", "backend_x11", + "backend_libei", "desktop", "renderer_glow", "renderer_multi", @@ -148,4 +149,5 @@ cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" } [patch.crates-io] -smithay = { git = "https://github.com/smithay/smithay.git", rev = "3d3f9e3" } +# smithay = { git = "https://github.com/smithay/smithay.git", rev = "3d3f9e3" } +smithay = {git = "https://github.com/ids1024/smithay", branch = "reis"} diff --git a/src/lib.rs b/src/lib.rs index 0fbb38d2f..253ac7e0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,6 +35,7 @@ pub mod dbus; pub mod debug; pub mod hooks; pub mod input; +pub mod libei; mod logger; pub mod session; pub mod shell; @@ -156,6 +157,8 @@ pub fn run(hooks: crate::hooks::Hooks) -> Result<(), Box> { // 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"); } diff --git a/src/libei.rs b/src/libei.rs new file mode 100644 index 000000000..c0c1ed3e7 --- /dev/null +++ b/src/libei.rs @@ -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(); +}