This commit is contained in:
Wilson Giese
2016-10-28 13:11:11 -07:00
parent a70192dae8
commit b88ff77b0d
2 changed files with 12 additions and 13 deletions
+10 -10
View File
@@ -81,9 +81,9 @@ pub enum CGMouseButton {
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CGEventTapLocation {
HIDEventTap,
SessionEventTap,
AnnotatedSessionEventTap,
HID,
Session,
AnnotatedSession,
}
#[repr(C)]
@@ -166,13 +166,13 @@ impl CGEvent {
pub fn new_mouse_event(
source: CGEventSource,
mouseType: CGEventType,
mouseCursorPosition: CGPoint,
mouseButton: CGMouseButton
mouse_type: CGEventType,
mouse_cursor_position: CGPoint,
mouse_button: CGMouseButton
) -> Result<CGEvent, ()> {
unsafe {
let event_ref = CGEventCreateMouseEvent(source.as_concrete_TypeRef(), mouseType,
mouseCursorPosition, mouseButton);
let event_ref = CGEventCreateMouseEvent(source.as_concrete_TypeRef(), mouse_type,
mouse_cursor_position, mouse_button);
if event_ref != ptr::null() {
Ok(TCFType::wrap_under_create_rule(event_ref))
} else {
@@ -181,9 +181,9 @@ impl CGEvent {
}
}
pub fn post(&self, tapLocation: CGEventTapLocation) {
pub fn post(&self, tap_location: CGEventTapLocation) {
unsafe {
CGEventPost(tapLocation, self.as_concrete_TypeRef());
CGEventPost(tap_location, self.as_concrete_TypeRef());
}
}
+2 -3
View File
@@ -1,6 +1,5 @@
use core_foundation::base::{CFRelease, CFRetain, CFTypeID, CFTypeRef, TCFType};
use libc;
use std::mem;
use std::ptr;
@@ -76,9 +75,9 @@ impl TCFType<CGEventSourceRef> for CGEventSource {
}
impl CGEventSource {
pub fn new(stateID: CGEventSourceStateID) -> Result<CGEventSource, ()> {
pub fn new(state_id: CGEventSourceStateID) -> Result<CGEventSource, ()> {
unsafe {
let event_source_ref = CGEventSourceCreate(stateID);
let event_source_ref = CGEventSourceCreate(state_id);
if event_source_ref != ptr::null() {
Ok(TCFType::wrap_under_create_rule(event_source_ref))
} else {