Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core-graphics: add event set_location #713

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other CG... functions here have rust documentation, so it makes sense to add it here as well, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I added to CGEventTapEnable as well.

}
Loading