Skip to content
Open
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
17 changes: 8 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use evdev::{
uinput::VirtualDevice, AbsInfo, AbsoluteAxisCode, AttributeSet, EventType, InputEvent, KeyCode,
RelativeAxisCode, UinputAbsSetup,
};
use once_cell::sync::Lazy;
use std::ffi::{c_int, c_uint, c_ulong};
use std::sync::Mutex;

Expand All @@ -19,7 +18,7 @@ pub struct Display {
_marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

static DEVICE: Lazy<Mutex<VirtualDevice>> = Lazy::new(|| {
static DEVICE: std::sync::LazyLock<Mutex<VirtualDevice>> = std::sync::LazyLock::new(|| {
let size = get_axes_range();
Mutex::new(
VirtualDevice::builder()
Expand Down Expand Up @@ -79,10 +78,10 @@ pub extern "C" fn XTestFakeKeyEvent(
dev.emit(&[InputEvent::new_now(
EventType::KEY.0,
key.0,
is_press as i32,
i32::from(is_press),
)])
.unwrap();
1
return 1;
}

#[repr(u8)]
Expand All @@ -99,7 +98,7 @@ enum MouseButtons {
impl TryFrom<u32> for MouseButtons {
type Error = u32;
fn try_from(value: u32) -> Result<Self, Self::Error> {
use MouseButtons::*;
use MouseButtons::{LeftClick, MiddleClick, RightClick, ScrollUp, ScrollDown, Side, Extra};
match value {
1 => Ok(LeftClick),
2 => Ok(MiddleClick),
Expand Down Expand Up @@ -158,10 +157,10 @@ pub extern "C" fn XTestFakeButtonEvent(
dev.emit(&[InputEvent::new_now(
EventType::KEY.0,
key.0,
is_press as i32,
i32::from(is_press),
)])
.unwrap();
1
return 1;
}

#[no_mangle]
Expand All @@ -177,7 +176,7 @@ pub extern "C" fn XTestFakeRelativeMotionEvent(
InputEvent::new_now(EventType::RELATIVE.0, RelativeAxisCode::REL_Y.0, y),
];
dev.emit(&events).unwrap();
1
return 1;
}

#[no_mangle]
Expand All @@ -194,5 +193,5 @@ pub extern "C" fn XTestFakeMotionEvent(
InputEvent::new_now(EventType::ABSOLUTE.0, AbsoluteAxisCode::ABS_Y.0, y),
];
dev.emit(&events).unwrap();
1
return 1;
}
10 changes: 5 additions & 5 deletions src/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn get_axes_range() -> DisplaySize {
let mut data = OutputData::default();
queue.roundtrip(&mut data).unwrap();

for output in data.wl_outputs.iter() {
for output in &data.wl_outputs {
data.output_man
.as_ref()
.unwrap()
Expand All @@ -47,9 +47,9 @@ impl Dispatch<zxdg_output_v1::ZxdgOutputV1, ()> for OutputData {
state: &mut Self,
_: &zxdg_output_v1::ZxdgOutputV1,
event: zxdg_output_v1::Event,
_: &(),
(): &(),
_: &Connection,
_: &QueueHandle<OutputData>,
_: &QueueHandle<Self>,
) {
if let zxdg_output_v1::Event::LogicalSize { width, height } = event {
println!("detected display with width {width} and height {height}");
Expand All @@ -66,9 +66,9 @@ impl Dispatch<wl_registry::WlRegistry, ()> for OutputData {
state: &mut Self,
registry: &wl_registry::WlRegistry,
event: wl_registry::Event,
_: &(),
(): &(),
_: &Connection,
handle: &QueueHandle<OutputData>,
handle: &QueueHandle<Self>,
) {
if let wl_registry::Event::Global {
name,
Expand Down