-
Notifications
You must be signed in to change notification settings - Fork 508
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
base: master
Are you sure you want to change the base?
Conversation
…ning, and state management issues
👋 Welcome back tsayao! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
Webrevs
|
/reviewers 2 reviewers Reviewers: @lukostyra @kevinrushforth @beldenfox If you have time, your review would be appreciated as well. |
@kevinrushforth |
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. |
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. |
There was a problem hiding this 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.
@EnumSource(value = StageStyle.class, | ||
mode = EnumSource.Mode.INCLUDE, | ||
names = {"DECORATED", "UNDECORATED", "TRANSPARENT"}) | ||
void testUnFullScreenChangedSize(StageStyle stageStyle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the spec changes to the size or position of a window while it's in fullscreen mode will be ignored and applied after the window leaves fullscreen mode. That's not how it currently works on macOS or Windows 11. Actually implementing that part of the spec would be complicated and probably not worth the development cycles. I would rather remove that wording and drop the testUnFullScreenChangeSize and Position tests.
I imagine this was easy to implement back when fullscreen was implemented as a separate window. It's not clear this is useful behavior, the spec might just have captured an implementation detail and elevated it to a feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was kind of on the fence with this one. Maybe it’s a case where the docs in Stage.java need fixing — they do also say that width and height should reflect the unfullscreened size. But there are several tests that check the fullscreen size against the screen size, so I opted for notifying the fullscreen sizes.
@EnumSource(value = StageStyle.class, | ||
mode = EnumSource.Mode.INCLUDE, | ||
names = {"DECORATED", "UNDECORATED", "TRANSPARENT"}) | ||
void testFullScreenMaxSize(StageStyle stageStyle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're assuming that fullscreen mode should ignore the max size properties. That's not how Windows 11 and macOS work. On macOS the window expands to the max size and is then centered on a black screen. On Windows 11 it ends up in the upper left corner with the desktop showing beneath it. It looks weird but I don't think there's much point to changing the implementation on these two platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m going to remove this test and undo the workaround I added to support it. I initially thought this behavior was consistent with how it works on Windows, but I think I got confused — Windows does allow a fullscreen, unresizable Stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it. But it does bug a little different than windows, it acts like it's fullscreen, but its not.
@EnumSource(value = StageStyle.class, | ||
mode = EnumSource.Mode.INCLUDE, | ||
names = {"DECORATED", "UNDECORATED", "TRANSPARENT"}) | ||
void testMaximizeMaxSize(StageStyle stageStyle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test assumes that maximizing a window will ignore the max size settings. That's not how it works on macOS and it would be a bear to try to implement this. I think we should remove this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually worked around by removing the constraints, maximize and restore back the constraints when unmaximized. Window does allow this. I would prefer to not allow as well and invert the test (or remove it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
@EnumSource(value = StageStyle.class, | ||
mode = EnumSource.Mode.INCLUDE, | ||
names = {"DECORATED", "UNDECORATED", "TRANSPARENT", "UTILITY"}) | ||
void testMinSize(StageStyle stageStyle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes! This test uncovers a long-standing problem and is failing on macOS and Windows. In general glass will only send a resize notification if the window's size actually changes. When you set the width and height here JavaFX records the new values, sends them on to glass, and glass doesn't respond because the window size doesn't change. The property values do not get corrected to reflect the actual window size and the test fails.
(I am not a fan of the JavaFX property-based API for setting window attributes. Basically JavaFX records an attribute change as if it has already happened and THEN sends it on to glass to be acted on. This creates endless complications like this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to work around this. It's a little worse, because if the Stage is fullscreen and we call setWitdth, for example, JavaFX will imediatelly set the width (but the Stage is fullscreen!).
private static final int TO_X = 500; | ||
private static final int TO_Y = 500; | ||
private static final Color COLOR = Color.RED; | ||
private static final double TOLERANCE = 0.00; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want a non-zero tolerance for color matching.
…ng when unresizable) - Improve code on gtk_window.cpp - Add delta for sizing (as Martin suggested) - Add constants for wait times (as Martin suggested)
The Since I changed the positioning code and it does passes the tests, it might be fixed. |
Please wait a little before reviewing the glass GTK part, as I may have found a way to improve it further |
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. |
This is a continuation to 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:
DECORATED
stages often behave differently fromUNDECORATED
orUTILITY
stages;-PCONF=DebugNative
;A simple manual test is also provided but I would prefer to move it's functionality to monkey tester:
java @build/run.args tests/manual/stage/TestStage.java
List of fixed issues:
The Xorg-related bugs were not issues within JavaFX itself, so they were addressed through workarounds - such as delaying the initial state and re-checking the geometry when the window is first mapped.
IMPORTANT: While this is open for review, please allow me some time to further polish and test it before final approval. Feedback is welcome—especially regarding any need to disable the new tests on specific platforms, as some of them might fail.
Progress
Issue
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