Skip to content

Commit

Permalink
fix clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
emrebicer committed Dec 8, 2024
1 parent 448ed31 commit f58b21c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
cargo
rustc
rust-analyzer
clippy
];
};

Expand Down
6 changes: 6 additions & 0 deletions src/darwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ impl DarwinMouseManager {
}
}

impl Default for DarwinMouseManager {
fn default() -> Self {
Self::new()
}
}

impl Drop for DarwinMouseManager {
fn drop(&mut self) {
unsafe {
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/nix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions src/nix/uinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
29 changes: 6 additions & 23 deletions src/nix/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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" {
Expand Down
8 changes: 7 additions & 1 deletion src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down

0 comments on commit f58b21c

Please sign in to comment.