Skip to content

Commit

Permalink
Update Utilities.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 11, 2023
1 parent fea3c79 commit 00622a4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/KeyboardShortcuts/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,18 @@ final class LocalEventMonitor {

final class RunLoopLocalEventMonitor {
private let runLoopMode: RunLoop.Mode
private let events: NSEvent.EventTypeMask
private let callback: (NSEvent) -> NSEvent?
private let observer: CFRunLoopObserver

init(runLoopMode: RunLoop.Mode, events: NSEvent.EventTypeMask, callback: @escaping (NSEvent) -> NSEvent?) {
init(
events: NSEvent.EventTypeMask,
runLoopMode: RunLoop.Mode,
callback: @escaping (NSEvent) -> NSEvent?
) {
self.runLoopMode = runLoopMode
self.events = events
self.callback = callback

observer = CFRunLoopObserverCreateWithHandler(nil, CFRunLoopActivity.beforeSources.rawValue, true, 0) { _, _ in
self.observer = CFRunLoopObserverCreateWithHandler(nil, CFRunLoopActivity.beforeSources.rawValue, true, 0) { _, _ in
var eventsToHandle = [NSEvent]()

while let eventToHandle = NSApp.nextEvent(matching: .any, until: nil, inMode: .default, dequeue: true) {
Expand Down

0 comments on commit 00622a4

Please sign in to comment.