RFR: 8354943: [Linux] Simplify and update glass gtk backend: window sizing, positioning, and state management issues [v71]
Thiago Milczarek Sayao
tsayao at openjdk.org
Sun Jan 25 16:12:19 UTC 2026
On Fri, 16 Jan 2026 20:37:35 GMT, Martin Fox <mfox at openjdk.org> wrote:
>> Thiago Milczarek Sayao has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 85 commits:
>>
>> - Merge branch 'master' into 8354943
>>
>> # Conflicts:
>> # tests/system/src/test/java/test/util/Util.java
>> - Merge branch 'master' into 8354943
>> - Remote assumeTrue for JDK-8364547
>> - Merge branch 'master' into 8354943
>> - Merge branch 'master' into 8354943
>>
>> # Conflicts:
>> # modules/javafx.graphics/src/main/native-glass/gtk/glass_window_ime.cpp
>> - Merge branch 'master' into 8354943
>> - Fix copyright header
>> - Revert "8367898: Skip StageFocusTest on Linux"
>>
>> This reverts commit c95cdcdc9cd8b3070e8076ea91234772d6a21331.
>> - Merge branch 'master' into 8354943
>> - Remove unused imports
>> - ... and 75 more: https://git.openjdk.org/jfx/compare/6626e013...7e3c3205
>
> modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp line 822:
>
>> 820:
>> 821: void WindowContext::update_initial_state() {
>> 822: GdkWindowState state = gdk_window_get_state(gdk_window);
>
> This handles the case where set_maximized, set_minimized, or enter_fullscreen are called after the peer is created but before it's mapped.
>
> Oh no!
>
> This is an ugly part of the code. For one, when these state flags are set on a Java Window before it is shown the code just stashes them away. When the Window is shown the code applies them in a fixed order: fullscreen, iconified, maximized. So if iconified and maximized are both set the window should end up maximized.
>
> For two, the documentation and code treat iconified/maximized/restored as a trio of mutually exclusive states which are entirely separate from fullscreen (which overrides them all). This is probably a relic of the days when fullscreen was implemented using an entirely separate window. In practice the platform code doesn't honor this separation and if you mix fullscreen with iconified or maximized you'll get different results on different platforms (and the Java state is likely to get confused).
>
> The end result is a bit of a mess. The good news is this leads to the sort of spec violations and bugs that no one notices.
>
> TL;DR - I think the correct order to apply these flags is iconified, maximized, and then fullscreen. This is different than the order the core code uses but, again, as far as it's concerned fullscreen overrides maximized and iconified. To honor that it should be applied last.
I've changed the order and also added a check to not iconify when the flag is also set to maximize, because the java side would set `iconified = false` when maximized.
Yeah, it seems it needs a refactor that would include changes on the java side, but it's not a priority because probably no one will notice it.
The documentation on `Stage` also needs some care.
> modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp line 1059:
>
>> 1057:
>> 1058: void WindowContext::notify_current_sizes() {
>> 1059: notify_window_resize(is_maximized()
>
> This should also be checking for is_iconified. Again, unlikely to be introducing a new bug so this fix can be pushed to a separate PR.
Fixed
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1789#discussion_r2725666846
PR Review Comment: https://git.openjdk.org/jfx/pull/1789#discussion_r2725667057
More information about the openjfx-dev
mailing list