diff --git a/flake.nix b/flake.nix index 65f797f..a749690 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,7 @@ cargo rustc rust-analyzer + clippy ]; }; diff --git a/src/darwin.rs b/src/darwin.rs index 6f67961..1f9b836 100644 --- a/src/darwin.rs +++ b/src/darwin.rs @@ -167,6 +167,12 @@ impl DarwinMouseManager { } } +impl Default for DarwinMouseManager { + fn default() -> Self { + Self::new() + } +} + impl Drop for DarwinMouseManager { fn drop(&mut self) { unsafe { diff --git a/src/lib.rs b/src/lib.rs index 64abb48..8102d3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,6 +76,12 @@ impl Mouse { } } +impl Default for Mouse { + fn default() -> Self { + Self::new() + } +} + impl MouseActions for Mouse { fn move_to(&self, x: usize, y: usize) -> Result<(), error::Error> { self.inner.move_to(x, y) diff --git a/src/nix/mod.rs b/src/nix/mod.rs index a0764f7..7042ad5 100644 --- a/src/nix/mod.rs +++ b/src/nix/mod.rs @@ -98,7 +98,7 @@ fn start_nix_listener(callbacks: &Callbacks) -> Result<(), Error> { // Construct the library's MouseEvent let r#type = received.r#type as i32; let code = received.code as i32; - let val = received.value as i32; + let val = received.value; let mouse_event = if r#type == EV_KEY { let button = if code == BTN_LEFT { diff --git a/src/nix/uinput.rs b/src/nix/uinput.rs index 32e9e5f..f33f2c5 100644 --- a/src/nix/uinput.rs +++ b/src/nix/uinput.rs @@ -154,6 +154,12 @@ impl UInputMouseManager { } } +impl Default for UInputMouseManager { + fn default() -> Self { + Self::new() + } +} + impl Drop for UInputMouseManager { fn drop(&mut self) { let fd = self.uinput_file_raw_fd(); diff --git a/src/nix/x11.rs b/src/nix/x11.rs index 8dc77c5..0af3ef3 100644 --- a/src/nix/x11.rs +++ b/src/nix/x11.rs @@ -49,6 +49,12 @@ impl X11MouseManager { } } +impl Default for X11MouseManager { + fn default() -> Self { + Self::new() + } +} + impl MouseActions for X11MouseManager { fn move_to(&self, x: usize, y: usize) -> Result<(), Error> { unsafe { @@ -150,29 +156,6 @@ enum _XDisplay {} type Display = _XDisplay; type Window = c_ulong; -#[derive(Debug)] -#[repr(C)] -struct XEvent { - r#type: c_int, - xbutton: XButtonEvent, -} - -#[derive(Debug)] -#[repr(C)] -struct XButtonEvent { - r#type: c_int, - window: Window, - root: Window, - subwindow: Window, - x: c_int, - y: c_int, - x_root: c_int, - y_root: c_int, - state: c_uint, - button: c_uint, - same_screen: bool, -} - // Xlib function definitions #[link(name = "X11")] extern "C" { diff --git a/src/windows.rs b/src/windows.rs index 077b644..eb475a6 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -127,7 +127,13 @@ impl WindowsMouseManager { )); } } - return Ok((out.x, out.y)); + Ok((out.x, out.y)) + } +} + +impl Default for WindowsMouseManager { + fn default() -> Self { + Self::new() } }