Links are not opened when xdg-desktop-portal OpenURI is not available
Steps to reproduce
- Have no xdg-desktop-portal installed, or have an installation that does not provide org.freedesktop.portal.OpenURI
- Click on a link in a gtk application.
As a minimal example, I took the example-0.c from the Gtk4 Getting Started and included a LinkButton:
linkbutton = gtk_link_button_new("https://example.org/");
gtk_window_set_child (GTK_WINDOW (window), linkbutton);
The issue also appears when clicking links e.g. in dino (bug report) or gnome-font-viewer (on the info screen).
Current behavior
The link is not opened.
Also there is no error message, neither on the GUI, nor in the program output (terminal).
Only if you run dbus-monitor
, you see a call to path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.OpenURI
, which gets an error about either org.freedesktop.portal.Desktop
or org.freedesktop.portal.OpenURI
not existing.
Expected outcome
The link should be opened (in the user's default web browser).
Version information
- Arch Linux
- gtk 4.10.1 (package version gtk4 1:4.10.1-2)
- xdg-desktop-portal 1.16.0-1
- xdg-desktop-portal-gtk 1.14.1-1
Additional information
I compiled my example code with gcc -O -ggdb $( pkg-config --cflags gtk4 ) -o example-0 example-0.c $( pkg-config --libs gtk4 )
and got the following backtrace (after a bit of breakpoints and stepping):
#0 gtk_xdp_open_uri_proxy_get_type () at gtk/xdp-dbus.c:1064
#1 gtk_xdp_open_uri_proxy_new_sync
(flags=G_DBUS_PROXY_FLAGS_NONE, name=0x7ffff7aaf0c8 "org.freedesktop.portal.Desktop", object_path=0x7ffff7aaf0a8 "/org/freedesktop/portal/desktop", cancellable=0x0, error=0x7fffffffc110, connection=0x5555555ad860) at gtk/xdp-dbus.c:1355
#2 init_openuri_portal () at ../gtk/gtk/gtkopenuriportal.c:60
#3 0x00007ffff7852409 in gtk_openuri_portal_is_available () at ../gtk/gtk/gtkopenuriportal.c:88
#4 gtk_uri_launcher_launch (self=0x555557b18f70, parent=0x55555578f4c0, cancellable=0x0, callback=<optimized out>, user_data=0x0)
at ../gtk/gtk/gtkurilauncher.c:303
#5 0x00007ffff776e234 in gtk_link_button_activate_link (link_button=link_button@entry=0x55555578bb80)
at ../gtk/gtk/gtklinkbutton.c:487
...
Line 1355 of auto-generated xdp-dbus.c is the following here (from Arch Linux's instance of debuginfod, since I did not compile gtk myself):
ret = g_initable_new (GTK_XDP_TYPE_OPEN_URI_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.freedesktop.portal.OpenURI", NULL);
init_openuri_portal()
and thus gtk_openuri_portal_is_available()
returns 1, thus reporting OpenURI being available.
The backtrace (apart from the address values) and the return value is the same in all three of the following cases, although only in the last one (with xdg-desktop-portal-gtk) the link is opened:
- no xdg-desktop-portal installed
- xdg-desktop-portal, xdg-desktop-portal-wlr installed. Note that the backtraces were generated on X11. However, a Wayland system with these two packets did not open the link either. xdg-desktop-portal-wlr does not include org.freedesktop.portal.OpenURI. (It's for screen captures / screenshots.)
- xdg-desktop-portal, xdg-desktop-portal-gtk installed. The link opens.