RFR: 8354943: [Linux] Simplify and update glass gtk backend: window sizing, positioning, and state management issues [v18]

Martin Fox mfox at openjdk.org
Wed May 7 17:30:21 UTC 2025


On Wed, 7 May 2025 09:30:05 GMT, Thiago Milczarek Sayao <tsayao at openjdk.org> wrote:

>> This is a continuation to [JDK-8236651](https://bugs.openjdk.org/browse/JDK-8236651) and it aims to stabilize the linux glass gtk backend.
>> 
>> 
>> Overall, it has been made more robust within its scope, particularly in terms of sizing, positioning, and state management.
>> 
>> List of changes:
>> 1. Use GDK for creating Windows. Since we paint directly to the underlying XWindow, creating a GtkWidget for the window is unnecessary and results in unused GTK resources. Additionally, avoiding the use of a GtkWidget eliminates the need for workarounds caused by conflicting GTK behavior—such as setting the initial window state, position, or size.
>> 2. It aligns with X11's asynchronous behavior by reporting geometry changes only upon receiving a configure event, since requests to the window manager aren't guaranteed to be honored. However, changes are still reported immediately in special cases, such as before the window is mapped. For example, a request to move the window to (0, 0) might be overridden by the window manager, placing it in the top-right corner below the panels instead.
>> 3. States (fullscreen, maximized and iconify) are now reported back to Java when it actually happens rather than immediately (except when not mapped);
>> 4. When a window is maximized, it will ignore geometry changes and restore to the geometry it had prior to being maximized. After some testing, I believe this is the best behavior for platform compatibility;
>> 5. Unifies the WindowContext class: previously, there were three separate classes—two of which (for applets and Java Web Start) were removed, leaving only one. However, the supporting infrastructure was still there partially. [Unify WindowContext in glass-gtk](https://bugs.openjdk.org/browse/JDK-8305768)
>> 6. Tests were added and re-enabled to ensure everything works correctly. The stage tests now cover various StageStyle configurations, as I found that `DECORATED` stages often behave differently from `UNDECORATED` or `UTILITY` stages;
>> 7. Added Logs for debugging. Enable it with ` -PCONF=DebugNative`;
>> 8. Old work-arounds dating back to Ubuntu 16.04 with Compiz were removed. 
>> 
>> A simple manual test is provided:
>> `java @build/run.args tests/manual/stage/TestStage.java `
>> 
>> 
>> List of fixed issues:
>> 
>> 1. [[Linux] Stage.setMaximized() before show() does not persist](https://bugs.openjdk.org/browse/JDK-8316425)
>> 3. [[Linux] Intermittent test failure in IconifyTest.canIconifyDecoratedStage](https://bugs.openjdk.org/brow...
>
> Thiago Milczarek Sayao has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix non-debug build

tests/system/src/test/java/test/robot/javafx/stage/StageOwnershipTest.java line 343:

> 341:                 () -> {
> 342:                     assertTrue(stage0.isIconified());
> 343:                     assertTrue(stage1.isIconified());

When a window is iconified I would expect the OS to hide any owned windows but not iconify them. For example, the owned windows should not appear as thumbnails in the dock or task bar. If we want these to be reported as iconified we would have to update glass to do that.

My first impulse is to not change anything but currently JavaFX has no way of knowing that the owned windows have changed state and can't be drawn to. We can't report them as hidden because that means something else in JavaFX. Modifying glass to report them as iconified might actually be the right thing to do even though they're not actually iconified.

tests/system/src/test/java/test/robot/javafx/stage/StageOwnershipTest.java line 436:

> 434:                 stage2::show,
> 435:                 stage2::close,
> 436:                 () -> assertTrue(stage1.isFocused()));

This test looks incorrect. If closing an app modal window should focus the parent (and I think it should) then stage0 should be focused.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1789#discussion_r2078098880
PR Review Comment: https://git.openjdk.org/jfx/pull/1789#discussion_r2078102455


More information about the openjfx-dev mailing list