Skip to content

Commit

Permalink
core-graphics: add event set_location (#713)
Browse files Browse the repository at this point in the history
* core-graphics: add event set_location

* core-graphics: add documentation to CGEvent functions

Adds documentation to CGEventTapEnable and CGEventSetLocation.
  • Loading branch information
iparaskev authored Oct 15, 2024
1 parent 66be81a commit ef896fe
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core-graphics/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,12 @@ impl CGEvent {
unsafe { CGEventGetLocation(self.as_ptr()) }
}

pub fn set_location(&self, location: CGPoint) {
unsafe {
CGEventSetLocation(self.as_ptr(), location);
}
}

#[cfg(feature = "elcapitan")]
pub fn post_to_pid(&self, pid: libc::pid_t) {
unsafe {
Expand Down Expand Up @@ -866,6 +872,14 @@ extern "C" {
userInfo: *const c_void,
) -> CFMachPortRef;

/// Enable or disable an event tap.
///
/// Event taps are normally enabled when created. If an event tap becomes
/// unresponsive, or if a user requests that event taps be disabled, then
/// a `kCGEventTapDisabled` event is passed to the event tap callback
/// function. Event taps may be re-enabled by calling this function.
fn CGEventTapEnable(tap: CFMachPortRef, enable: bool);

/// Set the location of a mouse event.
fn CGEventSetLocation(event: crate::sys::CGEventRef, location: CGPoint);
}

0 comments on commit ef896fe

Please sign in to comment.