|
@@ -341,6 +341,7 @@ final class ViewController: NSViewController {
|
|
|
private weak var aiCompanionNotesTextView: NSTextView?
|
|
private weak var aiCompanionNotesTextView: NSTextView?
|
|
|
private weak var aiCompanionNotesCopyButton: NSButton?
|
|
private weak var aiCompanionNotesCopyButton: NSButton?
|
|
|
private weak var aiCompanionNotesCloseButton: NSButton?
|
|
private weak var aiCompanionNotesCloseButton: NSButton?
|
|
|
|
|
+ private var aiCompanionNotesOutsideClickMonitor: Any?
|
|
|
private var aiCompanionNotesTaskByMeetingId = [String: Task<Void, Never>]()
|
|
private var aiCompanionNotesTaskByMeetingId = [String: Task<Void, Never>]()
|
|
|
private var aiCompanionAudioPlayer: AVPlayer?
|
|
private var aiCompanionAudioPlayer: AVPlayer?
|
|
|
private var aiCompanionLocalAudioPlayer: AVAudioPlayer?
|
|
private var aiCompanionLocalAudioPlayer: AVAudioPlayer?
|
|
@@ -3544,6 +3545,7 @@ private extension ViewController {
|
|
|
if hostWindow.attachedSheet !== panel {
|
|
if hostWindow.attachedSheet !== panel {
|
|
|
hostWindow.beginSheet(panel, completionHandler: nil)
|
|
hostWindow.beginSheet(panel, completionHandler: nil)
|
|
|
}
|
|
}
|
|
|
|
|
+ aiCompanionStartNotesOutsideClickMonitor()
|
|
|
panel.makeKeyAndOrderFront(nil)
|
|
panel.makeKeyAndOrderFront(nil)
|
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
|
return
|
|
return
|
|
@@ -3647,6 +3649,7 @@ private extension ViewController {
|
|
|
|
|
|
|
|
panel.contentView = root
|
|
panel.contentView = root
|
|
|
hostWindow.beginSheet(panel, completionHandler: nil)
|
|
hostWindow.beginSheet(panel, completionHandler: nil)
|
|
|
|
|
+ aiCompanionStartNotesOutsideClickMonitor()
|
|
|
panel.makeKeyAndOrderFront(nil)
|
|
panel.makeKeyAndOrderFront(nil)
|
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
|
|
|
|
|
@@ -3671,7 +3674,30 @@ private extension ViewController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@objc private func aiCompanionCloseNotesTapped(_ sender: NSButton) {
|
|
@objc private func aiCompanionCloseNotesTapped(_ sender: NSButton) {
|
|
|
|
|
+ aiCompanionCloseNotesPanel()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func aiCompanionStartNotesOutsideClickMonitor() {
|
|
|
|
|
+ guard aiCompanionNotesOutsideClickMonitor == nil else { return }
|
|
|
|
|
+ aiCompanionNotesOutsideClickMonitor = NSEvent.addLocalMonitorForEvents(
|
|
|
|
|
+ matching: [.leftMouseDown, .rightMouseDown, .otherMouseDown]
|
|
|
|
|
+ ) { [weak self] event in
|
|
|
|
|
+ guard let self, let panel = self.aiCompanionNotesPanel else { return event }
|
|
|
|
|
+ if event.window === panel { return event }
|
|
|
|
|
+ self.aiCompanionCloseNotesPanel()
|
|
|
|
|
+ return event
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func aiCompanionStopNotesOutsideClickMonitor() {
|
|
|
|
|
+ guard let monitor = aiCompanionNotesOutsideClickMonitor else { return }
|
|
|
|
|
+ NSEvent.removeMonitor(monitor)
|
|
|
|
|
+ aiCompanionNotesOutsideClickMonitor = nil
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func aiCompanionCloseNotesPanel() {
|
|
|
guard let panel = aiCompanionNotesPanel else { return }
|
|
guard let panel = aiCompanionNotesPanel else { return }
|
|
|
|
|
+ aiCompanionStopNotesOutsideClickMonitor()
|
|
|
if let hostWindow = view.window, hostWindow.attachedSheet === panel {
|
|
if let hostWindow = view.window, hostWindow.attachedSheet === panel {
|
|
|
hostWindow.endSheet(panel)
|
|
hostWindow.endSheet(panel)
|
|
|
}
|
|
}
|
|
@@ -6616,6 +6642,7 @@ extension ViewController: NSWindowDelegate {
|
|
|
func windowWillClose(_ notification: Notification) {
|
|
func windowWillClose(_ notification: Notification) {
|
|
|
guard let closingWindow = notification.object as? NSWindow else { return }
|
|
guard let closingWindow = notification.object as? NSWindow else { return }
|
|
|
if closingWindow === aiCompanionNotesPanel {
|
|
if closingWindow === aiCompanionNotesPanel {
|
|
|
|
|
+ aiCompanionStopNotesOutsideClickMonitor()
|
|
|
aiCompanionNotesPanel = nil
|
|
aiCompanionNotesPanel = nil
|
|
|
aiCompanionNotesRootView = nil
|
|
aiCompanionNotesRootView = nil
|
|
|
aiCompanionNotesHeaderView = nil
|
|
aiCompanionNotesHeaderView = nil
|