diff --git a/ScreenJumper/ScreenFocusHelper.swift b/ScreenJumper/ScreenFocusHelper.swift index 4d884ff..c48d35d 100644 --- a/ScreenJumper/ScreenFocusHelper.swift +++ b/ScreenJumper/ScreenFocusHelper.swift @@ -12,15 +12,7 @@ let SFHelper = ScreenFocusHelper() class ScreenFocusHelper: NSObject { override init() { - CGDisplayRegisterReconfigurationCallback({ (id, flags, pointer) in - print("wtf:\(id) \(flags)") - if ((flags.rawValue & CGDisplayChangeSummaryFlags.addFlag.rawValue) != 0) { - print("display has been added:\(id)") - } - else if ((flags.rawValue & CGDisplayChangeSummaryFlags.removeFlag.rawValue) != 0) { - print(" display has been removed:\(id)") - } - }, nil) + } private func screens() -> [NSScreen]{ return NSScreen.screens diff --git a/ScreenJumper/ShortcutHelper.swift b/ScreenJumper/ShortcutHelper.swift index e630429..71e6334 100644 --- a/ScreenJumper/ShortcutHelper.swift +++ b/ScreenJumper/ShortcutHelper.swift @@ -66,6 +66,16 @@ class ShortcutRepository: ObservableObject { let size = ShortcutRepository.restoreSize() assigns = [] assignSize = size + + CGDisplayRegisterReconfigurationCallback({ (id, flags, pointer) in + print("wtf:\(id) \(flags)") + //TODO 只监听显示器增减还不能覆盖所有情况,比如镜像显示器。暂不继续深入 +// if ((flags.rawValue & (CGDisplayChangeSummaryFlags.addFlag.rawValue | CGDisplayChangeSummaryFlags.removeFlag.rawValue)) != 0) { + let size = ShortcutRepository.restoreSize() + ShortcutRepository.shared.assigns = [] + ShortcutRepository.shared.assignSize = size +// } + }, nil) } func register() {