RFR: 8252373: [macOS] Stage with owner disappears when moved to another screen [v2]
Ambarish Rapte
arapte at openjdk.org
Fri Oct 17 06:19:23 UTC 2025
On Wed, 8 Oct 2025 18:17:11 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> 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.
>
> Kevin Rushforth has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>
> - Merge branch 'master' into 8252373-mac-dual-screen-owned-stage
> - Remove or comment out log messages
> - 8252373: [macOS] Stage with owner disappears when moved to another screen
lgtm+..
Testing looks good, on same/single screen and with external screen.
-------------
Marked as reviewed by arapte (Reviewer).
PR Review: https://git.openjdk.org/jfx/pull/1932#pullrequestreview-3348461596
More information about the openjfx-dev
mailing list