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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Added
- Settings › Advanced › "Right-click on the arrow": Show menu (the default, unchanged) or Show always-hidden icons. The second brings back the right-click of Hidden Bar before 1.11, which showed the always-hidden icons like Option-click does, so a Mac used without a keyboard (a TV, a remote) can reach them. The menu then opens with Option-right-click.
- 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
Expand Down
38 changes: 38 additions & 0 deletions HiddenBarTests/ExpandCollapseActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,44 @@ final class ExpandCollapseActionTests: XCTestCase {
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: .rightMouseUp, optionPressed: true), .toggleSeparators)
}

// "Right-click on the arrow": the menu unless the user picks the
// always-hidden icons, which is what right-click did before 1.11.
func testRightClickChoiceDefaultsToTheMenu() {
XCTAssertEqual(RightClickAction.default, .showMenu)
XCTAssertEqual(RightClickAction(storedValue: nil), .showMenu)
XCTAssertEqual(RightClickAction(storedValue: "nonsense"), .showMenu)
XCTAssertEqual(RightClickAction(storedValue: RightClickAction.showAlwaysHidden.rawValue), .showAlwaysHidden)
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: .rightMouseUp, optionPressed: false, rightClick: .showMenu), .contextMenu)
}

func testRightClickShowsAlwaysHiddenIconsWhenChosen() {
let action = ExpandCollapseActionResolver.action(eventType: .rightMouseUp, optionPressed: false, rightClick: .showAlwaysHidden)
XCTAssertEqual(action, .toggleSeparators)
XCTAssertFalse(action.mayShowArrivalsPrompt)
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: .rightMouseUp, optionPressed: false, shiftPressed: true,
rightClick: .showAlwaysHidden), .toggleSeparators)
}

// With right-click taken, the menu stays one Option away.
func testOptionRightClickShowsTheMenuWhenRightClickShowsAlwaysHidden() {
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: .rightMouseUp, optionPressed: true, rightClick: .showAlwaysHidden), .contextMenu)
}

// The choice is about the right button only: left clicks and half clicks keep their meaning.
func testRightClickChoiceLeavesOtherPressesAlone() {
for choice in RightClickAction.allCases {
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: nil, optionPressed: false, rightClick: choice), .toggle)
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: .leftMouseUp, optionPressed: false, rightClick: choice), .toggle)
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: .leftMouseUp, optionPressed: true, rightClick: choice), .toggleSeparators)
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: .leftMouseUp, optionPressed: false, shiftPressed: true, rightClick: choice),
.toggleWithFullBar)
for type in [NSEvent.EventType.rightMouseDown, .rightMouseDragged] {
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: type, optionPressed: false, rightClick: choice), .ignore)
XCTAssertEqual(ExpandCollapseActionResolver.action(eventType: type, optionPressed: true, rightClick: choice), .ignore)
}
}
}

// #434: on macOS 27 the button's mouse-up event arrives with no modifier
// flags while Option is physically held; the live flags must still count.
func testOptionDetectedFromLiveFlagsWhenEventFlagsAreEmpty() {
Expand Down
2 changes: 1 addition & 1 deletion HiddenTests/AppStoreMigrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ final class AppStoreMigrationTests: XCTestCase {
UserDefaults.Key.revealOnShakeEnabled, UserDefaults.Key.newAppDefaultSection,
UserDefaults.Key.findHiddenIconShortcut,
UserDefaults.Key.presentationAutoMirrorEnabled, UserDefaults.Key.presentationSensitiveApps,
UserDefaults.Key.presentationShortcut,
UserDefaults.Key.presentationShortcut, UserDefaults.Key.rightClickAction,
]
XCTAssertEqual(Set(AppStoreSettingsImport.importableKeys.keys), appKeys)
}
Expand Down
40 changes: 39 additions & 1 deletion HiddenTests/SettingsWindowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class SettingsWindowTests: XCTestCase {
UserDefaults.Key.newAppDefaultSection, // Icons: when an app adds a new icon
UserDefaults.Key.presentationShortcut, // Presentation mode shortcut, macOS 27 direct only
UserDefaults.Key.presentationSensitiveApps, // Presentation mode sensitive apps, macOS 27 direct only
UserDefaults.Key.rightClickAction, // Advanced: right-click on the arrow
]

private var saved: [String: Any] = [:]
Expand Down Expand Up @@ -185,6 +186,41 @@ final class SettingsWindowTests: XCTestCase {
XCTAssertFalse(NotchOverflowSupport.isAvailable(osMajorVersion: 27, hasNotch: false))
}

