On Wed, 10 Jan 2024 23:45:57 GMT, Sergey Bylokhov <s...@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? @mrserb > How it will work now(and worked before) if the user will call toBack() on the > such fullscreen window? Tested both cases - current fix on macOS 13.3 & above + fullScreenWindow.toBack() - original code on older macOS version (11.5) + fullScreenWindow.toBack() It works the same in both cases - the shield window becomes the topmost window and a black screen is seen. ------------- PR Comment: https://git.openjdk.org/jdk/pull/17358#issuecomment-1886019314