Skip to content

Commit ef896fe

Browse files
authored
core-graphics: add event set_location (#713)
* core-graphics: add event set_location * core-graphics: add documentation to CGEvent functions Adds documentation to CGEventTapEnable and CGEventSetLocation.
1 parent 66be81a commit ef896fe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core-graphics/src/event.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,12 @@ impl CGEvent {
659659
unsafe { CGEventGetLocation(self.as_ptr()) }
660660
}
661661

662+
pub fn set_location(&self, location: CGPoint) {
663+
unsafe {
664+
CGEventSetLocation(self.as_ptr(), location);
665+
}
666+
}
667+
662668
#[cfg(feature = "elcapitan")]
663669
pub fn post_to_pid(&self, pid: libc::pid_t) {
664670
unsafe {
@@ -866,6 +872,14 @@ extern "C" {
866872
userInfo: *const c_void,
867873
) -> CFMachPortRef;
868874

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

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

0 commit comments

Comments
 (0)