Skip to content

Commit

Permalink
Fix extension access
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonm23 committed Oct 9, 2023
1 parent cb4a273 commit fa26662
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions Lib/Magnet/HotKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ open class HotKey: NSObject {
}

// MARK: - Invoke
open extension HotKey {
func invoke() {
extension HotKey {
public func invoke() {
guard let callback = self.callback else {
guard let target = self.target as? NSObject, let selector = self.action else { return }
guard target.responds(to: selector) else { return }
Expand All @@ -84,19 +84,19 @@ open extension HotKey {
}

// MARK: - Register & UnRegister
open extension HotKey {
extension HotKey {
@discardableResult
func register() -> Bool {
public func register() -> Bool {
return HotKeyCenter.shared.register(with: self)
}

func unregister() {
public func unregister() {
return HotKeyCenter.shared.unregister(with: self)
}
}

// MARK: - override isEqual
open extension HotKey {
extension HotKey {
override func isEqual(_ object: Any?) -> Bool {
guard let hotKey = object as? HotKey else { return false }

Expand Down
22 changes: 11 additions & 11 deletions Lib/Magnet/HotKeyCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ open class HotKeyCenter {
}

// MARK: - Register & Unregister
open extension HotKeyCenter {
extension HotKeyCenter {
@discardableResult
func register(with hotKey: HotKey) -> Bool {
public func register(with hotKey: HotKey) -> Bool {
guard !hotKeys.keys.contains(hotKey.identifier) else { return false }
guard !hotKeys.values.contains(hotKey) else { return false }

Expand Down Expand Up @@ -78,7 +78,7 @@ open extension HotKeyCenter {
return true
}

func unregister(with hotKey: HotKey) {
public func unregister(with hotKey: HotKey) {
if let carbonHotKey = hotKey.hotKeyRef {
UnregisterEventHotKey(carbonHotKey)
}
Expand All @@ -88,19 +88,19 @@ open extension HotKeyCenter {
}

@discardableResult
func unregisterHotKey(with identifier: String) -> Bool {
public func unregisterHotKey(with identifier: String) -> Bool {
guard let hotKey = hotKeys[identifier] else { return false }
unregister(with: hotKey)
return true
}

func unregisterAll() {
public func unregisterAll() {
hotKeys.forEach { unregister(with: $1) }
}
}

// MARK: - Terminate
open extension HotKeyCenter {
extension HotKeyCenter {
private func observeApplicationTerminate() {
notificationCenter.addObserver(self,
selector: #selector(HotKeyCenter.applicationWillTerminate),
Expand All @@ -114,8 +114,8 @@ open extension HotKeyCenter {
}

// MARK: - HotKey Events
open extension HotKeyCenter {
func installHotKeyPressedEventHandler() {
extension HotKeyCenter {
public func installHotKeyPressedEventHandler() {
var pressedEventType = EventTypeSpec()
pressedEventType.eventClass = OSType(kEventClassKeyboard)
pressedEventType.eventKind = OSType(kEventHotKeyPressed)
Expand All @@ -124,7 +124,7 @@ open extension HotKeyCenter {
}, 1, &pressedEventType, nil, nil)
}

func sendPressedKeyboardEvent(_ event: EventRef) -> OSStatus {
public func sendPressedKeyboardEvent(_ event: EventRef) -> OSStatus {
assert(Int(GetEventClass(event)) == kEventClassKeyboard, "Unknown event class")

var hotKeyId = EventHotKeyID()
Expand All @@ -151,8 +151,8 @@ open extension HotKeyCenter {
}

// MARK: - Double Tap Modifier Event
open extension HotKeyCenter {
func installModifiersChangedEventHandlerIfNeeded() {
extension HotKeyCenter {
public func installModifiersChangedEventHandlerIfNeeded() {
NSEvent.addGlobalMonitorForEvents(matching: .flagsChanged) { [weak self] event in
self?.modifierEventHandler.handleModifiersEvent(with: event.modifierFlags, timestamp: event.timestamp)
}
Expand Down
4 changes: 2 additions & 2 deletions Lib/Magnet/KeyCombo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,6 @@ open class KeyCombo: NSObject, NSCopying, NSCoding, Codable {
}

// MARK: - Error
open extension KeyCombo {
struct InitializeError: Error {}
extension KeyCombo {
public struct InitializeError: Error {}
}
4 changes: 2 additions & 2 deletions Lib/Magnet/ModifierEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ open class ModifierEventHandler {
}

// MARK: - Handling
open extension ModifierEventHandler {
func handleModifiersEvent(with modifierFlags: NSEvent.ModifierFlags, timestamp: TimeInterval) {
extension ModifierEventHandler {
public func handleModifiersEvent(with modifierFlags: NSEvent.ModifierFlags, timestamp: TimeInterval) {
guard lastHandledEventTimestamp != timestamp else { return }
lastHandledEventTimestamp = timestamp

Expand Down

0 comments on commit fa26662

Please sign in to comment.