Skip to content

Commit

Permalink
Don't include disabled items in application menu frame
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Jul 4, 2024
1 parent 09b5fb7 commit f9daa2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Ice/Accessibility/AccessibilityMenuBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ struct AccessibilityMenuBarItem {
/// The underyling UI element.
let uiElement: UIElement

/// A Boolean value that indicates whether the menu bar item is enabled.
var isEnabled: Bool {
(try? uiElement.attribute(.enabled)) == true
}

/// Creates an accessibility menu bar item from the given UI element.
///
/// - Parameter uiElement: A UI element that represents a menu bar item.
Expand Down
4 changes: 3 additions & 1 deletion Ice/MenuBar/MenuBarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ final class MenuBarManager: ObservableObject {
var menuBarFrame = try menuBar.frame()
menuBarFrame.origin = CGDisplayBounds(display).origin
menuBarFrame.size.width = try menuBar.menuBarItems().reduce(into: 0) { width, item in
try width += item.frame().width
if item.isEnabled {
try width += item.frame().width
}
}
if menuBarFrame.width == .zero {
return menuBarFrame
Expand Down

0 comments on commit f9daa2a

Please sign in to comment.