On Fri, 6 Mar 2026 19:33:38 GMT, Jose Pereda <[email protected]> wrote:

> This PR adds a fix to prevent a crash on macOS after exiting full screen mode 
> when a modal dialog is showing (https://bugs.openjdk.org/browse/JDK-8371370).
> 
> At the same time, it prevents non-resizable windows from entering full screen 
> mode (https://bugs.openjdk.org/browse/JDK-8379315), given that the changes 
> for both issues were interrelated.
> 
> While no tests have been added, manual tests have been run, checking that the 
> style mask, the window behavior and the standard window buttons state, 
> remained consistent in different scenarios.

## Pull request overview

Fixes macOS Glass window state handling around fullscreen transitions, 
particularly when a modal dialog disables the main stage, to avoid crashes and 
prevent non-resizable windows from entering fullscreen.

**Changes:**
- Defers fullscreen collection behavior enabling to the point when a window 
becomes resizable, preventing non-resizable ownerless windows from entering 
fullscreen.
- Tracks/restores miniaturizable/resizable style-mask bits more carefully 
during enable/disable transitions.
- Reapplies style-mask, collection behavior, and standard button enabled states 
on fullscreen exit.

### Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 
comments.

| File | Description |
| ---- | ----------- |
| modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m | Adjusts 
enabled/disabled handling to preserve/restore miniaturizable/resizable style 
bits and standard button enabled states. |
| modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Overrides.m | 
Restores style mask, collection behavior, and button states when exiting 
fullscreen; adds a failure-to-exit handler. |
| modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m | 
Updates resizable toggling to manage fullscreen eligibility via collection 
behavior and to defer style changes until fullscreen exit completes. |





---

💡 <a 
href="/openjdk/jfx/new/master?filename=.github/instructions/*.instructions.md" 
class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot 
custom instructions</a> for smarter, more guided reviews. <a 
href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot";
 class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how 
to get started</a>.

modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m line 259:

> 257:             behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
> 258:             [self->nsWindow setCollectionBehavior: behavior];
> 259:         }

`_setResizable:` no longer toggles `showsResizeIndicator`, and the window/panel 
is initialized with `setShowsResizeIndicator:NO` in the class init path. This 
means the resize indicator will never be shown even when the window becomes 
resizable. If the resize indicator is still desired for resizable decorated 
windows/panels, consider restoring the `setShowsResizeIndicator:YES/NO` updates 
alongside the styleMask changes.

modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Overrides.m line 
337:

> 335:     // Fullscreen exit failed - window remains in fullscreen mode, 
> restore buttons
> 336:     BOOL isWindowEnabled = self->isEnabled;
> 337:     [[self->nsWindow standardWindowButton:NSWindowZoomButton] 
> setEnabled:isWindowEnabled];

`windowDidFailToExitFullScreen:` enables `NSWindowZoomButton` twice (lines 337 
and 339) and never restores the close button state. This looks like a 
copy/paste mistake and can leave the close button disabled after a failed 
fullscreen exit. Update this handler to set each standard button 
(close/mini/zoom) exactly once, consistent with the logic in 
`windowDidExitFullScreen:`.
Suggestion:

    [[self->nsWindow standardWindowButton:NSWindowCloseButton] 
setEnabled:isWindowEnabled];

modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m line 877:

> 875:             if (closeButton != nil) {
> 876:                 [closeButton setEnabled:NO];
> 877:             }

When disabling the window, the code disables only the close and zoom buttons. 
In cases where the style mask isn't modified (e.g., while in fullscreen or for 
non-regular windows), the miniaturize button can remain enabled even though the 
window is disabled. Consider explicitly updating `NSWindowMiniaturizeButton` 
enabled state here (and restoring it in the enabled branches) to keep standard 
buttons consistent with `window->isEnabled`.

-------------

PR Review: https://git.openjdk.org/jfx/pull/2098#pullrequestreview-3905648910
PR Review Comment: https://git.openjdk.org/jfx/pull/2098#discussion_r2897521836
PR Review Comment: https://git.openjdk.org/jfx/pull/2098#discussion_r2897521784
PR Review Comment: https://git.openjdk.org/jfx/pull/2098#discussion_r2897521817

Reply via email to