Skip to content

Commit

Permalink
Prevent window title overlay on Sequoia
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Aug 26, 2024
1 parent 5553931 commit c2caadf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Maccy/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

panel = FloatingPanel(
contentRect: NSRect(origin: .zero, size: Defaults[.windowSize]),
title: Bundle.main.bundleIdentifier ?? "org.p0deje.Maccy",
identifier: Bundle.main.bundleIdentifier ?? "org.p0deje.Maccy",
statusBarButton: statusItem.button
) {
ContentView()
Expand Down
5 changes: 2 additions & 3 deletions Maccy/FloatingPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class FloatingPanel<Content: View>: NSPanel, NSWindowDelegate {

init(
contentRect: NSRect,
title: String = "",
identifier: String = "",
statusBarButton: NSStatusBarButton? = nil,
view: () -> Content
) {
Expand All @@ -26,7 +26,7 @@ class FloatingPanel<Content: View>: NSPanel, NSWindowDelegate {
)

self.statusBarButton = statusBarButton
self.title = title
self.identifier = NSUserInterfaceItemIdentifier(identifier)

Defaults[.windowSize] = contentRect.size
delegate = self
Expand All @@ -45,7 +45,6 @@ class FloatingPanel<Content: View>: NSPanel, NSWindowDelegate {
standardWindowButton(.miniaturizeButton)?.isHidden = true
standardWindowButton(.zoomButton)?.isHidden = true


contentView = NSHostingView(
rootView: view()
// The safe area is ignored because the title bar still interferes with the geometry
Expand Down
8 changes: 6 additions & 2 deletions Maccy/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ struct ContentView: View {
.environment(\.scenePhase, scenePhase)
// FloatingPanel is not a scene, so let's implement custom scenePhase..
.onReceive(NotificationCenter.default.publisher(for: NSWindow.didBecomeKeyNotification)) {
if ($0.object as? NSWindow)?.title == Bundle.main.bundleIdentifier {
if let window = $0.object as? NSWindow,
let bundleIdentifier = Bundle.main.bundleIdentifier,
window.identifier == NSUserInterfaceItemIdentifier(bundleIdentifier) {
scenePhase = .active
}
}
.onReceive(NotificationCenter.default.publisher(for: NSWindow.didResignKeyNotification)) {
if ($0.object as? NSWindow)?.title == Bundle.main.bundleIdentifier {
if let window = $0.object as? NSWindow,
let bundleIdentifier = Bundle.main.bundleIdentifier,
window.identifier == NSUserInterfaceItemIdentifier(bundleIdentifier) {
scenePhase = .background
}
}
Expand Down
103 changes: 0 additions & 103 deletions MaccyTests/MenuFoooterTests.swift

This file was deleted.

0 comments on commit c2caadf

Please sign in to comment.