From eaf7e368dfaf38c3930db56c77258bf1b1241a40 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Wed, 13 May 2026 15:40:38 +0200 Subject: [PATCH 1/2] Move usage example to `./examples` This will allow: - the maintainers: to check that it still compiles, run Clippy on it in CI, etc. - the users: to directly run the example using `cargo run --example event_loop` --- README.md | 38 +------------------------------------- examples/event_loop.rs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 37 deletions(-) create mode 100644 examples/event_loop.rs diff --git a/README.md b/README.md index 8f214f6..d6acbf5 100644 --- a/README.md +++ b/README.md @@ -31,40 +31,4 @@ Fedora dnf install libinput-devel ``` -Configure and run event loop: - -```rust -use input::{Libinput, LibinputInterface}; -use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY}; -use std::fs::{File, OpenOptions}; -use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd}; -use std::path::Path; - -struct Interface; - -impl LibinputInterface for Interface { - fn open_restricted(&mut self, path: &Path, flags: i32) -> Result { - OpenOptions::new() - .custom_flags(flags) - .read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR)) - .write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR)) - .open(path) - .map(|file| file.into()) - .map_err(|err| err.raw_os_error().unwrap()) - } - fn close_restricted(&mut self, fd: OwnedFd) { - drop(File::from(fd)); - } -} - -fn main() { - let mut input = Libinput::new_with_udev(Interface); - input.udev_assign_seat("seat0").unwrap(); - loop { - input.dispatch().unwrap(); - for event in &mut input { - println!("Got event: {:?}", event); - } - } -} -``` +For usage examples, see [Examples](https://github.com/Smithay/input.rs/tree/master/examples). diff --git a/examples/event_loop.rs b/examples/event_loop.rs new file mode 100644 index 0000000..495b6a6 --- /dev/null +++ b/examples/event_loop.rs @@ -0,0 +1,35 @@ +//! Configure and run event loop + +use input::{Libinput, LibinputInterface}; +use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY}; +use std::fs::{File, OpenOptions}; +use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd}; +use std::path::Path; + +struct Interface; + +impl LibinputInterface for Interface { + fn open_restricted(&mut self, path: &Path, flags: i32) -> Result { + OpenOptions::new() + .custom_flags(flags) + .read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR)) + .write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR)) + .open(path) + .map(|file| file.into()) + .map_err(|err| err.raw_os_error().unwrap()) + } + fn close_restricted(&mut self, fd: OwnedFd) { + drop(File::from(fd)); + } +} + +fn main() { + let mut input = Libinput::new_with_udev(Interface); + input.udev_assign_seat("seat0").unwrap(); + loop { + input.dispatch().unwrap(); + for event in &mut input { + println!("Got event: {:?}", event); + } + } +} From eb13ae1a9b7e0afc8aadea93a606ad354530799d Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Wed, 13 May 2026 15:50:08 +0200 Subject: [PATCH 2/2] Run checks on it in CI --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdfcfdd..df58ba3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: - uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --all --all-features + args: --all --all-features --all-targets check-minimal: runs-on: ubuntu-latest @@ -122,7 +122,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: check - args: --all --all-features -Z minimal-versions + args: --all --all-features --all-targets -Z minimal-versions test: needs: