From a62c15962ec4c8e967afa44d5513c01383a34b56 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Wed, 24 Apr 2024 20:37:35 -0400 Subject: [PATCH 01/12] timeline fullscreen without ext monitor blackouts --- rem/TimelineView.swift | 14 +++++++++----- rem/remApp.swift | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/rem/TimelineView.swift b/rem/TimelineView.swift index d0a3be8..a4ae4c1 100644 --- a/rem/TimelineView.swift +++ b/rem/TimelineView.swift @@ -177,6 +177,15 @@ class CustomHostingViewController: NSViewController { self.view.window?.makeKey() } } + + override func viewDidAppear() { + super.viewDidAppear() + guard let window = view.window else { return } + + if !self.view.isInFullScreenMode{ + window.toggleFullScreen(nil) + } + } override func loadView() { let _interceptingView = CustomInterceptingView() @@ -206,11 +215,6 @@ class CustomHostingViewController: NSViewController { func updateContent(image: NSImage?, frame: NSRect, analysis: ImageAnalysis?) { if let im = image { - if !view.isInFullScreenMode { - DispatchQueue.main.async { - self.view.enterFullScreenMode(NSScreen.main!) - } - } updateImage(im, frame: frame) updateAnalysis(analysis) hadImage = true diff --git a/rem/remApp.swift b/rem/remApp.swift index 79d3661..6f82efd 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -649,14 +649,14 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { let screenRect = NSScreen.main?.frame ?? NSRect.zero timelineViewWindow = MainWindow( contentRect: screenRect, - styleMask: [.borderless, .fullSizeContentView], + styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false ) timelineViewWindow?.hasShadow = false timelineViewWindow?.level = .normal - timelineViewWindow?.collectionBehavior = [.fullScreenAuxiliary, .canJoinAllSpaces, .participatesInCycle] + timelineViewWindow?.collectionBehavior = [.fullScreenPrimary, .canJoinAllSpaces, .participatesInCycle] timelineViewWindow?.ignoresMouseEvents = false timelineView = TimelineView(viewModel: TimelineViewModel(), settingsManager: settingsManager, onClose: { DispatchQueue.main.async { [weak self] in From 3b8731487cc7853b4eb3166178d87b0aacb9828e Mon Sep 17 00:00:00 2001 From: Connorpar Date: Wed, 24 Apr 2024 20:41:55 -0400 Subject: [PATCH 02/12] readd borderless for timeline view --- rem/remApp.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rem/remApp.swift b/rem/remApp.swift index 6f82efd..eed828e 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -649,7 +649,7 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { let screenRect = NSScreen.main?.frame ?? NSRect.zero timelineViewWindow = MainWindow( contentRect: screenRect, - styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], + styleMask: [.borderless, .titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false ) From 4a7134821e75621c2de86867aa685a32a3ed3f70 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Wed, 24 Apr 2024 21:30:48 -0400 Subject: [PATCH 03/12] timeline view skip missing frames --- rem/TimelineView.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rem/TimelineView.swift b/rem/TimelineView.swift index a4ae4c1..1834bb7 100644 --- a/rem/TimelineView.swift +++ b/rem/TimelineView.swift @@ -30,10 +30,11 @@ struct TimelineView: View { _customHostingView = State(initialValue: nil) } + var body: some View { ZStack { let frame = NSScreen.main?.frame ?? NSRect.zero - let image = DatabaseManager.shared.getImage(index: viewModel.currentFrameIndex) + let image = viewModel.getNextImage() let nsImage = image.flatMap { NSImage(cgImage: $0, size: NSSize(width: $0.width, height: $0.height)) } CustomHostingControllerRepresentable( @@ -323,6 +324,15 @@ class TimelineViewModel: ObservableObject { } } + func getNextImage() -> CGImage? { + var image = DatabaseManager.shared.getImage(index: self.currentFrameIndex) + while image == nil { + self.updateIndex(withDelta: 1) + image = DatabaseManager.shared.getImage(index: self.currentFrameIndex) + } + return image + } + func updateIndexSafely() { indexUpdateThrottle.throttle { let rounded = Int64(self.currentFrameContinuous) From 4318575e5562e72fddd348ffbb5e861f69bfdbba Mon Sep 17 00:00:00 2001 From: Connorpar Date: Thu, 25 Apr 2024 14:09:40 -0400 Subject: [PATCH 04/12] timelineview toggle fullscreen before show --- rem/TimelineView.swift | 32 +++++++------------------------- rem/remApp.swift | 5 ++++- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/rem/TimelineView.swift b/rem/TimelineView.swift index 1834bb7..89888e5 100644 --- a/rem/TimelineView.swift +++ b/rem/TimelineView.swift @@ -34,7 +34,7 @@ struct TimelineView: View { var body: some View { ZStack { let frame = NSScreen.main?.frame ?? NSRect.zero - let image = viewModel.getNextImage() + let image = DatabaseManager.shared.getImage(index: viewModel.currentFrameIndex) let nsImage = image.flatMap { NSImage(cgImage: $0, size: NSSize(width: $0.width, height: $0.height)) } CustomHostingControllerRepresentable( @@ -55,13 +55,13 @@ struct TimelineView: View { } if image == nil { - VStack(alignment: .center) { - Text("Nothing to remember, or missing frame (if missing, sorry, still alpha!)") - .padding() - .background(RoundedRectangle(cornerRadius: 10) - .fill(Color.white.opacity(0.1))) + VStack(alignment: .center) { + Text("Nothing to remember, or missing frame (if missing, sorry, still alpha!)") + .padding() + .background(RoundedRectangle(cornerRadius: 10) + .fill(Color.white.opacity(0.1))) + } } - } } .ignoresSafeArea(.all) @@ -178,15 +178,6 @@ class CustomHostingViewController: NSViewController { self.view.window?.makeKey() } } - - override func viewDidAppear() { - super.viewDidAppear() - guard let window = view.window else { return } - - if !self.view.isInFullScreenMode{ - window.toggleFullScreen(nil) - } - } override func loadView() { let _interceptingView = CustomInterceptingView() @@ -324,15 +315,6 @@ class TimelineViewModel: ObservableObject { } } - func getNextImage() -> CGImage? { - var image = DatabaseManager.shared.getImage(index: self.currentFrameIndex) - while image == nil { - self.updateIndex(withDelta: 1) - image = DatabaseManager.shared.getImage(index: self.currentFrameIndex) - } - return image - } - func updateIndexSafely() { indexUpdateThrottle.throttle { let rounded = Int64(self.currentFrameContinuous) diff --git a/rem/remApp.swift b/rem/remApp.swift index eed828e..509a729 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -649,10 +649,11 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { let screenRect = NSScreen.main?.frame ?? NSRect.zero timelineViewWindow = MainWindow( contentRect: screenRect, - styleMask: [.borderless, .titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], + styleMask: [.borderless, .fullSizeContentView], backing: .buffered, defer: false ) + timelineViewWindow?.hasShadow = false timelineViewWindow?.level = .normal @@ -664,6 +665,7 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { } }) timelineView?.viewModel.updateIndex(withIndex: index) + timelineViewWindow?.toggleFullScreen(nil) timelineViewWindow?.contentView = NSHostingView(rootView: timelineView) timelineView?.viewModel.setIsOpen(isOpen: true) @@ -672,6 +674,7 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { self.timelineViewWindow?.orderFrontRegardless() // Ensure it comes to the front } } else if !isTimelineOpen() { + timelineViewWindow?.toggleFullScreen(nil) timelineView?.viewModel.updateIndex(withIndex: index) timelineView?.viewModel.setIsOpen(isOpen: true) timelineViewWindow?.makeKeyAndOrderFront(nil) From 0e029dba0f37755696e32fc7a96317cbdb7883b4 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Thu, 25 Apr 2024 14:11:10 -0400 Subject: [PATCH 05/12] cleanup --- rem/TimelineView.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rem/TimelineView.swift b/rem/TimelineView.swift index 89888e5..8dc01c3 100644 --- a/rem/TimelineView.swift +++ b/rem/TimelineView.swift @@ -30,7 +30,6 @@ struct TimelineView: View { _customHostingView = State(initialValue: nil) } - var body: some View { ZStack { let frame = NSScreen.main?.frame ?? NSRect.zero @@ -55,13 +54,13 @@ struct TimelineView: View { } if image == nil { - VStack(alignment: .center) { - Text("Nothing to remember, or missing frame (if missing, sorry, still alpha!)") - .padding() - .background(RoundedRectangle(cornerRadius: 10) - .fill(Color.white.opacity(0.1))) - } + VStack(alignment: .center) { + Text("Nothing to remember, or missing frame (if missing, sorry, still alpha!)") + .padding() + .background(RoundedRectangle(cornerRadius: 10) + .fill(Color.white.opacity(0.1))) } + } } .ignoresSafeArea(.all) From 41f21694c749bb25af0a96b0fbf95b6975e0dbe2 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Thu, 25 Apr 2024 14:12:22 -0400 Subject: [PATCH 06/12] one more cleanup --- rem/remApp.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/rem/remApp.swift b/rem/remApp.swift index 509a729..7354079 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -653,7 +653,6 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { backing: .buffered, defer: false ) - timelineViewWindow?.hasShadow = false timelineViewWindow?.level = .normal From 86ef63b2e0272065ade3ef1d07e026898d263813 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Thu, 25 Apr 2024 14:13:20 -0400 Subject: [PATCH 07/12] cleanup --- rem/remApp.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rem/remApp.swift b/rem/remApp.swift index 7354079..483b819 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -673,8 +673,8 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { self.timelineViewWindow?.orderFrontRegardless() // Ensure it comes to the front } } else if !isTimelineOpen() { - timelineViewWindow?.toggleFullScreen(nil) timelineView?.viewModel.updateIndex(withIndex: index) + timelineViewWindow?.toggleFullScreen(nil) timelineView?.viewModel.setIsOpen(isOpen: true) timelineViewWindow?.makeKeyAndOrderFront(nil) DispatchQueue.main.async { From b62f181986ca164b3c0be387628fe8c70ecaf5f8 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Fri, 26 Apr 2024 10:03:31 -0400 Subject: [PATCH 08/12] fullscreen after set open avoid transition --- rem/remApp.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rem/remApp.swift b/rem/remApp.swift index 483b819..8a7f129 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -664,18 +664,18 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { } }) timelineView?.viewModel.updateIndex(withIndex: index) - timelineViewWindow?.toggleFullScreen(nil) timelineViewWindow?.contentView = NSHostingView(rootView: timelineView) timelineView?.viewModel.setIsOpen(isOpen: true) + self.timelineViewWindow?.toggleFullScreen(nil) timelineViewWindow?.makeKeyAndOrderFront(nil) DispatchQueue.main.async { self.timelineViewWindow?.orderFrontRegardless() // Ensure it comes to the front } } else if !isTimelineOpen() { timelineView?.viewModel.updateIndex(withIndex: index) - timelineViewWindow?.toggleFullScreen(nil) timelineView?.viewModel.setIsOpen(isOpen: true) + self.timelineViewWindow?.toggleFullScreen(nil) timelineViewWindow?.makeKeyAndOrderFront(nil) DispatchQueue.main.async { self.timelineViewWindow?.orderFrontRegardless() // Ensure it comes to the front From 8fa45fc626d948c819cffaba80eccc11a6b1a385 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Fri, 26 Apr 2024 12:19:06 -0400 Subject: [PATCH 09/12] fullScreenOptions --- rem/TimelineView.swift | 15 ++++++++++++++- rem/remApp.swift | 6 ++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/rem/TimelineView.swift b/rem/TimelineView.swift index 8dc01c3..2603b4a 100644 --- a/rem/TimelineView.swift +++ b/rem/TimelineView.swift @@ -177,7 +177,7 @@ class CustomHostingViewController: NSViewController { self.view.window?.makeKey() } } - + override func loadView() { let _interceptingView = CustomInterceptingView() _interceptingView.onClose = onClose @@ -190,6 +190,13 @@ class CustomHostingViewController: NSViewController { } _interceptingView.customHostingView = customHostingView interceptingView = _interceptingView + + NSAnimationContext.runAnimationGroup({ context in + context.duration = 0.0 // Setting duration to zero effectively disables animations + self.view.window?.toggleFullScreen(nil) + }, completionHandler: { + // Any additional code after animation completes + }) } func updateImage(_ image: NSImage, frame: NSRect) { @@ -206,6 +213,12 @@ class CustomHostingViewController: NSViewController { func updateContent(image: NSImage?, frame: NSRect, analysis: ImageAnalysis?) { if let im = image { + let fullScreenOptions = [NSView.FullScreenModeOptionKey.fullScreenModeAllScreens: NSNumber(value: false)] + if !view.isInFullScreenMode { + DispatchQueue.main.async { + self.view.enterFullScreenMode(NSScreen.main!, withOptions: fullScreenOptions) + } + } updateImage(im, frame: frame) updateAnalysis(analysis) hadImage = true diff --git a/rem/remApp.swift b/rem/remApp.swift index 8a7f129..1869cf1 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -656,7 +656,7 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { timelineViewWindow?.hasShadow = false timelineViewWindow?.level = .normal - timelineViewWindow?.collectionBehavior = [.fullScreenPrimary, .canJoinAllSpaces, .participatesInCycle] + timelineViewWindow?.collectionBehavior = [.fullScreenAuxiliary, .canJoinAllSpaces, .participatesInCycle] timelineViewWindow?.ignoresMouseEvents = false timelineView = TimelineView(viewModel: TimelineViewModel(), settingsManager: settingsManager, onClose: { DispatchQueue.main.async { [weak self] in @@ -664,10 +664,9 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { } }) timelineView?.viewModel.updateIndex(withIndex: index) - + timelineViewWindow?.contentView = NSHostingView(rootView: timelineView) timelineView?.viewModel.setIsOpen(isOpen: true) - self.timelineViewWindow?.toggleFullScreen(nil) timelineViewWindow?.makeKeyAndOrderFront(nil) DispatchQueue.main.async { self.timelineViewWindow?.orderFrontRegardless() // Ensure it comes to the front @@ -675,7 +674,6 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { } else if !isTimelineOpen() { timelineView?.viewModel.updateIndex(withIndex: index) timelineView?.viewModel.setIsOpen(isOpen: true) - self.timelineViewWindow?.toggleFullScreen(nil) timelineViewWindow?.makeKeyAndOrderFront(nil) DispatchQueue.main.async { self.timelineViewWindow?.orderFrontRegardless() // Ensure it comes to the front From 6d65c98810e91fbfba7b7fc47de8644db2983524 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Fri, 26 Apr 2024 12:20:57 -0400 Subject: [PATCH 10/12] fullScreenOptions --- rem/TimelineView.swift | 7 ------- rem/remApp.swift | 1 - 2 files changed, 8 deletions(-) diff --git a/rem/TimelineView.swift b/rem/TimelineView.swift index 2603b4a..716ec05 100644 --- a/rem/TimelineView.swift +++ b/rem/TimelineView.swift @@ -190,13 +190,6 @@ class CustomHostingViewController: NSViewController { } _interceptingView.customHostingView = customHostingView interceptingView = _interceptingView - - NSAnimationContext.runAnimationGroup({ context in - context.duration = 0.0 // Setting duration to zero effectively disables animations - self.view.window?.toggleFullScreen(nil) - }, completionHandler: { - // Any additional code after animation completes - }) } func updateImage(_ image: NSImage, frame: NSRect) { diff --git a/rem/remApp.swift b/rem/remApp.swift index 1869cf1..f7bd277 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -664,7 +664,6 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { } }) timelineView?.viewModel.updateIndex(withIndex: index) - timelineViewWindow?.contentView = NSHostingView(rootView: timelineView) timelineView?.viewModel.setIsOpen(isOpen: true) timelineViewWindow?.makeKeyAndOrderFront(nil) From af4e8e906a0c48da9e009ee73526649a670524ff Mon Sep 17 00:00:00 2001 From: Connorpar Date: Fri, 26 Apr 2024 12:22:18 -0400 Subject: [PATCH 11/12] cleanup --- rem/TimelineView.swift | 2 +- rem/remApp.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rem/TimelineView.swift b/rem/TimelineView.swift index 716ec05..01dad8c 100644 --- a/rem/TimelineView.swift +++ b/rem/TimelineView.swift @@ -177,7 +177,7 @@ class CustomHostingViewController: NSViewController { self.view.window?.makeKey() } } - + override func loadView() { let _interceptingView = CustomInterceptingView() _interceptingView.onClose = onClose diff --git a/rem/remApp.swift b/rem/remApp.swift index f7bd277..1869cf1 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -664,6 +664,7 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { } }) timelineView?.viewModel.updateIndex(withIndex: index) + timelineViewWindow?.contentView = NSHostingView(rootView: timelineView) timelineView?.viewModel.setIsOpen(isOpen: true) timelineViewWindow?.makeKeyAndOrderFront(nil) From 0733e071191d4afe153bcc9f44fdb44ee7a90b64 Mon Sep 17 00:00:00 2001 From: Connorpar Date: Fri, 26 Apr 2024 12:22:46 -0400 Subject: [PATCH 12/12] cleanup --- rem/remApp.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rem/remApp.swift b/rem/remApp.swift index 1869cf1..79d3661 100644 --- a/rem/remApp.swift +++ b/rem/remApp.swift @@ -664,7 +664,7 @@ func drawStatusBarIcon(rect: CGRect) -> Bool { } }) timelineView?.viewModel.updateIndex(withIndex: index) - + timelineViewWindow?.contentView = NSHostingView(rootView: timelineView) timelineView?.viewModel.setIsOpen(isOpen: true) timelineViewWindow?.makeKeyAndOrderFront(nil)