@@ 29,13 29,16 @@ func commandPressToEscapePressTransformer(proxy: CGEventTapProxy,
refcon: UnsafeMutableRawPointer?)
-> Unmanaged<CGEvent>?
{
+ // `UnsafeMutableRawPointer` -> `UnsafeMutablePointer`
+ let refcon = refcon?.bindMemory(to: CGEvent?.self, capacity: 1)
+
if (event.type != .flagsChanged) {
- refcon?.storeBytes(of: nil, as: CGEvent?.self)
- } else if let currentKeyDown = refcon?.load(as: CGEvent?.self) {
+ refcon?.initialize(to: nil)
+ } else if let currentKeyDown = refcon?.pointee {
if (keyEventNoFlagsPressed(event) &&
keyEventCmdPressedAlone(currentKeyDown))
{
- refcon?.storeBytes(of: nil, as: CGEvent?.self)
+ refcon?.initialize(to: nil)
if (event.timestamp - currentKeyDown.timestamp <= 200_000_000) // ns
{
@@ 61,10 64,10 @@ func commandPressToEscapePressTransformer(proxy: CGEventTapProxy,
// Don't treat this as a true cmd-pressed-alone to be stored,
// treat it as whatever's already been stored.
} else {
- refcon?.storeBytes(of: event, as: CGEvent?.self)
+ refcon?.initialize(to: event)
}
} else {
- refcon?.storeBytes(of: event, as: CGEvent?.self)
+ refcon?.initialize(to: event)
}
return Unmanaged.passRetained(event)