Skip to content

Commit c9692b8

Browse files
committed
WIP Ei protocol support
libei: Update for new API update Handle error cargo
1 parent 4a2e76a commit c9692b8

4 files changed

Lines changed: 75 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 23 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ features = [
107107
"backend_winit",
108108
"backend_vulkan",
109109
"backend_x11",
110+
"backend_libei",
110111
"desktop",
111112
"renderer_glow",
112113
"renderer_multi",
@@ -148,4 +149,5 @@ cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch
148149
cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" }
149150

150151
[patch.crates-io]
151-
smithay = { git = "https://github.com/smithay/smithay.git", rev = "3d3f9e3" }
152+
# smithay = { git = "https://github.com/smithay/smithay.git", rev = "3d3f9e3" }
153+
smithay = {git = "https://github.com/ids1024/smithay", branch = "reis"}

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub mod dbus;
3535
pub mod debug;
3636
pub mod hooks;
3737
pub mod input;
38+
pub mod libei;
3839
mod logger;
3940
pub mod session;
4041
pub mod shell;
@@ -156,6 +157,8 @@ pub fn run(hooks: crate::hooks::Hooks) -> Result<(), Box<dyn Error>> {
156157
// init backend
157158
backend::init_backend_auto(&display, &mut event_loop, &mut state)?;
158159

160+
libei::listen_eis(&event_loop.handle());
161+
159162
if let Err(err) = theme::watch_theme(event_loop.handle()) {
160163
warn!(?err, "Failed to watch theme");
161164
}

src/libei.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use reis::calloop::EisListenerSource;
2+
use reis::eis;
3+
use smithay::reexports::reis;
4+
5+
use smithay::backend::libei::{EiInput, EiInputEvent};
6+
use smithay::input::keyboard::XkbConfig;
7+
use smithay::reexports::calloop;
8+
9+
use crate::state::State;
10+
11+
pub fn listen_eis(handle: &calloop::LoopHandle<'static, State>) {
12+
let listener = match eis::Listener::bind_auto() {
13+
Ok(listener) => listener,
14+
Err(err) => {
15+
tracing::error!("Failed to bind EI listener socket: {}", err);
16+
return;
17+
}
18+
};
19+
20+
unsafe { std::env::set_var("LIBEI_SOCKET", listener.path()) };
21+
22+
let listener_source = EisListenerSource::new(listener);
23+
let handle_clone = handle.clone();
24+
handle
25+
.insert_source(listener_source, move |context, _, _| {
26+
let source = EiInput::new(context);
27+
handle_clone
28+
.insert_source(source, |event, connection, data| match event {
29+
EiInputEvent::Connected => {
30+
let seat = connection.add_seat("default");
31+
// TODO config
32+
let _ = seat.add_keyboard("virtual keyboard", XkbConfig::default());
33+
seat.add_pointer("virtual pointer");
34+
seat.add_pointer_absolute("virtual absoulte pointer");
35+
seat.add_touch("virtual touch");
36+
}
37+
EiInputEvent::Disconnected => {}
38+
EiInputEvent::Event(event) => {
39+
data.process_input_event(event);
40+
}
41+
})
42+
.unwrap();
43+
Ok(calloop::PostAction::Continue)
44+
})
45+
.unwrap();
46+
}

0 commit comments

Comments
 (0)