Skip to content

Commit

Permalink
Refactor menu padding for application menu frame
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Jul 20, 2024
1 parent bd66430 commit a72d8a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Ice/Events/EventManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,11 @@ extension EventManager {
let mouseLocation = MouseCursor.location(flipped: true),
let screen = bestScreen,
let appState,
let applicationMenuFrame = appState.menuBarManager.getApplicationMenuFrame(for: screen.displayID)
var applicationMenuFrame = appState.menuBarManager.getApplicationMenuFrame(for: screen.displayID)
else {
return false
}
applicationMenuFrame.size.width += 15 // extra width to accomodate menu padding
return applicationMenuFrame.contains(mouseLocation)
}

Expand Down
5 changes: 1 addition & 4 deletions Ice/MenuBar/MenuBarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ final class MenuBarManager: ObservableObject {
}

let itemFrames = items.lazy.compactMap { try? $0.attribute(.frame) as CGRect? }
var applicationMenuFrame = itemFrames.reduce(.null, CGRectUnion)
let applicationMenuFrame = itemFrames.reduce(.null, CGRectUnion)

if applicationMenuFrame.width <= 0 {
return nil
Expand All @@ -344,9 +344,6 @@ final class MenuBarManager: ObservableObject {
return nil
}

// add extra width to accomodate menu padding
applicationMenuFrame.size.width += 15

return applicationMenuFrame
}

Expand Down
4 changes: 2 additions & 2 deletions Ice/MenuBarAppearance/MenuBarOverlayPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ private class MenuBarOverlayPanelContentView: NSView {
return .zero
}
if shouldInset {
maxX -= 5
maxX += 10
if info.leading.leadingEndCap == .square {
maxX += appearanceManager.menuBarInsetAmount
}
} else {
maxX += 5
maxX += 20
}
return CGRect(x: rect.minX, y: rect.minY, width: maxX, height: rect.height)
}()
Expand Down

0 comments on commit a72d8a0

Please sign in to comment.