// Given the Advanced pane, in the App Store build on macOS 26 and the direct build on macOS 27
// When picking "Show always-hidden icons", then "Show menu" in "Right-click on the arrow"
// Then rightClickAction stores each choice, the popup starts on Show menu when nothing is
// stored, and the caption says how to reach what right-click no longer does
func test_advanced_rightClickPopupWritesItsKey() throws {
var old = fullContext()
old.build = .appStore
old.osMajorVersion = 26
for context in [old, fullContext()] {
AppDefaults.store.removeObject(forKey: UserDefaults.Key.rightClickAction)
let pane = AdvancedSettingsViewController(context: context)
let popup = try XCTUnwrap(control(UserDefaults.Key.rightClickAction, in: Self.subviews(of: pane.view)) as? NSPopUpButton)
func captions() -> [String] { Self.subviews(of: pane.view).compactMap { ($0 as? NSTextField)?.stringValue } }

XCTAssertEqual(popup.itemTitles, ["Show menu", "Show always-hidden icons"])
XCTAssertEqual(popup.indexOfSelectedItem, 0)
XCTAssertTrue(captions().contains(AdvancedSettingsViewController.rightClickCaption(for: .showMenu)))
for choice in [RightClickAction.showAlwaysHidden, .showMenu] {
popup.selectItem(at: RightClickAction.allCases.firstIndex(of: choice)!)
popup.sendAction(popup.action, to: popup.target)
XCTAssertEqual(AppDefaults.store.string(forKey: UserDefaults.Key.rightClickAction), choice.rawValue)
XCTAssertEqual(Preferences.rightClickAction, choice)
let shown = captions()
XCTAssertTrue(shown.contains(AdvancedSettingsViewController.rightClickCaption(for: choice)), "\(choice) caption missing")
for other in RightClickAction.allCases where other != choice {
XCTAssertFalse(shown.contains(AdvancedSettingsViewController.rightClickCaption(for: other)), "\(other) caption still shown")
}
}

// Set elsewhere (defaults write), the popup follows.
Preferences.rightClickAction = .showAlwaysHidden
XCTAssertEqual(popup.indexOfSelectedItem, 1)
}
}

