Open nbenitez opened 3 years ago
Well, diving a bit more in the Java source, gnome_url_show()
is called when libgnome is found, but it also checks whether gtk3 and gtk2 is installed, and calls gtk_show_uri()
in that case. Links to that java source:
https://hg.openjdk.java.net/jdk/jdk15/file/0dabbdfd97e6/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c#l78
https://hg.openjdk.java.net/jdk/jdk15/file/0dabbdfd97e6/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.c#l46
I just sent PR #16 to replace those with a call to xdg-open
which will work in any desktop not just GTK/Gnome and will also work in the minimal Freedesktop runtime which many Java apps are built upon in flathub.
Opening URLs is not the only problem here — file chooser dialogs are as well. It'd be great if that was added too. Or, alternatively, if a new Java package was created that developers could use to easily integrate xdg-desktop-portal into Java apps.
Opening URLs is not the only problem here — file chooser dialogs are as well. It'd be great if that was added too. Or, alternatively, if a new Java package was created that developers could use to easily integrate xdg-desktop-portal into Java apps.
That would be cool, but I see that more as an enhancement, first we need to handle the issue here which is more of a bug, where many java apps are currently buggy in that they cannot open links or local files/directories (those which are allowed by --filesystem flag).
But in your line, I think other buggy behaviours of java apps that may be patched further (after this gets accepted):
~/.var/$APP_ID/cache/tmp
so people can stop adding -Djava.io.tmpdir=bla
in their java launch scripts. This is for java apps that create temp files, using the java api CreateTempFile()
which would fail if not setting the aforementioned hack, as JVM hardcodes /tmp
as default temp dir on unix/linux.@nbenitez What license is your HiDPI support script? I'd like to use it in my own Flathub project — FOSStriangulator
@nbenitez What license is your HiDPI support script? I'd like to use it in my own Flathub project — FOSStriangulator
Public domain, no license.
Wonderful, thank you!
Opening URLs is not the only problem here — file chooser dialogs are as well. It'd be great if that was added too. Or, alternatively, if a new Java package was created that developers could use to easily integrate xdg-desktop-portal into Java apps.
FWIW the Java UI framework SWT has full portal integration because it is built on GTK3 and uses all native chooser dialogs. This is how Eclipse (a large Java application) got full desktop portal integration -- it just inherits it from GTK3.
I've been packaging Java GUI applications in flathub recently, they usually are multiplaform apps (Windows, Mac and Linux) which use Java Swing interface. And most of them fail to open url links from their dialogs or menu items (eg. to visit their project page or issue tracker, or to show their online documentation), another one also failed to launch file browser (eg. Nautilus) to show a local directory.
These apps all use a Java api for Desktop integration, which is the following Desktop class: https://docs.oracle.com/javase/9/docs/api/java/awt/Desktop.html
Unfortunately, the linux desktop integration in java is very old and outdated, it uses the
gnome_url_show()
call which is provided by deprecated librarylibgnome
which is not even present in modern linux distros. See below howgnome_url_show()
is used in the Java source code: https://hg.openjdk.java.net/jdk/jdk11/file/1ddf9a99e4ad/src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java#l119So, in order for Java Swing applications to work well in their Desktop integration I propose to add a small patch to openjdk extension to replace the
gnome_url_show()
call for one ofxdg-open
so it works perfectly fine under flatpak when the app manifest also includes the flatpak-xdg-utils module.Related issue: https://github.com/flatpak/xdg-desktop-portal/issues/519