|
|
@@ -341,6 +341,7 @@ final class ViewController: NSViewController {
|
|
341
|
341
|
private weak var aiCompanionNotesTextView: NSTextView?
|
|
342
|
342
|
private weak var aiCompanionNotesCopyButton: NSButton?
|
|
343
|
343
|
private weak var aiCompanionNotesCloseButton: NSButton?
|
|
|
344
|
+ private var aiCompanionNotesOutsideClickMonitor: Any?
|
|
344
|
345
|
private var aiCompanionNotesTaskByMeetingId = [String: Task<Void, Never>]()
|
|
345
|
346
|
private var aiCompanionAudioPlayer: AVPlayer?
|
|
346
|
347
|
private var aiCompanionLocalAudioPlayer: AVAudioPlayer?
|
|
|
@@ -3544,6 +3545,7 @@ private extension ViewController {
|
|
3544
|
3545
|
if hostWindow.attachedSheet !== panel {
|
|
3545
|
3546
|
hostWindow.beginSheet(panel, completionHandler: nil)
|
|
3546
|
3547
|
}
|
|
|
3548
|
+ aiCompanionStartNotesOutsideClickMonitor()
|
|
3547
|
3549
|
panel.makeKeyAndOrderFront(nil)
|
|
3548
|
3550
|
NSApp.activate(ignoringOtherApps: true)
|
|
3549
|
3551
|
return
|
|
|
@@ -3647,6 +3649,7 @@ private extension ViewController {
|
|
3647
|
3649
|
|
|
3648
|
3650
|
panel.contentView = root
|
|
3649
|
3651
|
hostWindow.beginSheet(panel, completionHandler: nil)
|
|
|
3652
|
+ aiCompanionStartNotesOutsideClickMonitor()
|
|
3650
|
3653
|
panel.makeKeyAndOrderFront(nil)
|
|
3651
|
3654
|
NSApp.activate(ignoringOtherApps: true)
|
|
3652
|
3655
|
|
|
|
@@ -3671,7 +3674,30 @@ private extension ViewController {
|
|
3671
|
3674
|
}
|
|
3672
|
3675
|
|
|
3673
|
3676
|
@objc private func aiCompanionCloseNotesTapped(_ sender: NSButton) {
|
|
|
3677
|
+ aiCompanionCloseNotesPanel()
|
|
|
3678
|
+ }
|
|
|
3679
|
+
|
|
|
3680
|
+ private func aiCompanionStartNotesOutsideClickMonitor() {
|
|
|
3681
|
+ guard aiCompanionNotesOutsideClickMonitor == nil else { return }
|
|
|
3682
|
+ aiCompanionNotesOutsideClickMonitor = NSEvent.addLocalMonitorForEvents(
|
|
|
3683
|
+ matching: [.leftMouseDown, .rightMouseDown, .otherMouseDown]
|
|
|
3684
|
+ ) { [weak self] event in
|
|
|
3685
|
+ guard let self, let panel = self.aiCompanionNotesPanel else { return event }
|
|
|
3686
|
+ if event.window === panel { return event }
|
|
|
3687
|
+ self.aiCompanionCloseNotesPanel()
|
|
|
3688
|
+ return event
|
|
|
3689
|
+ }
|
|
|
3690
|
+ }
|
|
|
3691
|
+
|
|
|
3692
|
+ private func aiCompanionStopNotesOutsideClickMonitor() {
|
|
|
3693
|
+ guard let monitor = aiCompanionNotesOutsideClickMonitor else { return }
|
|
|
3694
|
+ NSEvent.removeMonitor(monitor)
|
|
|
3695
|
+ aiCompanionNotesOutsideClickMonitor = nil
|
|
|
3696
|
+ }
|
|
|
3697
|
+
|
|
|
3698
|
+ private func aiCompanionCloseNotesPanel() {
|
|
3674
|
3699
|
guard let panel = aiCompanionNotesPanel else { return }
|
|
|
3700
|
+ aiCompanionStopNotesOutsideClickMonitor()
|
|
3675
|
3701
|
if let hostWindow = view.window, hostWindow.attachedSheet === panel {
|
|
3676
|
3702
|
hostWindow.endSheet(panel)
|
|
3677
|
3703
|
}
|
|
|
@@ -6616,6 +6642,7 @@ extension ViewController: NSWindowDelegate {
|
|
6616
|
6642
|
func windowWillClose(_ notification: Notification) {
|
|
6617
|
6643
|
guard let closingWindow = notification.object as? NSWindow else { return }
|
|
6618
|
6644
|
if closingWindow === aiCompanionNotesPanel {
|
|
|
6645
|
+ aiCompanionStopNotesOutsideClickMonitor()
|
|
6619
|
6646
|
aiCompanionNotesPanel = nil
|
|
6620
|
6647
|
aiCompanionNotesRootView = nil
|
|
6621
|
6648
|
aiCompanionNotesHeaderView = nil
|