// Given the Appearance tiles
// When clicking each
// Then arrowStyle stores that style's name, as the old popup did
Expand Down Expand Up @@ -499,7 +535,9 @@ final class SettingsWindowTests: XCTestCase {
// Then each locale carries them (English text for now), so none shows a raw key
func test_everyLocale_carriesTheSettingsKeys() {
let keys = ["Hidden Bar is working", "Hide icons again", "Never", "After %d seconds", "Your menu bar",
"This App Store version can't hide icons on macOS 27", "Check for Updates…", "What's new"]
"This App Store version can't hide icons on macOS 27", "Check for Updates…", "What's new",
"Right-click on the arrow", "Show menu", "Show always-hidden icons",
"Option-click the arrow to see always-hidden icons.", "Option-right-click the arrow to open the menu."]
let localizations = Bundle.main.localizations.filter { $0 != "Base" }
XCTAssertGreaterThan(localizations.count, 5)
for locale in localizations {
Expand Down
5 changes: 5 additions & 0 deletions docs/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Everything Hidden Bar can do, including the parts with no UI.
the separator's left are hidden when collapsed.
- **Option-click the arrow**: show/hide the separators and the always-hidden
area without expanding.
- **Right-click the arrow to show always-hidden icons** (Settings › Advanced ›
"Right-click on the arrow": Show always-hidden icons): right-click then does
what Option-click does, as it did before 1.11, so no keyboard is needed.
The menu moves to **Option-right-click**. The default stays Show menu.
- **Shift-click the arrow**: expand and use the full menu bar for this
expansion only, like "Use the full menu bar on expanding" but without
changing the setting. It reverts when the bar collapses.
Expand Down Expand Up @@ -76,6 +80,7 @@ Tabs in a centered control at the top (Cmd+1 to Cmd+5). A status card at the top
| Appearance | Fade the arrow when icons are hidden | `stealthExpandIconEnabled` |
| Advanced | Show this window when Hidden Bar opens | `isShowPreferences` |
| Advanced | Make room for icons while they are shown: the app turns "regular" while expanded, so the frontmost app's menus give way | `useFullStatusBarOnExpandEnabled` |
| Advanced | Right-click on the arrow: Show menu (default) or Show always-hidden icons, which moves the menu to Option-right-click | `rightClickAction` (`showMenu`, `showAlwaysHidden`) |
| Advanced (notch Macs) | Reach icons behind the camera notch | `notchOverflowEnabled` |
| Advanced (macOS 27, direct) | Pause hiding while macOS shows Now Playing, Focus and similar items: macOS 27 hides these items whenever an app hides icons, so while one shows, Hidden Bar hides nothing | `pauseHidingForUnkeepableItems` |
| About (direct) | Check for updates automatically, Check for Updates… | Sparkle's `SUEnableAutomaticChecks` |
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions hidden/Common/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ enum Preferences {
}
}

// What a plain right-click on the arrow does. Stored as the choice's name;
// anything unreadable reads as the menu, the default since 1.11.
static var rightClickAction: RightClickAction {
get {
RightClickAction(storedValue: AppDefaults.store.string(forKey: UserDefaults.Key.rightClickAction))
}

set {
AppDefaults.store.set(newValue.rawValue, forKey: UserDefaults.Key.rightClickAction)
NotificationCenter.default.post(Notification(name: .prefsChanged))
}
}

static var notchOverflowEnabled: Bool {
get {
AppDefaults.store.bool(forKey: UserDefaults.Key.notchOverflowEnabled)
Expand Down
1 change: 1 addition & 0 deletions hidden/Extensions/UserDefault+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extension UserDefaults {
static let presentationAutoMirrorEnabled = "presentationAutoMirrorEnabled"
static let presentationSensitiveApps = "presentationSensitiveApps"
static let presentationShortcut = "presentationShortcut"
static let rightClickAction = "rightClickAction"
// Internal: not user-facing, so not in the App Store import whitelist.
static let menuBarCatalogFirstSeen = "menuBarCatalogFirstSeen"
static let arrivalsPending = "arrivalsPending"
Expand Down
1 change: 1 addition & 0 deletions hidden/Features/AppStoreMigration/AppStoreMigration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum AppStoreSettingsImport {
UserDefaults.Key.presentationAutoMirrorEnabled: .number,
UserDefaults.Key.presentationSensitiveApps: .dictionary,
UserDefaults.Key.presentationShortcut: .data,
UserDefaults.Key.rightClickAction: .string,
]

static func containerPreferencesURL(home: URL, bundleIdentifier: String) -> URL {
Expand Down
45 changes: 44 additions & 1 deletion hidden/Features/Settings/AdvancedSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ import AppKit
final class AdvancedSettingsViewController: SettingsPaneController {
private var macOSAlsoHidesCaption: NSTextField?

/// English title of a "Right-click on the arrow" choice, also its Localizable.strings key.
static func rightClickTitle(for choice: RightClickAction) -> String {
switch choice {
case .showMenu: return "Show menu"
case .showAlwaysHidden: return "Show always-hidden icons"
}
}

/// Where the action right-click does not do went.
static func rightClickCaption(for choice: RightClickAction) -> String {
switch choice {
case .showMenu: return "Option-click the arrow to see always-hidden icons.".localized
case .showAlwaysHidden: return "Option-right-click the arrow to open the menu.".localized
}
}

override func buildForm() {
let showWindow = boundSwitch(UserDefaults.Key.isShowPreference, read: { Preferences.isShowPreference },
write: { Preferences.isShowPreference = $0 })
Expand All @@ -21,7 +37,8 @@ final class AdvancedSettingsViewController: SettingsPaneController {
var rows = [SettingsForm.row("Show this window when Hidden Bar opens".localized, control: showWindow),
SettingsForm.row("Make room for icons while they are shown".localized,
caption: "Hides the menus of the app you are using while hidden icons are shown, so more icons fit.".localized,
control: fullBar)]
control: fullBar),
rightClickRow()]
// The notch row only where a notch exists and macOS can put icons behind it.
if context.showsNotchOverflow {
let notch = boundSwitch(UserDefaults.Key.notchOverflowEnabled, read: { Preferences.notchOverflowEnabled },
Expand Down Expand Up @@ -62,6 +79,32 @@ final class AdvancedSettingsViewController: SettingsPaneController {
refreshAll()
}

// A popup, not a switch: it names both choices, like the menu it replaces.
private func rightClickRow() -> NSView {
let popup = NSPopUpButton(frame: .zero, pullsDown: false)
popup.controlSize = .small
for choice in RightClickAction.allCases {
popup.addItem(withTitle: Self.rightClickTitle(for: choice).localized)
}
popup.identifier = NSUserInterfaceItemIdentifier(UserDefaults.Key.rightClickAction)
popup.target = self
popup.action = #selector(rightClickPicked(_:))
let row = SettingsForm.row("Right-click on the arrow".localized,
caption: Self.rightClickCaption(for: Preferences.rightClickAction), control: popup)
let caption = (row.subviews.first { $0 is NSStackView } as? NSStackView)?.arrangedSubviews.last as? NSTextField
onRefresh { [weak popup, weak caption] in
let choice = Preferences.rightClickAction
popup?.selectItem(at: RightClickAction.allCases.firstIndex(of: choice) ?? 0)
caption?.stringValue = Self.rightClickCaption(for: choice)
}
return row
}

@objc private func rightClickPicked(_ sender: NSPopUpButton) {
guard RightClickAction.allCases.indices.contains(sender.indexOfSelectedItem) else { return }
Preferences.rightClickAction = RightClickAction.allCases[sender.indexOfSelectedItem]
}

private func refreshMacOSAlsoHides() {
let names = NativeVisibilityEngine.knownUnkeepableSystemItems.map(NativeVisibilityEngine.displayName(ofSystemItem:))
+ NativeVisibilityEngine.knownUnkeepableApps
Expand Down
23 changes: 22 additions & 1 deletion hidden/Features/StatusBar/ExpandCollapseAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ enum ExpandCollapseAction: CaseIterable {
var closesArrowPopovers: Bool { self == .contextMenu }
}

// What a plain right-click on the arrow does (Settings › Advanced). Before 1.11
// it showed the always-hidden icons; since then it opens the menu. The raw value
// is what Preferences stores.
enum RightClickAction: String, CaseIterable {
case showMenu
case showAlwaysHidden

static let `default`: RightClickAction = .showMenu

/// Anything unknown or missing reads as the default.
init(storedValue: String?) {
self = storedValue.flatMap(RightClickAction.init(rawValue:)) ?? .default
}
}

enum ExpandCollapseActionResolver {
// On macOS 27 the mouse-up event a status bar button hands to its action
// carries empty modifier flags even while Option is held (#434), so the live
Expand All @@ -43,12 +58,18 @@ enum ExpandCollapseActionResolver {
// A nil event type means there is no real NSEvent behind the press, which is
// what assistive synthesis (VoiceOver AXPress) produces: treat it as a plain
// left click so VoiceOver users can toggle the bar at all.
static func action(eventType: NSEvent.EventType?, optionPressed: Bool, shiftPressed: Bool = false) -> ExpandCollapseAction {
// With right-click set to show the always-hidden icons, the two swap: a
// right-click toggles them and Option-right-click opens the menu.
static func action(eventType: NSEvent.EventType?, optionPressed: Bool, shiftPressed: Bool = false,
rightClick: RightClickAction = .default) -> ExpandCollapseAction {
guard let eventType = eventType else { return .toggle }
switch eventType {
case .leftMouseDown, .leftMouseDragged, .rightMouseDown, .rightMouseDragged: return .ignore
default: break
}
if eventType == .rightMouseUp && rightClick == .showAlwaysHidden {
return optionPressed ? .contextMenu : .toggleSeparators
}
if optionPressed { return .toggleSeparators }
switch eventType {
case .leftMouseUp: return shiftPressed ? .toggleWithFullBar : .toggle
Expand Down
7 changes: 5 additions & 2 deletions hidden/Features/StatusBar/StatusBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ class StatusBarController: MenuBarItemProvider {
// so VoiceOver can operate the bar.
let optionPressed = ExpandCollapseActionResolver.isOptionPressed(eventFlags: event?.modifierFlags, liveFlags: NSEvent.modifierFlags)
let shiftPressed = ExpandCollapseActionResolver.isShiftPressed(eventFlags: event?.modifierFlags, liveFlags: NSEvent.modifierFlags)
let action = ExpandCollapseActionResolver.action(eventType: event?.type, optionPressed: optionPressed, shiftPressed: shiftPressed)
let action = ExpandCollapseActionResolver.action(eventType: event?.type, optionPressed: optionPressed, shiftPressed: shiftPressed,
rightClick: Preferences.rightClickAction)
if action.closesArrowPopovers { closeArrowPopovers() }
switch action {
case .ignore:
Expand All @@ -328,9 +329,11 @@ class StatusBarController: MenuBarItemProvider {
// Right-click opens the same context menu the separator has (#356),
// making settings reachable from the control everyone clicks.
// The separators/always-hidden toggle stays on option-click.
// With right-click set to the always-hidden icons, Option-right-click.
showContextMenu(from: sender)
case .toggleSeparators:
// Both option+left and option+right land here: separators toggle.
// Option-click lands here, and a plain right-click when the user
// picked "Show always-hidden icons" for it.
self.showHideSeparatorsAndAlwayHideArea()
}
}
Expand Down
Loading