Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 58 commits into
base: master
Choose a base branch
from

Conversation

tsayao
Copy link
Collaborator

@tsayao tsayao commented Apr 22, 2025

This is a continuation to JDK-8236651 and it aims to stabilize the linux glass gtk backend.

This is a refactor of the Glass GTK implementation, primarily focused on window size, positioning, and state management to resolve numerous issues.

The main change is that GtkWindow (which is a GtkWidget) has been replaced with a direct use of GdkWindow for windows. This makes sense because GTK includes its own rendering pipeline, whereas JavaFX renders directly to the underlying system window (such as the X11 window) via Prism ES2 using GL and GLX. Most GTK window-related calls have equivalent GDK calls. Since GDK serves as an abstraction over the system window and input events, it aligns better with the purposes of Glass. Additionally, using GTK required various workarounds to integrate with Glass, which are no longer necessary when using GDK directly.

It uses a simple C++ Observable to notify the Java side about changes. This approach is more straightforward, as notifications occur at many points and the previous implementation was becoming cluttered.

Previously, there were three separate context classes, two of which were used for Java Web Start and Applets. These have now been unified, as they are no longer required.

Many tests were added to ensure everything is working correctly. I noticed that some tests produced different results depending on the StageStyle, so they now use @ParameterizedTest to vary the StageStyle.

A manual test is also provided. I did not use MonkeyTester for this, as it was quicker to simply run and test manually:java @build/run.args tests/manual/stage/TestStage.java

While this is focused on XWayland, everything works on pure Xorg as well.

List of fixed issues:

  1. [Linux] Stage.setMaximized() before show() does not persist
  2. [Linux] Intermittent test failure in IconifyTest.canIconifyDecoratedStage
  3. [Linux] Initial window position is not centered on Ubuntu 24.04 / Xorg
  4. [Linux] Some of the SizeToSceneTest fail in Ubuntu 24.04
  5. [Linux] View size glitch when resizing past max window size
  6. RestoreSceneSizeTest fails in Ubuntu 24.04
  7. DualWindowTest fails intermittently on Linux

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)

Issue

  • JDK-8354943: [Linux] Simplify and update glass gtk backend: window sizing, positioning, and state management issues (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1789/head:pull/1789
$ git checkout pull/1789

Update a local copy of the PR:
$ git checkout pull/1789
$ git pull https://git.openjdk.org/jfx.git pull/1789/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1789

View PR using the GUI difftool:
$ git pr show -t 1789

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1789.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 22, 2025

👋 Welcome back tsayao! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 22, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Ready for review label Apr 22, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 22, 2025

Webrevs

@mlbridge
Copy link

mlbridge bot commented Apr 22, 2025

Webrevs

@kevinrushforth
Copy link
Member

/reviewers 2 reviewers

Reviewers: @lukostyra @kevinrushforth

@beldenfox If you have time, your review would be appreciated as well.

@openjdk
Copy link

openjdk bot commented Apr 22, 2025

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

@beldenfox
Copy link
Contributor

Thanks for adding these tests. I'm currently tracking down two bugs on macOS that should have been caught a long time ago. Looks like these tests cover those cases (finally).

I will at least review and run the tests on macOS and report back. I might have time to run the tests on Windows 11. I don't have a Windows 10 box to test one.

@lukostyra
Copy link
Contributor

I'll give this a thorough read and report back.

In the meantime, I recently was tackling JDK-8321624 and i have to wonder if it got fixed in the process of your changes? It is intermittent, I managed to get it to fail locally on my VM and it seemed like a race between window manager showing the window and us wanting to move it. Judging by the list of bugs you fixed this one could maybe also make he list.

Copy link
Contributor

@beldenfox beldenfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a rough pass on macOS and Windows. There's some failures in the StageLocation and StageAttributes tests that I haven't had time to look into.

You might want to consider adding a few delay constants and using them instead of the 500's you've scattered through these tests. There's the delay needed for big state changes (like entering and exiting fullscreen) and that needs to be 500 or more. Then there's the delay for waiting for a layout pulse and I'm assuming that could be significantly shorter.

There seem to be places where you compare an attribute like Stage.getWidth() against a constant using strict equality and other places where you provide a tolerance delta. I suspect you want a delta in more locations but someone else will have to chime in on that. I think this mostly affects Windows machines using fractional scaling.

There was a discussion a while back about naming conventions and I think the consensus was that new tests should not have "test" in the name (so testMinSize should be minSize or minStageSize). But I might be wrong on that and in the end it's a matter of style.

tsayao added 2 commits April 26, 2025 09:57
…ng when unresizable)

- Improve code on gtk_window.cpp
- Add delta for sizing (as Martin suggested)
- Add constants for wait times (as Martin suggested)
@tsayao
Copy link
Collaborator Author

tsayao commented Apr 26, 2025

I'll give this a thorough read and report back.

In the meantime, I recently was tackling JDK-8321624 and i have to wonder if it got fixed in the process of your changes? It is intermittent, I managed to get it to fail locally on my VM and it seemed like a race between window manager showing the window and us wanting to move it. Judging by the list of bugs you fixed this one could maybe also make he list.

The DualWindow test consistently fails without these changes on my Ubuntu 24.04 test VM, and consistently passes with the changes applied. However, on a physical machine running Ubuntu 24.04, the test passes even without the changes.

Since I changed the positioning code and it does passes the tests, it might be fixed.

@tsayao
Copy link
Collaborator Author

tsayao commented Apr 27, 2025

Please wait a little before reviewing the glass GTK part, as I may have found a way to improve it further

@lukostyra
Copy link
Contributor

The DualWindow test consistently fails without these changes on my Ubuntu 24.04 test VM, and consistently passes with the changes applied. However, on a physical machine running Ubuntu 24.04, the test passes even without the changes.

Since I changed the positioning code and it does passes the tests, it might be fixed.

Good news! Problems were usually on slower environments ex. VMs. I would add this test to the list as well, and I'll verify for its stability during my review.

- Notify maximize/fullscreen before show on native side
@openjdk
Copy link

openjdk bot commented May 4, 2025

@tsayao this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8354943
git fetch https://git.openjdk.org/jfx.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

tsayao added 18 commits June 9, 2025 20:49
- Remove work-around to allow unresizable Stages to be resized
- Other minor adjustments
# Conflicts:
#	modules/javafx.graphics/src/main/native-glass/gtk/glass_general.cpp
#	modules/javafx.graphics/src/main/native-glass/gtk/glass_general.h
#	modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp
#	modules/javafx.graphics/src/main/native-glass/gtk/glass_window.h
- Fix mistakes when merging
@tsayao
Copy link
Collaborator Author

tsayao commented Jun 19, 2025

I think I'm mostly done and this can be reviewed now.

@tsayao
Copy link
Collaborator Author

tsayao commented Jun 29, 2025

I have updated the main explanation of the changes. I also ran extensive tests on XWayland, Xorg, KDE, GNOME, and across different OS versions and distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfr Ready for review
Development

Successfully merging this pull request may close these issues.

6 participants