File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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" ) ]
3737extern "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 }
You can’t perform that action at this time.
0 commit comments