|
1 | 1 | import AppKit |
2 | 2 | import CoreGraphics |
3 | 3 |
|
4 | | -/// Whether a display's menu bar is on screen right now, and how tall it is. |
| 4 | +/// Whether a display's menu bar is on screen, and its height. |
5 | 5 | /// |
6 | | -/// Neither `NSScreen` answer works [MEASURED 2026-10-02]. `frame.maxY - |
7 | | -/// visibleFrame.maxY` reads 38 on the notched built-in with the bar auto-hidden |
8 | | -/// (the notch's safe area) and 39 with it shown, and 0 on an external either |
9 | | -/// way. `menuBarAllowance` returns the bar's thickness even while it is hidden. |
| 6 | +/// `NSScreen` cannot tell [MEASURED 2026-10-02]. `frame.maxY - visibleFrame.maxY` |
| 7 | +/// reads 38 hidden and 39 shown on the notched built-in (the notch's safe area), |
| 8 | +/// 0 on an external either way; `menuBarAllowance` reports the bar's thickness |
| 9 | +/// even while it is hidden. |
10 | 10 | /// |
11 | | -/// What does change is the window server's own bar window: owner "Window |
12 | | -/// Server", layer 24, origin at the display's top-left, the display's full |
13 | | -/// width and the bar's height (0,0 1800x39 on the built-in, 1800,0 2560x30 on |
14 | | -/// an external). With the bar auto-hidden no Window Server window sits at |
15 | | -/// layer 24 on any display. It is matched on owner, layer and bounds, never on |
16 | | -/// its "Menubar" title: window titles are withheld from a process without |
17 | | -/// Screen Recording, which the app does not ask for, while owner, layer and |
18 | | -/// bounds are reported regardless. |
| 11 | +/// The window server's bar window does change: owner "Window Server", layer 24, |
| 12 | +/// at the display's top-left, full width, bar height (0,0 1800x39 on the |
| 13 | +/// built-in, 1800,0 2560x30 on an external). With the bar auto-hidden no Window |
| 14 | +/// Server window sits at layer 24 on any display. Matched on owner, layer and |
| 15 | +/// bounds, never the "Menubar" title: titles are withheld without Screen |
| 16 | +/// Recording, which the app does not request. |
19 | 17 | @MainActor |
20 | 18 | enum MenuBarVisibility { |
21 | 19 | private static let barLayer = 24 |
22 | | - /// Generous for any bar thickness, short of anything that could be a real window. |
| 20 | + /// Room for any bar thickness, short of a real window's height. |
23 | 21 | private static let heightRange: ClosedRange<CGFloat> = 1...60 |
24 | 22 |
|
25 | 23 | /// Nil while the bar is hidden, or when the window list cannot say. |
|
0 commit comments