Skip to content

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

Open
tsayao wants to merge 24 commits intoopenjdk:masterfrom
tsayao:8354943_v2
Open

8354943: [Linux] Simplify and update glass gtk backend: window sizing, positioning, and state management issues#2139
tsayao wants to merge 24 commits intoopenjdk:masterfrom
tsayao:8354943_v2

Conversation

@tsayao
Copy link
Copy Markdown
Collaborator

@tsayao tsayao commented Apr 6, 2026

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

It refactors the Glass GTK implementation with a primary focus on window sizing, positioning, and state management, addressing a number of long-standing issues.

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

Additional tests have been introduced to improve coverage. Some tests produced different results depending on the StageStyle, so they have been converted to use @ParameterizedTest to exercise multiple styles.

Although the primary focus is XWayland, the changes have also been verified to work correctly on Xorg.

This replaces #1789. It removes the use of GdkWindow in favor of GtkWindow, reducing risk and simplifying the review process while preserving the same set of bug fixes. Additionally, #2025 requires a GtkWindow to be used when setting the parent of the file chooser dialog.

To show debug messages, build with -PCONF=DebugNative and run with -Dglass.gtk.verbose=CATEGORY

CATEGORY can be one or more of:

  • all
  • size
  • position
  • focus
  • state
  • lifecycle
  • input
  • dialog

Multiple categories can be specified by separating them with commas (e.g. size,focus,input).

A manual test is provided:
java @build/run.args tests/manual/stage/TestStage.java

I have added constants for delay times in systemTests (Util.java) for geometry, state, and focus. These can be configured at runtime, for example: -Dtest.geometry.delay=DELAY. Please let me know if you would prefer these to be removed.

When a window property is set, it is reported immediately. However, once it reaches the native Glass layer, it may be adjusted or rejected, causing the property to be updated again. Introducing a delay helps ensure the final state has been applied before it is verified.

Additional testing on other OS versions and manual validation is in progress.



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)

Issues

  • JDK-8354943: [Linux] Simplify and update glass gtk backend: window sizing, positioning, and state management issues (Enhancement - P4)
  • JDK-8316425: [Linux] Stage.setMaximized() before show() does not persist (Bug - P4)
  • JDK-8316891: [Linux] Intermittent test failure in IconifyTest.canIconifyDecoratedStage (Bug - P4)
  • JDK-8337400: [Linux] Initial window position is not centered on Ubuntu 24.04 / Xorg (Bug - P4)
  • JDK-8353612: [Linux] Some of the SizeToSceneTest fail in Ubuntu 24.04 (Bug - P4)
  • JDK-8355073: [Linux] View size glitch when resizing past max window size (Bug - P4)
  • JDK-8353556: RestoreSceneSizeTest fails in Ubuntu 24.04 (Bug - P4)
  • JDK-8321624: DualWindowTest fails intermittently on Linux (Bug - P4)
  • JDK-8367893: StageFocusTest fails on some Linux systems (Bug - P4)
  • JDK-8366009: Stage does not always enter full screen when shown with fullScreen set to true on Ubuntu 24.04 (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2139

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Apr 6, 2026

👋 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
Copy Markdown

openjdk Bot commented Apr 6, 2026

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

@tsayao tsayao marked this pull request as ready for review April 6, 2026 18:11
@openjdk openjdk Bot added the rfr Ready for review label Apr 6, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Apr 6, 2026

@kevinrushforth
Copy link
Copy Markdown
Member

We'll need to evaluate this approach vs that of #1789 and choose one or the other.

It is accurate to say that the main difference between the two approaches is that PR #1789 replaces GtkWindow with GdkWindow whereas this PR sticks with GtkWindow? What other differences will help guide the reviewers?

Does this PR address the same set of issues that PR #1789 does? That one lists 10 additional bugs as also being resolved by that PR.

/reviewers 2 reviewers

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 6, 2026

@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).

@tsayao
Copy link
Copy Markdown
Collaborator Author

tsayao commented Apr 6, 2026

We'll need to evaluate this approach vs that of #1789 and choose one or the other.

It is accurate to say that the main difference between the two approaches is that PR #1789 replaces GtkWindow with GdkWindow whereas this PR sticks with GtkWindow? What other differences will help guide the reviewers?

With the introduction of #2025, a GtkWindow became required for the FileChooser. As a result, PR #1789 needed a relatively large change to work directly with the portal (with a fallback to the GTK FileChooser), enabling the use of a GdkWindow as the parent.

By reverting to GtkWindow instead of GdkWindow, this additional FileChooser-related change is no longer necessary.

