RFR: 8252373: [macOS] Stage with owner disappears when moved to another screen
Kevin Rushforth
kcr at openjdk.org
Wed Oct 8 17:22:20 UTC 2025
This PR fixes the bug where owned stage will disappear on macOS if it is moved to another screen with the Mission Control setting of "Displays have separate spaces" enabled (which it is by default).
We fix this by managing owned windows ourself in glass rather than relying on NSWindow's childWindow feature, which we currently do. This matches what AWT does.
### Notes to reviewers:
The following changes are implemented:
* Each GlassWindow keeps a list of owned (child) windows. A window with an owner adds itself to its owner's list of child windows when created and removes itself when closed
* A new `reorderChildWindows` method is created to stack each child window above its owner, setting the level to be at least the same as its owner (to handle the case of an owned window of an always-on-top owner window). We call `reorderChildWindows` in various places that can alter the window stacking order, so we can preserve the desired order.
* When an owner window is closed, all child windows are recursively closed.
* When an owner window is iconified / deiconified, all child windows are recursively iconified / deiconified.
* When an owner window enters full screen, it recursively sets the `NSWindowCollectionBehaviorMoveToActiveSpace` behavior to temporarily enable moving the child window to the active space
Testing:
* Most of the testing can be done on a single screen, but you will need 2 screens to reproduce the bug by dragging an owned window from one screen to another (and verify that it is fixed)
* You can use the updated HelloModality test app to test this. It already had most of what was needed to test the various combinations; I added the ability to create / toggle the alwaysOnTop property of a Stage and the ability to initially create a stage on a secondary screen. I also added tooltips, which are implemented using owned popup windows.
* MonkeyTester also has some dialog tests that can be used to verify the behavior
NOTE: dragging an owner window no longer causes all child windows to move in lock step; this means that owned windows will now works more like it does on the Windows platform.
-------------
Commit messages:
- Remove or comment out log messages
- 8252373: [macOS] Stage with owner disappears when moved to another screen
Changes: https://git.openjdk.org/jfx/pull/1932/files
Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1932&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8252373
Stats: 235 lines in 5 files changed: 207 ins; 9 del; 19 mod
Patch: https://git.openjdk.org/jfx/pull/1932.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1932/head:pull/1932
PR: https://git.openjdk.org/jfx/pull/1932
More information about the openjfx-dev
mailing list