Skip to content

Commit

Permalink
all: Renamed variants of Coordinate enum
Browse files Browse the repository at this point in the history
  • Loading branch information
pentamassiv committed Nov 8, 2023
1 parent 4097d59 commit cb6089c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ where
/// enigo.mouse_move_to(500, 200);
/// ```
fn mouse_move_to(&mut self, x: i32, y: i32) {
match self.move_mouse(x, y, Coordinate::Absolute) {
match self.move_mouse(x, y, Coordinate::Abs) {
Ok(()) => {}
Err(e) => {
error!("{e}");
Expand All @@ -159,7 +159,7 @@ where
/// enigo.mouse_move_relative(100, 100);
/// ```
fn mouse_move_relative(&mut self, x: i32, y: i32) {
match self.move_mouse(x, y, Coordinate::Relative) {
match self.move_mouse(x, y, Coordinate::Rel) {
Ok(()) => {}
Err(e) => {
error!("{e}");
Expand Down Expand Up @@ -458,8 +458,8 @@ pub enum Axis {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// Specifies if a coordinate is relative or absolute
pub enum Coordinate {
Relative,
Absolute,
Rel,
Abs,
}

pub trait KeyboardControllableNext {
Expand Down
4 changes: 2 additions & 2 deletions src/linux/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@ impl MouseControllableNext for Con {
if let Some(vp) = &self.virtual_pointer {
let time = self.get_time();
match coordinate {
Coordinate::Relative => {
Coordinate::Rel => {
trace!("vp.motion({time}, {x}, {y})");
vp.motion(time, x as f64, y as f64);
}
Coordinate::Absolute => {
Coordinate::Abs => {
let Ok(x) = x.try_into() else {
return Err(InputError::InvalidInput(
"the absolute coordinates cannot be negative",
Expand Down
4 changes: 2 additions & 2 deletions src/linux/x11rb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ impl MouseControllableNext for Con {
fn move_mouse(&mut self, x: i32, y: i32, coordinate: Coordinate) -> InputResult<()> {
let type_ = x11rb::protocol::xproto::MOTION_NOTIFY_EVENT;
let detail = match coordinate {
Coordinate::Relative => 1,
Coordinate::Absolute => 0,
Coordinate::Rel => 1,
Coordinate::Abs => 0,
};
let time = x11rb::CURRENT_TIME;
let root = x11rb::NONE; // the root window of the screen the pointer is currently on
Expand Down
4 changes: 2 additions & 2 deletions src/linux/xdo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ impl MouseControllableNext for Con {

fn move_mouse(&mut self, x: i32, y: i32, coordinate: Coordinate) -> InputResult<()> {
let res = match coordinate {
Coordinate::Relative => {
Coordinate::Rel => {
debug!("xdo_move_mouse_relative with x {}, y {}", x, y);
unsafe { xdo_move_mouse_relative(self.xdo, x as c_int, y as c_int) }
}
Coordinate::Absolute => {
Coordinate::Abs => {
debug!("xdo_move_mouse with mouse button with x {}, y {}", x, y);
unsafe { xdo_move_mouse(self.xdo, x as c_int, y as c_int, 0) }
}
Expand Down
4 changes: 2 additions & 2 deletions src/macos/macos_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ impl MouseControllableNext for Enigo {

let (absolute, relative) = match coordinate {
// TODO: Check the bounds
Coordinate::Absolute => ((x, y), (current_x - x, current_y - y)),
Coordinate::Relative => ((current_x + x, current_y + y), (x, y)),
Coordinate::Abs => ((x, y), (current_x - x, current_y - y)),
Coordinate::Rel => ((current_x + x, current_y + y), (x, y)),
};

let (event_type, mouse_button) =
Expand Down
2 changes: 1 addition & 1 deletion src/win/win_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl MouseControllableNext for Enigo {
// TODO: Check if using x11rb::protocol::xproto::warp_pointer would be better
fn move_mouse(&mut self, x: i32, y: i32, coordinate: Coordinate) -> InputResult<()> {
debug!("\x1b[93mmove_mouse(x: {x:?}, y: {y:?}, coordinate:{coordinate:?})\x1b[0m");
let (x_absolute, y_absolute) = if coordinate == Coordinate::Relative {
let (x_absolute, y_absolute) = if coordinate == Coordinate::Rel {
let (x_absolute, y_absolute) = self.location()?;
(x_absolute + x, y_absolute + y)
} else {
Expand Down

0 comments on commit cb6089c

Please sign in to comment.