'Determine dimensions of full-screen macOS application windows below the camera housing notch

I need to determine the dimensions of a full-screen application window on a display with a camera housing notch. I'm using a Mac Book Pro (14-inch, 2021) but I'm looking for a general technique. Crucially, I need to do this from outside the full-screen application itself before it is launched, so I can predict the window position in advance in an application testing/screen-capture scenario.

The full screen size including the notch region is reported from NSScreen frame as 1512x982. The safeAreaInsets are reported as top = 32.0 with the other three edges being zero. Subtracting the top inset gives a size of 1512x950, yet full-screen applications (I'm using Chromium) report a maximised window size of 1512x945, which is what we might expect as it has a 16:10 aspect ratio. For example, SwitchResX allows setting the resolution to 1512x945 HiDPI 16:10 to ignore the notch area.

The regions returned by auxiliaryTopLeftArea and auxiliaryTopRightArea also have a height of 32.

Confusingly, visibleFrame reports 1512x944 (not 945) and I'm not sure where the one pixel discrepancy is coming from.

What API calls can I make to determine the dimensions of the full-screen application area?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source