RFR: 8372415: Stage size should match visual window bounds [v2]

Martin Fox mfox at openjdk.org
Sat Dec 13 22:15:06 UTC 2025


On Wed, 3 Dec 2025 00:48:52 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> On Windows, the `Stage.width` and `Stage.height` correspond to the window size as returned by `GetWindowRect`.
>> 
>> Up until Windows 10, the size of a window was identical to its visual borders. However, since Windows 10 has introduced thin visual window borders, the window manager adds an invisible border of a few pixels around the window to make it easier to resize the window. Since `GetWindowRect` returns the window size _including_ these invisible borders, the location and size of a `Stage` isn't exactly what we'd expect.
>> 
>> For example, if we place a `Stage` at `setX(0)` and `setY(0)`, the window appears with a small distance from the screen edge, and the window size extends a few pixels beyond its visual borders (in the following images, the screenshot size corresponds to the window size; note the invisible padding around the edges):
>> <img width="300" alt="window-size-1" src="https://github.com/user-attachments/assets/76ea6861-885f-4bea-aeb7-e8e6464b7199" />
>> 
>> What we actually want is to have the visual borders line up with the edges of the screen, and have the window size correspond to the visual borders:
>> <img width="295" alt="window-size-2" src="https://github.com/user-attachments/assets/ca6bed73-e4e7-4df6-9491-d82792bb0866" />
>> 
>> The implementation is quite simple: instead of `GetWindowRect`, we use `DwmGetWindowAttribute(DWMA_EXTENDED_FRAME_BOUNDS)`. This gives us the bounds of the visual window borders. If this function fails, we fall back to `GetWindowRect` (now, I don't know why `DwmGetWindowAttribute(DWMA_EXTENDED_FRAME_BOUNDS)` would ever fail... maybe an old Windows version in a remote desktop scenario?).
>
> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
> 
>   add comments

The existing changes look fine. GitHub doesn't allow me to comment on unchanged code so I'll just have to write up my comments here.

In GlassView.cpp the `_getX` and `_getY` routines return the location of the scene relative to the upper-left corner of the window. I believe these offsets should be relative to the extended frame bounds instead of GetWindowRect.

In GlassWindow.cpp there's a call to the Java routine `notifyMoving` (which lives in WinWindow.java). At that call site the x and y coordinates are based on GetWindowRect and the anchor is relative to GetWindowRect but the insets are relative to the extended frame bounds. `notifyMoving` is also called from the `setBounds` routine in WinWindow.java. In that case I believe it's being called with the coordinates of the extended frame bounds, an anchor relative to GetWindowRect, and insets relative to the extended frame bounds. I think this all needs further review.

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

Changes requested by mfox (Committer).

PR Review: https://git.openjdk.org/jfx/pull/1982#pullrequestreview-3574587958


More information about the openjfx-dev mailing list