Skip to content

Commit

Permalink
Fix for overlay panels not appearing immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Jul 6, 2024
1 parent 8241a4d commit 192c6ca
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions Ice/MenuBarAppearance/MenuBarOverlayPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ class MenuBarOverlayPanel: NSPanel {

private var cancellables = Set<AnyCancellable>()

/// Callbacks to perform after the panel is updated.
///
/// - Note: The callbacks are removed after each update.
private var updateCallbacks = [() -> Void]()

/// The context that manages panel update tasks.
private let updateTaskContext = UpdateTaskContext()

Expand All @@ -71,12 +66,12 @@ class MenuBarOverlayPanel: NSPanel {
/// A Boolean value that indicates whether the panel needs to be shown.
@Published var needsShow = false

/// Flags representing the components of the panel currently in need of an update.
@Published private(set) var updateFlags = Set<UpdateFlag>()

/// A Boolean value that indicates whether the user is dragging a menu bar item.
@Published var isDraggingMenuBarItem = false

/// Flags representing the components of the panel currently in need of an update.
@Published private(set) var updateFlags = Set<UpdateFlag>()

/// The frame of the application menu.
@Published private(set) var applicationMenuFrame: CGRect?

Expand Down Expand Up @@ -204,16 +199,9 @@ class MenuBarOverlayPanel: NSPanel {
guard let self, !flags.isEmpty else {
return
}
defer {
Task {
// must be run async, or this will not remove the flags
self.updateFlags.removeAll()
}
let updateCallbacks = self.updateCallbacks
self.updateCallbacks.removeAll()
for callback in updateCallbacks {
callback()
}
Task {
// must be run async, or this will not remove the flags
self.updateFlags.removeAll()
}
let windows = WindowInfo.getOnScreenWindows()
guard let owningDisplay = self.validate(for: .updates, with: windows) else {
Expand Down Expand Up @@ -332,16 +320,9 @@ class MenuBarOverlayPanel: NSPanel {
orderFrontRegardless()

updateFlags = [.applicationMenuFrame, .desktopWallpaper]
updateCallbacks.append { [weak self, weak appState] in
guard
let self,
let appState
else {
return
}
if !appState.menuBarManager.isMenuBarHiddenBySystem {
animator().alphaValue = 1
}

if !appState.menuBarManager.isMenuBarHiddenBySystem {
animator().alphaValue = 1
}
}

Expand Down

0 comments on commit 192c6ca

Please sign in to comment.