Integrated: JDK-8312518 : [macos13] setFullScreenWindow() shows black screen on macOS 13 & above
Harshitha Onkar
honkar at openjdk.org
Fri Jan 12 17:59:32 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];
> }
This pull request has now been integrated.
Changeset: 999e556b
Author: Harshitha Onkar <honkar at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/999e556be4302de4b6911e6d62ee5ca556a76469
Stats: 91 lines in 2 files changed: 90 ins; 0 del; 1 mod
8312518: [macos13] setFullScreenWindow() shows black screen on macOS 13 & above
Reviewed-by: serb, tr, azvegint
-------------
PR: https://git.openjdk.org/jdk/pull/17358
More information about the client-libs-dev
mailing list