aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Shared
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-05-06 16:51:42 -0700
committerDustin Mierau <dustin@mierau.me>2024-05-06 16:51:42 -0700
commit043bfc4cf7b8cd5f6247ed2af82ff0159622f7d6 (patch)
tree4c9613c61731b6690c57a845eb96f0999e8ae0d6 /Hotline/Shared
parentcda35aa9e697736b1cf0e8422c8cc18654dc7f11 (diff)
Fix some flakiness around the banner window when moving between fullscreen/spaces and desktop.
Diffstat (limited to 'Hotline/Shared')
-rw-r--r--Hotline/Shared/HotlinePanel.swift22
1 files changed, 18 insertions, 4 deletions
diff --git a/Hotline/Shared/HotlinePanel.swift b/Hotline/Shared/HotlinePanel.swift
index 60d1337..ee881a2 100644
--- a/Hotline/Shared/HotlinePanel.swift
+++ b/Hotline/Shared/HotlinePanel.swift
@@ -1,9 +1,11 @@
import Cocoa
import SwiftUI
+fileprivate let HOTLINE_PANEL_SIZE: CGSize = CGSizeMake(476, 114)
+
class HotlinePanel: NSPanel {
init(_ view: HotlinePanelView) {
- super.init(contentRect: .zero, styleMask: [.nonactivatingPanel, .titled, .closable, .utilityWindow, .fullSizeContentView], backing: .buffered, defer: false)
+ super.init(contentRect: NSRect(x: 0, y: 0, width: HOTLINE_PANEL_SIZE.width, height: HOTLINE_PANEL_SIZE.height), styleMask: [.nonactivatingPanel, .titled, .closable, .utilityWindow, .fullSizeContentView], backing: .buffered, defer: false)
// Make sure that the panel is in front of almost all other windows
self.isFloatingPanel = false
@@ -12,7 +14,9 @@ class HotlinePanel: NSPanel {
self.animationBehavior = .utilityWindow
// Allow the panel to appear in a fullscreen space
- self.collectionBehavior.insert(.fullScreenAuxiliary)
+// self.collectionBehavior.insert(.fullScreenAuxiliary)
+ self.collectionBehavior.insert(.canJoinAllSpaces)
+ self.collectionBehavior.insert(.ignoresCycle)
// Don't delete panel state when it's closed.
self.isReleasedWhenClosed = false
@@ -31,9 +35,19 @@ class HotlinePanel: NSPanel {
self.titlebarAppearsTransparent = true
let hostingView = NSHostingView(rootView: view.edgesIgnoringSafeArea(.top))
- hostingView.sizingOptions = [.standardBounds]
+ hostingView.sizingOptions = [.preferredContentSize]
- self.contentView = hostingView
+ let visualEffectView = NSVisualEffectView(frame: NSRect(x: 0, y: 0, width: HOTLINE_PANEL_SIZE.width, height: HOTLINE_PANEL_SIZE.height))
+ visualEffectView.material = .headerView
+ visualEffectView.blendingMode = .behindWindow
+ visualEffectView.state = NSVisualEffectView.State.active
+ visualEffectView.autoresizingMask = [.width, .height]
+ visualEffectView.autoresizesSubviews = true
+ visualEffectView.addSubview(hostingView)
+
+ self.contentView = visualEffectView
+
+ hostingView.frame = visualEffectView.bounds
self.cascadeTopLeft(from: NSMakePoint(16, 16))
}