RFR: JDK-8312518 : [macos13] setFullScreenWindow() shows black screen on macOS 13 & above
Harshitha Onkar
honkar at openjdk.org
Wed Jan 10 21:43:39 UTC 2024
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 windows 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];
}
-------------
Commit messages:
- removed extra line
- test changes
- summary updated
- test changes
- initial changes
Changes: https://git.openjdk.org/jdk/pull/17358/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17358&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8312518
Stats: 91 lines in 2 files changed: 90 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/17358.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/17358/head:pull/17358
PR: https://git.openjdk.org/jdk/pull/17358
More information about the client-libs-dev
mailing list