Auto merge of #541 - joshleeb:joshleeb-graphics-tap_post_event, r=jdm

Add binding for CGEventTapPostEvent

This change adds the binding for CGEventTapPostEvent and adds a wrapper function CGEvent::post_from_tap to call the core-graphics function.
This commit is contained in:
bors-servo
2023-03-21 13:29:58 +01:00
committed by GitHub
+8 -2
View File
@@ -607,12 +607,16 @@ impl CGEvent {
}
}
pub fn location(&self) -> CGPoint {
pub fn post_from_tap(&self, tap_proxy: CGEventTapProxy) {
unsafe {
CGEventGetLocation(self.as_ptr())
CGEventTapPostEvent(tap_proxy, self.as_ptr());
}
}
pub fn location(&self) -> CGPoint {
unsafe { CGEventGetLocation(self.as_ptr()) }
}
#[cfg(feature = "elcapitan")]
pub fn post_to_pid(&self, pid: libc::pid_t) {
unsafe {
@@ -734,6 +738,8 @@ extern {
/// taps.
fn CGEventPost(tapLocation: CGEventTapLocation, event: ::sys::CGEventRef);
fn CGEventTapPostEvent(tapProxy: CGEventTapProxy, event: ::sys::CGEventRef);
#[cfg(feature = "elcapitan")]
/// Post an event to a specified process ID
fn CGEventPostToPid(pid: libc::pid_t, event: ::sys::CGEventRef);