Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 83346ca

Browse files
Narsilmaxbla
andauthoredAug 13, 2020
Linux grab (#52)
* WIP: add linux grabbing * add working linux grabbing (requires root) test_grab fails because simulate() operates on the level of x11, but grab() operates at a lower level, so never sees simulated events. * add a few more keys, better comments * Fixing unstable_grab for linux (with root privileges required.) * Rebase hiccup. * Adding cargo fmt * Clippy. * Fixing clippy on mac os + cast_ptr_alignment. * Fixing MacOS again ? * Correct clippy allow * Fixing windows test. Co-authored-by: Max Blachman <blachmanmax@gmail.com>
1 parent 848cb21 commit 83346ca

File tree

11 files changed

+599
-180
lines changed

11 files changed

+599
-180
lines changed
 

‎.github/workflows/rust.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828

2929
steps:
3030
- uses: actions/checkout@v2
31+
- name: CargoFmt
32+
run: rustup component add rustfmt
3133
- name: Dependencies
3234
run: ${{matrix.dependencies}}
3335
- name: Setup headless environment

‎Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ serde = {version = "1.0", features = ["derive"], optional=true}
1818

1919
[features]
2020
serialize = ["serde"]
21-
unstable_grab = []
21+
unstable_grab = ["evdev-rs", "epoll", "inotify"]
2222

2323
[target.'cfg(target_os = "macos")'.dependencies]
2424
lazy_static = "1.4.0"
25-
cocoa = "0.20"
25+
cocoa = "0.22"
2626
core-graphics = {version = "0.19.0", features = ["highsierra"]}
2727
core-foundation = {version = "0.7"}
2828
core-foundation-sys = {version = "0.7"}
@@ -31,7 +31,9 @@ core-foundation-sys = {version = "0.7"}
3131
[target.'cfg(target_os = "linux")'.dependencies]
3232
libc = "0.2"
3333
x11 = {version = "2.18", features = ["xlib", "xrecord", "xinput"]}
34-
xproto = "1.1"
34+
evdev-rs = {version = "0.4.0", optional=true}
35+
epoll = {version = "4.1.0", optional=true}
36+
inotify = {version = "0.8.2", default-features=false, optional=true}
3537

3638
[target.'cfg(target_os = "windows")'.dependencies]
3739
lazy_static = "1.4.0"
@@ -45,7 +47,6 @@ serde_json = "1.0"
4547
# to run thoses tests in sequence instead.
4648
serial_test = "0.4"
4749

48-
4950
[[example]]
5051
name = "serialize"
5152
required-features = ["serialize"]

‎examples/listen.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@ fn main() {
99

1010
fn callback(event: Event) {
1111
println!("My callback {:?}", event);
12-
match event.name {
13-
Some(_) => (), // println!("User wrote {:?}", string),
14-
None => (),
15-
}
1612
}

‎examples/serialize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use rdev::{Event, EventType, Key};
2-
use serde_json;
32
use std::time::SystemTime;
43

54
fn main() {

‎src/linux/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ pub fn convert_event(code: c_uchar, type_: c_int, x: f64, y: f64) -> Option<Even
3535
delta_x: 0,
3636
}),
3737
#[allow(clippy::identity_conversion)]
38-
code => Some(EventType::ButtonPress(Button::Unknown(code.into()))),
38+
code => Some(EventType::ButtonPress(Button::Unknown(code))),
3939
},
4040
xlib::ButtonRelease => match code {
4141
1 => Some(EventType::ButtonRelease(Button::Left)),
4242
2 => Some(EventType::ButtonRelease(Button::Middle)),
4343
3 => Some(EventType::ButtonRelease(Button::Right)),
4444
4 | 5 => None,
4545
#[allow(clippy::identity_conversion)]
46-
_ => Some(EventType::ButtonRelease(Button::Unknown(code.into()))),
46+
_ => Some(EventType::ButtonRelease(Button::Unknown(code))),
4747
},
4848
xlib::MotionNotify => Some(EventType::MouseMove { x, y }),
4949
_ => None,

0 commit comments

Comments
 (0)
Please sign in to comment.