Experience shows that such changes can introduce regressions. Since this PR preserves the use of GtkWindow and changes less, it is likely lower risk compared to #1789. A final conclusion depends on further testing of this PR.

Does this PR address the same set of issues that PR #1789 does? That one lists 10 additional bugs as also being resolved by that PR.

At this time, the answer is likely yes, as all tests are passing on Ubuntu 24.04 with XWayland. I will follow up with additional validation and explicitly list the confirmed fixes.

The decision between #1789 and this PR will ultimately depend on the outcome of these tests.

/reviewers 2 reviewers

@tsayao
Copy link
Copy Markdown
Collaborator Author

tsayao commented Apr 7, 2026

/issue add 8354943,8316425,8316891,8337400,8353612,8355073,8353556,8321624,8367893,8366009

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 7, 2026

@tsayao This issue is referenced in the PR title - it will now be updated.

Adding additional issue to issue list: 8316425: [Linux] Stage.setMaximized() before show() does not persist.

Adding additional issue to issue list: 8316891: [Linux] Intermittent test failure in IconifyTest.canIconifyDecoratedStage.

Adding additional issue to issue list: 8337400: [Linux] Initial window position is not centered on Ubuntu 24.04 / Xorg.

Adding additional issue to issue list: 8353612: [Linux] Some of the SizeToSceneTest fail in Ubuntu 24.04.

Adding additional issue to issue list: 8355073: [Linux] View size glitch when resizing past max window size.

Adding additional issue to issue list: 8353556: RestoreSceneSizeTest fails in Ubuntu 24.04.

Adding additional issue to issue list: 8321624: DualWindowTest fails intermittently on Linux.

Adding additional issue to issue list: 8367893: StageFocusTest fails on some Linux systems.

Adding additional issue to issue list: 8366009: Stage does not always enter full screen when shown with fullScreen set to true on Ubuntu 24.04.

tsayao added 6 commits April 8, 2026 06:52
- Improve tests to be more consistent
- GdkWindow -> GtkWindow related fixes
- Prevent repeated 'a' being typed
- Small fixes
# Conflicts:
#	modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 9, 2026

⚠️ @tsayao This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk openjdk Bot removed the rfr Ready for review label Apr 9, 2026
@palexdev
Copy link
Copy Markdown

palexdev commented Apr 10, 2026

@tsayao should you add JDK-8365201 to the list too?

Edit: oh sorry, I just read that this is an alternative to the other proposal. So the question is, does this fixes the above-mentioned issue too?

@tsayao
Copy link
Copy Markdown
Collaborator Author

tsayao commented Apr 10, 2026

@tsayao should you add JDK-8365201 to the list too?

Edit: oh sorry, I just read that this is an alternative to the other proposal. So the question is, does this fixes the above-mentioned issue too?

I still need to set up a multi-monitor environment to properly test it, but it will probably fix this issue as well.

@tsayao
Copy link
Copy Markdown
Collaborator Author

tsayao commented Apr 10, 2026

/template append

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 10, 2026

@tsayao The pull request template has been appended to the pull request body

tsayao added 2 commits April 10, 2026 09:39
- Details on going back to GtkWindow
- unref cursor
@kevinrushforth kevinrushforth self-requested a review April 14, 2026 15:45
@kevinrushforth
Copy link
Copy Markdown
Member

Reviewers: @lukostyra and some combination of: @mstr2 @beldenfox @kevinrushforth

Copy link
Copy Markdown
Contributor

@lukostyra lukostyra left a comment

Choose a reason for hiding this comment

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

I have reviewed a part of this change but I noticed there's still some commits being added.

Let us know when the change is ready to review. In the meantime, I'm leaving off the comment I found.


#else

#define LOG(...) ((void)0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: while it probably won't matter much right now, a preferred syntax here is:

#define LOG(...) do {} while(0)

It compiles to the same thing (a noop) but it is the most language-conforming statement that can be used basically anywhere without triggering a sudden compiler error. Here there could be a problem when for example we would try to do:

if (cond)
    LOG("success");
else
    LOG("error");

As a side-note, this also should apply to other LOG macros in this file, but we already have JDK-8356327 for this, so you can leave them and it will get adjusted there.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

@tsayao
Copy link
Copy Markdown
Collaborator Author

tsayao commented Apr 24, 2026

I have reviewed a part of this change but I noticed there's still some commits being added.

Let us know when the change is ready to review. In the meantime, I'm leaving off the comment I found.

Since it started using GtkWindow again, the behavior is slightly different in some situations, so I'm rechecking the possible scenarios—that’s why these commits.

I also added comments in some places because I no longer remembered why they were there (they're usually edge cases).

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.

4 participants