On Sun, 22 Mar 2026 12:02:42 GMT, Thiago Milczarek Sayao <[email protected]> 
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.
>> 
>> 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.
>
> Thiago Milczarek Sayao has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Add flag to disable portal file chooser

In GTK3, `gtk_file_chooser_native_new` (introduced in #2025) only accepts a 
`GtkWindow` as its parent and initially shows the GTK file chooser instead of 
the GNOME portal-based dialog.

This PR switches to using `GdkWindow` instead of `GtkWindow`, since there is no 
rendering integration between them. Creating a `GtkWindow` initializes the full 
GTK infrastructure (such as CSS parsing and rendering) and paints onto the 
native window, which we then repaint over.

To address this (since we no longer have a `GtkWindow` to pass to 
`gtk_file_chooser_native_new`), a new class was introduced to handle file 
chooser requests by calling the portal directly through D-Bus, with a fallback 
to the GTK file chooser.

It can be disabled with `glass.gtk.usePortalFileChooser=false`

This approach provides a better file chooser experience on GNOME and KDE.

Gnome (via portal):
<img width="1880" height="1200" alt="image" 
src="https://github.com/user-attachments/assets/19992299-1926-47ba-a8e9-b95e7b3232e2";
 />

Gnome (without portal):
<img width="2612" height="1406" alt="image" 
src="https://github.com/user-attachments/assets/6bf161d8-d861-4499-8b79-3047191c0929";
 />

Kde (via portal) - Ubuntu 20.04
<img width="2737" height="1407" alt="image" 
src="https://github.com/user-attachments/assets/f76fe1ca-a30c-4110-bdd1-3f1f7a43b7c9";
 />

Kde (portal disabled)
<img width="1944" height="1288" alt="image" 
src="https://github.com/user-attachments/assets/e98914c6-df51-4be4-a1db-4a4dbfbac14f";
 />

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

PR Comment: https://git.openjdk.org/jfx/pull/1789#issuecomment-4106149527

Reply via email to