Skip to content

Commit 0656a66

Browse files
committed
Remove the warnings.
1 parent f8ec9a2 commit 0656a66

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/macos/grab.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ unsafe extern "C" fn raw_callback(
2222
let opt = KEYBOARD_STATE.lock();
2323
if let Ok(mut keyboard) = opt {
2424
if let Some(event) = convert(_type, &cg_event, &mut keyboard) {
25-
if let Some(callback) = &mut GLOBAL_CALLBACK {
25+
// Reborrowing the global callback pointer.
26+
// Totally UB. but not sure there's a great alternative.
27+
let ptr = &raw mut GLOBAL_CALLBACK;
28+
if let Some(callback) = &mut *ptr {
2629
if callback(event).is_none() {
2730
cg_event.set_type(CGEventType::Null);
2831
}

src/macos/keyboard.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const BUF_LEN: usize = 4;
3333

3434
#[cfg(target_os = "macos")]
3535
#[link(name = "Cocoa", kind = "framework")]
36-
#[link(name = "Carbon", kind = "framework")]
36+
#[link(name = "Carbon")]
3737
extern "C" {
3838
fn TISCopyCurrentKeyboardLayoutInputSource() -> TISInputSourceRef;
3939
fn TISCopyCurrentKeyboardInputSource() -> TISInputSourceRef;
@@ -143,13 +143,10 @@ impl KeyboardState for Keyboard {
143143
unsafe { self.string_from_code(code.into(), self.modifier_state()) }
144144
}
145145
},
146-
EventType::KeyRelease(key) => match key {
147-
Key::ShiftLeft | Key::ShiftRight => {
148-
self.shift = false;
149-
None
150-
}
151-
_ => None,
152-
},
146+
EventType::KeyRelease(Key::ShiftLeft | Key::ShiftRight) => {
147+
self.shift = false;
148+
None
149+
}
153150
_ => None,
154151
}
155152
}

0 commit comments

Comments
 (0)