Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Added
- Direct build on macOS 27: when you expand the bar and some of the revealed icons do not fit (on a notched MacBook, right of the notch), macOS puts them into its own « button. Hidden Bar now says so once, after an expand by click or hotkey: "Some icons do not fit in the menu bar, so macOS moved them into its own « button. Click « to see them. To make room, move icons you rarely use to the always-hidden section." It never shows again, and the collapse notice from before stays separate.

### Changed
- Settings › Advanced: the switch "Show all icons while macOS hides one right of the arrow" is now "Pause hiding while macOS shows Now Playing, Focus and similar items", with a note that Hidden Bar hides nothing while one of them shows. Same stored setting, same behavior ([#446](https://github.com/dwarvesf/hidden/issues/446)).

Expand Down
105 changes: 105 additions & 0 deletions HiddenTests/SystemOverflowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,111 @@ final class SystemOverflowTests: XCTestCase {
XCTAssertFalse(policy.shouldShow())
XCTAssertFalse(SystemOverflowNoticePolicy(defaults: defaults).shouldShow())
}

// MARK: expand notice: the decision

func test_expandNoticeShowsOnlyWhenExpandedAndItemInOverflowAndNotShown() {
for isExpanded in [true, false] {
for inOverflow in [true, false] {
for alreadyShown in [true, false] {
let show = SystemOverflowNoticePolicy.shouldShowAfterExpand(
isExpanded: isExpanded, hiddenItemInOverflow: inOverflow, alreadyShown: alreadyShown)
XCTAssertEqual(show, isExpanded && inOverflow && !alreadyShown,
"expanded \(isExpanded), in overflow \(inOverflow), shown \(alreadyShown)")
}
}
}
}

func test_expandNoticeFlagIsSeparateFromTheCollapseNotice() {
let suite = "SystemOverflowTests.\(UUID().uuidString)"
let defaults = UserDefaults(suiteName: suite)!
defer { defaults.removePersistentDomain(forName: suite) }
let policy = SystemOverflowNoticePolicy(defaults: defaults)
policy.recordShown()
XCTAssertTrue(policy.shouldShowAfterExpand())
policy.recordExpandShown()
XCTAssertFalse(policy.shouldShowAfterExpand())
XCTAssertFalse(SystemOverflowNoticePolicy(defaults: defaults).shouldShowAfterExpand())

let other = UserDefaults(suiteName: suite + ".other")!
defer { other.removePersistentDomain(forName: suite + ".other") }
let fresh = SystemOverflowNoticePolicy(defaults: other)
fresh.recordExpandShown()
XCTAssertTrue(fresh.shouldShow(), "the expand notice does not silence the collapse notice")
}

// MARK: expand notice: which hidden apps are in «

private func item(_ bundle: String, _ axFrame: CGRect, unreadable: Bool = false) -> MenuBarInventoryItem {
MenuBarInventoryItem(bundleIdentifier: bundle, frame: axFrame, isUnreadable: unreadable)
}

private func overflowed(hidden: Set<String>, running: Set<String>? = nil,
inventory: [MenuBarInventoryItem], indicators: [SystemOverflowButton]) -> Set<String> {
SystemOverflowExpandMatcher.bundlesInOverflow(
hidden: hidden, running: running ?? hidden, inventory: inventory, indicators: indicators,
displays: MenuBarDisplay.displays(screenFrames: [main, portrait]), primaryScreenMaxY: primaryMaxY)
}

private let onBar = CGRect(x: 900, y: 0, width: 24, height: 24)

func test_hiddenAppMissingFromAccessibilityWhileButtonExistsIsInOverflow() {
let result = overflowed(hidden: ["a.app", "b.app"], inventory: [item("a.app", onBar)], indicators: [mainButton])
XCTAssertEqual(result, ["b.app"])
}

func test_nothingIsInOverflowWithoutAButton() {
XCTAssertEqual(overflowed(hidden: ["a.app"], inventory: [], indicators: []), [])
}

func test_everyHiddenAppOnTheBarMeansNoOverflow() {
let result = overflowed(hidden: ["a.app", "b.app"],
inventory: [item("a.app", onBar), item("b.app", onBar.offsetBy(dx: 30, dy: 0))],
indicators: [mainButton])
XCTAssertEqual(result, [])
}

func test_hiddenAppListedUnderTheButtonIsInOverflow() {
let result = overflowed(hidden: ["a.app"], inventory: [item("a.app", mainAXFrame)], indicators: [mainButton])
XCTAssertEqual(result, ["a.app"])
}

func test_hiddenAppListedOnNoDisplayIsInOverflow() {
let off = CGRect(x: 0, y: 5000, width: 24, height: 24)
let result = overflowed(hidden: ["a.app"], inventory: [item("a.app", off)], indicators: [mainButton])
XCTAssertEqual(result, ["a.app"])
}

func test_oneOverflowedItemOfSeveralCounts() {
let result = overflowed(hidden: ["a.app"],
inventory: [item("a.app", onBar), item("a.app", mainAXFrame)],
indicators: [mainButton])
XCTAssertEqual(result, ["a.app"])
}

func test_appThatDidNotAnswerAccessibilityIsNotJudged() {
let result = overflowed(hidden: ["a.app"], inventory: [item("a.app", .zero, unreadable: true)], indicators: [mainButton])
XCTAssertEqual(result, [])
}

func test_appThatIsNotRunningIsNotCounted() {
let result = overflowed(hidden: ["a.app", "b.app"], running: ["a.app"],
inventory: [item("a.app", onBar)], indicators: [mainButton])
XCTAssertEqual(result, [])
}

func test_systemExtrasAreNotCounted() {
let result = overflowed(hidden: ["com.apple.controlcenter", "com.apple.MenuBarAgent"],
inventory: [], indicators: [mainButton])
XCTAssertEqual(result, [])
}

func test_buttonWithoutFrameStillCountsAnAppMissingFromTheList() {
let unreadable = SystemOverflowButton(state: .closed, frame: nil)
XCTAssertEqual(overflowed(hidden: ["a.app"], inventory: [], indicators: [unreadable]), ["a.app"])
XCTAssertEqual(overflowed(hidden: ["a.app"], inventory: [item("a.app", mainAXFrame)], indicators: [unreadable]), [])
}
}

#endif
1 change: 1 addition & 0 deletions docs/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ To undo any of them: `defaults delete com.dwarvesv.minimalbar <key>`.
| Login item missing after denying it once | System Settings > General > Login Items: re-enable Hidden Bar, then toggle the pref off/on |
| The old "LauncherApplication" login item from a version before 1.11 (System Settings > General > Login Items & Extensions lists it inside "Hidden Bar" under Allow in the Background; a "Hidden Bar" row there is normal while launch at login is on) | With "Open Hidden Bar at login" on, launch the current version once; it removes the old item. Otherwise turn "Open Hidden Bar at login" off and on in Settings |
| App language stuck | See the `AppleLanguages` command above, or System Settings > General > Language & Region > Applications |
| A second arrow « appears when I expand (macOS 27 direct build) | The icons Hidden Bar reveals do not all fit in the menu bar (on a notched MacBook, right of the notch), so macOS puts some into its own « button. macOS offers no setting to turn this off. Click « to see them, and move icons you rarely use to the always-hidden section (Settings > Icons) to make room. Hidden Bar says this once, the first time an expand overflows |
| Nothing hides on a macOS 27 beta | Known (issue #360); the menu bar re-architecture broke the hiding mechanism, fix under investigation |
| A new or just-updated app's icon shows up already hidden | macOS 26 and earlier, or the App Store build: expected, see "Why new icons start hidden" below; ⌘-drag it to the right of the separator once. macOS 27 direct build: new and relaunched apps start visible (Pinned sections, beta) |
| An app jumps into the hidden section by itself (BitBar, SwiftBar) | macOS 27 direct build: in Settings > Icons, tick "Ignore drags" on that app; it then keeps the section you picked |
Expand Down
5 changes: 5 additions & 0 deletions hidden/Features/StatusBar/Engine/MenuBarEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ protocol MenuBarEngine: AnyObject {
// can tell a menu-bar app's popup window. Empty when the engine reads none.
var menuBarItemOwners: Set<String> { get }

// Bundles the last read put in the hidden section: what an expand brings back
// onto the bar. Empty when the engine reads none.
var hiddenSectionBundles: Set<String> { get }

// The user expanded or collapsed the bar, so a clock click no longer
// collapses it when Notification Center closes.
func userChangedBar()
Expand All @@ -69,6 +73,7 @@ extension MenuBarEngine {
var isArrangementKnown: Bool { return true }
var defersAutoCollapse: Bool { return false }
var menuBarItemOwners: Set<String> { return [] }
var hiddenSectionBundles: Set<String> { return [] }
func userChangedBar() {}
func separatorsHiddenForCollapse(current: Bool) -> Bool { return current }
var offersShowEverything: Bool { return false }
Expand Down
4 changes: 4 additions & 0 deletions hidden/Features/StatusBar/Engine/NativeVisibilityEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@ final class NativeVisibilityEngine: MenuBarEngine {
return Set(read + complete)
}

var hiddenSectionBundles: Set<String> {
return Set(layout?.bundles(in: [.hidden]) ?? [])
}

// Set by the controller: the palette's reveal session also keeps a bar the user changed.
var onUserChangedBar: (() -> Void)?

Expand Down
12 changes: 10 additions & 2 deletions hidden/Features/StatusBar/StatusBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class StatusBarController: MenuBarItemProvider {
if AccessibilityPermission.shared.arrowClickOpensPreferences(isCollapsed: isCollapsed) {
Util.showPrefWindow()
}
self.isCollapsed ? self.expandMenubar() : self.collapseMenuBar(userInitiated: true)
self.isCollapsed ? self.expandMenubar(userInitiated: true) : self.collapseMenuBar(userInitiated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
self?.isToggle = false
}
Expand Down Expand Up @@ -483,8 +483,12 @@ class StatusBarController: MenuBarItemProvider {
#endif
}

private func expandMenubar(activatingApp: Bool = true) {
private func expandMenubar(activatingApp: Bool = true, userInitiated: Bool = false) {
guard self.isCollapsed else {return}
#if HIDDENBAR_NATIVE_VISIBILITY
// Read before the engine expands: it is what the bar hid until now.
let hiddenBundles = userInitiated ? menuBarEngine.hiddenSectionBundles : []
#endif
menuBarEngine.expand()
if let button = btnExpandCollapse.button {
button.image = Assets.collapseImage
Expand All @@ -499,6 +503,10 @@ class StatusBarController: MenuBarItemProvider {
}
#if HIDDENBAR_NATIVE_VISIBILITY
presentationController?.barExpanded()
if userInitiated {
SystemOverflowNotice.shared.checkAfterExpand(hiddenBundles: hiddenBundles,
isExpanded: { [weak self] in !(self?.isCollapsed ?? true) })
}
#endif
}

Expand Down
Loading