-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #436 - AsafFisher:master, r=jrmuizel
Add CGEventTap servo/core-graphics-rs#111
- Loading branch information
Showing
6 changed files
with
203 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ pub mod string; | |
pub mod timezone; | ||
pub mod url; | ||
pub mod uuid; | ||
pub mod mach_port; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
pub use base::{CFAllocatorRef, CFIndex, CFTypeID}; | ||
use runloop::CFRunLoopSourceRef; | ||
use std::os::raw::c_void; | ||
|
||
#[repr(C)] | ||
pub struct __CFMachPort(c_void); | ||
pub type CFMachPortRef = *const __CFMachPort; | ||
|
||
extern "C" { | ||
/* | ||
* CFMachPort.h | ||
*/ | ||
pub fn CFMachPortCreateRunLoopSource( | ||
allocator: CFAllocatorRef, | ||
port: CFMachPortRef, | ||
order: CFIndex, | ||
) -> CFRunLoopSourceRef; | ||
|
||
pub fn CFMachPortGetTypeID() -> CFTypeID; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,3 +233,4 @@ pub mod propertylist; | |
pub mod runloop; | ||
pub mod timezone; | ||
pub mod uuid; | ||
pub mod mach_port; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use base::TCFType; | ||
use core_foundation_sys::base::kCFAllocatorDefault; | ||
use runloop::CFRunLoopSource; | ||
pub use core_foundation_sys::mach_port::*; | ||
|
||
|
||
declare_TCFType! { | ||
/// An immutable numeric value. | ||
CFMachPort, CFMachPortRef | ||
} | ||
impl_TCFType!(CFMachPort, CFMachPortRef, CFMachPortGetTypeID); | ||
impl_CFTypeDescription!(CFMachPort); | ||
|
||
impl CFMachPort { | ||
pub fn create_runloop_source( | ||
&self, | ||
order: CFIndex, | ||
) -> Result<CFRunLoopSource, ()> { | ||
unsafe { | ||
let runloop_source_ref = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, self.0, order); | ||
if runloop_source_ref.is_null() { | ||
Err(()) | ||
} else { | ||
Ok(CFRunLoopSource::wrap_under_create_rule(runloop_source_ref)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters