perf: fix very small memory leaks
This commit is contained in:
1 parent
c531e52650
commit
8b7da216fb
2 files changed
+4
-3
No files matched your search
@@ -18,9 +18,10 @@ class KeyboardEvents {
|
||||
static var eventHotKeyRefs = [EventHotKeyRef?](repeating: nil, count: globalShortcuts.count)
|
||||
static var hotModifierEventHandler: EventHandlerRef?
|
||||
static var hotKeyEventHandler: EventHandlerRef?
|
||||
static var localMonitor: Any?
|
||||
|
||||
static func observe() {
|
||||
NSEvent.addLocalMonitorForEvents(matching: [.keyDown, .flagsChanged]) { event in
|
||||
localMonitor = NSEvent.addLocalMonitorForEvents(matching: [.keyDown, .flagsChanged]) { event in
|
||||
// global .flagsChanged events are not send to the app when it's active, thus modifiers-only shortcuts should be matched in global and local handlers
|
||||
if handleHotModifier(cocoaToCarbonFlags(event.modifierFlags)) || handleLocalEvents(event) {
|
||||
return nil // don't propagate event
|
||||
|
||||
@@ -29,7 +29,7 @@ private func observe_() {
|
||||
callback: mouseHandler,
|
||||
userInfo: nil)
|
||||
MouseEvents.toggle(false)
|
||||
let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0)
|
||||
let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)
|
||||
CFRunLoopAddSource(BackgroundWork.mouseEventsThread.runLoop, runLoopSource, .commonModes)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ private func mouseHandler(proxy: CGEventTapProxy, type: CGEventType, cgEvent: CG
|
||||
} else if (type == .tapDisabledByUserInput || type == .tapDisabledByTimeout) && shouldBeEnabled {
|
||||
CGEvent.tapEnable(tap: eventTap!, enable: true)
|
||||
}
|
||||
return Unmanaged.passRetained(cgEvent) // focused app will receive the event
|
||||
return Unmanaged.passUnretained(cgEvent) // focused app will receive the event
|
||||
}
|
||||
|
||||
private func isPointerInsideUi_() {
|
||||
|
||||
Reference in new issue
Block a user