wminor
TSDThe Swift Den
•Created by wminor on 8/26/2023 in #swift-development
NSScreen visibleFrame / safeAreaInsets not adding up right?
I'm trying to compare
visibleFrame
and frame
to figure out whether the dock is currently showing on a given screen. Of course, I need to account for the menubar and any inset caused by a macbook notch as part of this. However, the number I'm getting don't quite add up right!
For example, on my M2 Macbook Air:
frame
has a height of 956 (as expected)
visibleFrame
has a height of 919
NSApp.mainMenu?.menuBarHeight
is 36
safeAreaInsets.top
is just 32
I take the maximum of the menu bar height and the notch inset height, which in this case is 36. Add 36 to the visible frame height: 36+919 = 955. But my frame is 956 high! Where's the missing point?!
Is this even the right approach? Is there a better way to detect whether the dock is showing in these types of cases?4 replies