From 96bf8d800c16e417e77f073f49a9a2c639742fd5 Mon Sep 17 00:00:00 2001 From: Martin Fox Date: Wed, 30 Apr 2025 11:34:51 -0700 Subject: [PATCH 1/4] Notify WindowStage if setBounds didn't change the size as expected --- .../src/main/native-glass/mac/GlassWindow+Java.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m b/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m index e6ac4d8b70a..8e923747995 100644 --- a/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m +++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m @@ -340,6 +340,12 @@ - (void)_setBounds:(jint)x y:(jint)y xSet:(jboolean)xSet ySet:(jboolean)ySet w:( // as it is possible that the windowDidMove event is not triggered. [self _sendJavaWindowMoveEventForFrame:flipFrame]; } + if (newW != flipFrame.size.width || newH != flipFrame.size.height) { + // The frame may not have changed due min/max limitations. In that + // case we need to send back the actual size since the + // windowDidResize notification was not triggered. + [self _sendJavaWindowResizeEvent:com_sun_glass_events_WindowEvent_RESIZE forFrame:flipFrame]; + } } - (void)_restorePreZoomedRect From 5de1c38cc4176eea9c28f831fbf363a93a169eb0 Mon Sep 17 00:00:00 2001 From: Martin Fox Date: Wed, 30 Apr 2025 13:26:30 -0700 Subject: [PATCH 2/4] Comment cleanup --- .../src/main/native-glass/mac/GlassWindow+Java.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m b/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m index 8e923747995..f1ab0b47c01 100644 --- a/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m +++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m @@ -341,9 +341,9 @@ - (void)_setBounds:(jint)x y:(jint)y xSet:(jboolean)xSet ySet:(jboolean)ySet w:( [self _sendJavaWindowMoveEventForFrame:flipFrame]; } if (newW != flipFrame.size.width || newH != flipFrame.size.height) { - // The frame may not have changed due min/max limitations. In that - // case we need to send back the actual size since the - // windowDidResize notification was not triggered. + // The frame may not have changed due min/max limits. In that case we + // need to send back the actual size since the windowDidResize + // notification was not triggered. [self _sendJavaWindowResizeEvent:com_sun_glass_events_WindowEvent_RESIZE forFrame:flipFrame]; } } From 1c4527820709dfefd80284b93187e31760d9825a Mon Sep 17 00:00:00 2001 From: Martin Fox Date: Tue, 12 Aug 2025 12:33:25 -0700 Subject: [PATCH 3/4] If min/max window size enforced send notification to correct Window properties --- .../src/main/java/com/sun/glass/ui/win/WinWindow.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java index c6a21bb5c33..bf386575515 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java +++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java @@ -24,6 +24,7 @@ */ package com.sun.glass.ui.win; +import com.sun.glass.events.WindowEvent; import com.sun.glass.ui.Cursor; import com.sun.glass.ui.HeaderButtonMetrics; import com.sun.glass.ui.HeaderButtonOverlay; @@ -122,8 +123,11 @@ public void setBounds(float x, float y, boolean xSet, boolean ySet, fxReqHeight = fx_ch; int maxW = getMaximumWidth(), maxH = getMaximumHeight(); + int oldPw = pw; + int oldPh = ph; pw = Math.max(Math.min(pw, maxW > 0 ? maxW : Integer.MAX_VALUE), getMinimumWidth()); ph = Math.max(Math.min(ph, maxH > 0 ? maxH : Integer.MAX_VALUE), getMinimumHeight()); + boolean minMaxEnforced = (oldPw != pw || oldPh != ph); long anchor = _getAnchor(getRawHandle()); int resizeMode = (anchor == ANCHOR_NO_CAPTURE) @@ -151,6 +155,10 @@ public void setBounds(float x, float y, boolean xSet, boolean ySet, pfReqWidth = (int) Math.ceil(fxReqWidth * platformScaleX); pfReqHeight = (int) Math.ceil(fxReqHeight * platformScaleY); _setBounds(getRawHandle(), px, py, xSet, ySet, pw, ph, 0, 0, xGravity, yGravity); + + if (minMaxEnforced) { + notifyResize(WindowEvent.RESIZE, pw, ph); + } } } From 468fd35449a7d91db1ff3eaa2cecf2f5be4b8e18 Mon Sep 17 00:00:00 2001 From: Martin Fox Date: Mon, 18 Aug 2025 10:19:54 -0700 Subject: [PATCH 4/4] Remove double notifications, keep window min/max/normal state unchanged. --- .../src/main/java/com/sun/glass/ui/win/WinWindow.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java index bf386575515..492f5769048 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java +++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java @@ -154,10 +154,17 @@ public void setBounds(float x, float y, boolean xSet, boolean ySet, if (!ySet) ySet = (py != this.y); pfReqWidth = (int) Math.ceil(fxReqWidth * platformScaleX); pfReqHeight = (int) Math.ceil(fxReqHeight * platformScaleY); + boolean alreadyAtSize = (pw == width && ph == height); _setBounds(getRawHandle(), px, py, xSet, ySet, pw, ph, 0, 0, xGravity, yGravity); - if (minMaxEnforced) { - notifyResize(WindowEvent.RESIZE, pw, ph); + if (minMaxEnforced && alreadyAtSize) { + var eventType = WindowEvent.RESIZE; + if (isMaximized()) { + eventType = WindowEvent.MAXIMIZE; + } else if (isMinimized()) { + eventType = WindowEvent.MINIMIZE; + } + notifyResize(eventType, pw, ph); } } }