Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,24 @@ jobs:
- run: sudo apt-get -qq update
- run: sudo apt-get install -y libxkbcommon-dev
- run: cargo fmt --all -- --check

# Make sure there are no broken intra-doc links with and without features
- run: RUSTDOCFLAGS="--deny warnings" cargo doc --no-deps --all-features
- run: RUSTDOCFLAGS="--deny warnings" cargo doc --no-deps

- run: cargo clippy --all-features -- -Dwarnings
if: matrix.rust_version != 'stable'
- run: cargo clippy --all-features --all-targets -- -Dwarnings
if: matrix.rust_version == 'stable'

# Sanity check: generic code doesn't depend on features
- run: cargo check

- run: cargo build --all-features
if: matrix.rust_version != 'stable'
- run: cargo build --all-features --examples
if: matrix.rust_version == 'stable'

- uses: actions/upload-artifact@v4
with:
name: reis-demo-server
Expand Down
15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ calloop = { version = "0.14.0", optional = true }
rustix = { version = "0.38.3", features = ["event", "fs", "net", "time"] }
futures = { version = "0.3.28", optional = true }
tokio = { version = "1.31.0", features = ["net"], optional = true }
enumflags2 = "0.7.12"

[dev-dependencies]
ashpd = "0.11.0"
Expand All @@ -23,6 +24,20 @@ tokio = { version = "1.31.0", features = ["rt", "macros"] }
signal-hook = "0.3.17"
pollster = "0.4.0"

[lints.rust]
missing_docs = "warn"

[lints.clippy]
pedantic = "warn"
# Blocked by MSRV
#allow_attributes = "warn"
#allow_attributes_without_reason = "warn"
#should_panic_without_expect = "warn"
str_to_string = "warn"
string_to_string = "warn"
cast_possible_wrap = { level = "allow", priority = 1 }
cast_possible_truncation = { level = "allow", priority = 1 }

[features]
tokio = ["dep:tokio", "futures"]
# Experimental and somewhat incomplete
Expand Down
30 changes: 15 additions & 15 deletions examples/list-devices.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! List devices with sender context type.

use ashpd::desktop::remote_desktop::{DeviceType, RemoteDesktop};
use futures::stream::StreamExt;
use reis::{ei, tokio::EiEventStream, PendingRequestResult};
Expand All @@ -20,6 +22,7 @@ struct DeviceData {
}

