From 905108414a1a9f69dc0bc246bb300e06b5d48a4a Mon Sep 17 00:00:00 2001 From: Iason Paraskevopoulos Date: Sat, 21 Sep 2024 09:35:54 +0100 Subject: [PATCH 1/2] core-graphics: add event set_location --- core-graphics/src/event.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core-graphics/src/event.rs b/core-graphics/src/event.rs index 77b699e7..a8e5f9e7 100644 --- a/core-graphics/src/event.rs +++ b/core-graphics/src/event.rs @@ -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 { @@ -868,4 +874,5 @@ extern "C" { fn CGEventTapEnable(tap: CFMachPortRef, enable: bool); + fn CGEventSetLocation(event: crate::sys::CGEventRef, location: CGPoint); } From c3b03900a2998d26d5f1817bfd0e20314dc468a4 Mon Sep 17 00:00:00 2001 From: Iason Paraskevopoulos Date: Mon, 14 Oct 2024 21:47:51 +0100 Subject: [PATCH 2/2] core-graphics: add documentation to CGEvent functions Adds documentation to CGEventTapEnable and CGEventSetLocation. --- core-graphics/src/event.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core-graphics/src/event.rs b/core-graphics/src/event.rs index a8e5f9e7..1fae3a76 100644 --- a/core-graphics/src/event.rs +++ b/core-graphics/src/event.rs @@ -872,7 +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); }