RFR: JDK-8312518 : [macos13] setFullScreenWindow() shows black screen on macOS 13 & above

Sergey Bylokhov serb at openjdk.org
Wed Jan 10 23:48:21 UTC 2024


On Wed, 10 Jan 2024 21:35:57 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

> A black screen is seen on newer versions of macOS (13.3 & above) when a window is set to full-screen using `setFullScreenWindow()`. The root cause was narrowed down to the shield level of the full-screen window vs the shield level of the captured display.
> 
> Following solutions were explored -
> 
> 1. Setting `kCGMaximumWindowLevelKey` as the shield level for the full screen window. But setting the fullscreen window to maximum available window level might cause z-order issues when other popup/screen savers are involved.
> 
>           int shieldLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey);
>           window.preFullScreenLevel = [nsWindow level];
>           [nsWindow setLevel: shieldLevel];
> 
> 2. Raise the window's level slightly (shieldLevel + 1) above the system shield window. 
> 
>             int shieldLevel = CGShieldingWindowLevel();
>             window.preFullScreenLevel = [nsWindow level];
>             [nsWindow setLevel: (shieldLevel + 1)]; 
> 
> 3. Keeping the shielding level as-is and bringing the window to the foreground after display is captured. The 3rd approach **(also the one Apple recommends)** ensures that the full screen window has focus as well as being visible and also maintains the correct z-order. This solution works as expected on older (< 13.3) and newer versions (13.3 & above) of macOS.
> 
>           if (CGDisplayCapture(aID) == kCGErrorSuccess) {
>                 ...
>                 ...
>                 int shieldLevel = CGShieldingWindowLevel();
>                 window.preFullScreenLevel = [nsWindow level];
>                 [nsWindow setLevel: shieldLevel];
>                 [nsWindow makeKeyAndOrderFront: nil];
>             }

How it will work now(and worked before) if the user will call toBack() on the such fullscreen window?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17358#issuecomment-1885934211


More information about the client-libs-dev mailing list