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?2 Replies
Visually, does this cause issues in your code
I'm trying to use it to detect whether the dock is showing or not (seems to be the generally recommended approach i've found)
so yes, if they don't add up, it's hard to detect, unless i add some kind of padding amount to account for this, which doesn't feel super robust