impl DeviceData {
#[allow(dead_code)]
fn interface<T: reis::Interface>(&self) -> Option<T> {
self.interfaces.get(T::NAME)?.clone().downcast()
}
Expand All @@ -37,10 +40,10 @@ struct State {
impl State {
fn handle_event(&mut self, event: ei::Event) {
match event {
ei::Event::Handshake(handshake, request) => panic!(),
ei::Event::Connection(connection, request) => match request {
ei::Event::Handshake(_handshake, _request) => panic!(),
ei::Event::Connection(_connection, request) => match request {
ei::connection::Event::Seat { seat } => {
self.seats.insert(seat, Default::default());
self.seats.insert(seat, SeatData::default());
}
ei::connection::Event::Ping { ping } => {
ping.done(0);
Expand Down Expand Up @@ -71,7 +74,7 @@ impl State {
}
ei::seat::Event::Device { device } => {
data.devices.push(device.clone());
self.devices.insert(device, Default::default());
self.devices.insert(device, DeviceData::default());
}
_ => {}
}
Expand All @@ -87,7 +90,7 @@ impl State {
}
ei::device::Event::Interface { object } => {
data.interfaces
.insert(object.interface().to_string(), object);
.insert(object.interface().to_owned(), object);
}
ei::device::Event::Done => {
data.done = true;
Expand All @@ -100,23 +103,20 @@ impl State {
data.interfaces.keys().collect::<Vec<_>>()
);
}
ei::device::Event::Resumed { serial } => {}
_ => {}
}
}
ei::Event::Callback(callback, request) => match request {
ei::callback::Event::Done { callback_data: _ } => {
// TODO: Callback being called after first device, but not later ones?
// self.print_and_exit_if_done();
}
_ => {}
},
ei::Event::Callback(_callback, ei::callback::Event::Done { .. }) => {
// TODO: Callback being called after first device, but not later ones?
// self.print_and_exit_if_done();
}
_ => {}
}

let _ = self.context.flush();
}

#[allow(dead_code)]
fn print_and_exit_if_done(&self) {
if !(self.seats.values().all(|x| x.done) && self.devices.values().all(|x| x.done)) {
return;
Expand Down Expand Up @@ -171,10 +171,10 @@ async fn main() {
while let Some(result) = events.next().await {
let event = match result.unwrap() {
PendingRequestResult::Request(event) => event,
PendingRequestResult::ParseError(msg) => {
PendingRequestResult::ParseError(_msg) => {
todo!()
}
PendingRequestResult::InvalidObject(object_id) => {
PendingRequestResult::InvalidObject(_object_id) => {
// TODO
continue;
}
Expand Down
26 changes: 14 additions & 12 deletions examples/receive-synchronous.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Capturing input synchronously.

use ashpd::desktop::input_capture::{Barrier, Capabilities, InputCapture};
use pollster::FutureExt as _;
use reis::{ei, event::DeviceCapability};
Expand Down Expand Up @@ -34,7 +36,7 @@ async fn open_connection() -> ei::Context {
let x = region.x_offset();
let y = region.y_offset();
let w = region.width() as i32;
let h = region.height() as i32;
let _h = region.height() as i32;
Barrier::new(NonZero::new(n as u32 + 1).unwrap(), (x, y, x + w - 1, y))
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -64,25 +66,25 @@ fn main() {
match &event {
reis::event::EiEvent::SeatAdded(evt) => {
// println!(" capabilities: {:?}", evt.seat);
evt.seat.bind_capabilities(&[
DeviceCapability::Pointer,
DeviceCapability::PointerAbsolute,
DeviceCapability::Keyboard,
DeviceCapability::Touch,
DeviceCapability::Scroll,
DeviceCapability::Button,
]);
context.flush();
evt.seat.bind_capabilities(
DeviceCapability::Pointer
| DeviceCapability::PointerAbsolute
| DeviceCapability::Keyboard
| DeviceCapability::Touch
| DeviceCapability::Scroll
| DeviceCapability::Button,
);
let _ = context.flush();
}
reis::event::EiEvent::DeviceAdded(evt) => {
println!(" seat: {:?}", evt.device.seat().name());
println!(" type: {:?}", evt.device.device_type());
if let Some(dimensions) = evt.device.dimensions() {
println!(" dimensions: {:?}", dimensions);
println!(" dimensions: {dimensions:?}");
}
println!(" regions: {:?}", evt.device.regions());
if let Some(keymap) = evt.device.keymap() {
println!(" keymap: {:?}", keymap);
println!(" keymap: {keymap:?}");
}
// Interfaces?
}
Expand Down
28 changes: 15 additions & 13 deletions examples/receive.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Capturing input asynchronously.

use ashpd::desktop::input_capture::{Barrier, Capabilities, InputCapture};
use futures::stream::StreamExt;
use reis::{ei, event::DeviceCapability};
Expand All @@ -12,7 +14,7 @@ async fn open_connection() -> ei::Context {
let session = input_capture
.create_session(
None,
(Capabilities::Keyboard | Capabilities::Pointer | Capabilities::Touchscreen).into(),
Capabilities::Keyboard | Capabilities::Pointer | Capabilities::Touchscreen,
)
.await
.unwrap()
Expand All @@ -34,7 +36,7 @@ async fn open_connection() -> ei::Context {
let x = region.x_offset();
let y = region.y_offset();
let w = region.width() as i32;
let h = region.height() as i32;
let _h = region.height() as i32;
Barrier::new(NonZero::new(n as u32 + 1).unwrap(), (x, y, x + w - 1, y))
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -65,25 +67,25 @@ async fn main() {
match &event {
reis::event::EiEvent::SeatAdded(evt) => {
// println!(" capabilities: {:?}", evt.seat);
evt.seat.bind_capabilities(&[
DeviceCapability::Pointer,
DeviceCapability::PointerAbsolute,
DeviceCapability::Keyboard,
DeviceCapability::Touch,
DeviceCapability::Scroll,
DeviceCapability::Button,
]);
context.flush();
evt.seat.bind_capabilities(
DeviceCapability::Pointer
| DeviceCapability::PointerAbsolute
| DeviceCapability::Keyboard
| DeviceCapability::Touch
| DeviceCapability::Scroll
| DeviceCapability::Button,
);
let _ = context.flush();
}
reis::event::EiEvent::DeviceAdded(evt) => {
println!(" seat: {:?}", evt.device.seat().name());
println!(" type: {:?}", evt.device.device_type());
if let Some(dimensions) = evt.device.dimensions() {
println!(" dimensions: {:?}", dimensions);
println!(" dimensions: {dimensions:?}");
}
println!(" regions: {:?}", evt.device.regions());
if let Some(keymap) = evt.device.keymap() {
println!(" keymap: {:?}", keymap);
println!(" keymap: {keymap:?}");
}
// Interfaces?
}
Expand Down
Loading