RFR: 8364547: Window size may be incorrect when constrained to min or max
Martin Fox
mfox at openjdk.org
Fri Aug 15 20:09:19 UTC 2025
On Fri, 15 Aug 2025 17:21:03 GMT, Thiago Milczarek Sayao <tsayao at openjdk.org> wrote:
>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java line 161:
>>
>>> 159: if (minMaxEnforced) {
>>> 160: notifyResize(WindowEvent.RESIZE, pw, ph);
>>> 161: }
>>
>> Could this lead to two resize commands in some cases? I can see why this new logic is needed for the case where the window was already at max (or min) width and height, but if it wasn't already constrained, wouldn't the resize event have already happened?
>
> The issue is that the Java side updates the property first, and only afterward requests the Glass native side to apply the change. I've found this to cause many problems and I fixed the same way in #1789 - when the change can't be applied, it notifies back.
> Could this lead to two resize commands in some cases?
Yes, I was trying not to be too clever with my checks. I figured if the second notification wasn't necessary it would be benign. At the very least it won't trigger invalidation of the window's width and height properties.
I will tighten this up since I have to tweak the code a bit anyway. I just verified that on Windows you can alter the size of a maximized window and the OS will keep it in the MAXIMIZED state (as it resizes glass calls notifyResize with WindowEvent.MAXIMIZED). This PR can kick the window out of the MAXIMIZED or MINIMIZED state incorrectly. Unfortunately it puts the window in the wrong internal state without updating the maximized or iconified properties so it's not easy to write a test to detect this.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1870#discussion_r2279798272
More information about the openjfx-dev
mailing list