After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791569 - GTK window icons are not honoured by wayland backend
GTK window icons are not honoured by wayland backend
Status: RESOLVED DUPLICATE of bug 767966
Product: gtk+
Classification: Platform
Component: Documentation
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-12-13 11:40 UTC by Daniel P. Berrange
Modified: 2017-12-14 15:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Daniel P. Berrange 2017-12-13 11:40:57 UTC
I have an app that is calling

  gtk_window_set_default_icon_from_file(...some icon file...)

to set the default window icon. This has historically worked fine with GTK2 and GTK3 when using the X11 backend, even when in a Wayland session (and thus using Xwayland compat).

When using GTK3 with the Wayland backend though, these icons are no longer honoured. The windows just get given a generic icon.

The gdk_wayland_window_set_icon_list() implementation is just a no-op, so completely ignores any attempt to set window icons, with any of the gtk_window_set_default_icon* and gtk_window_set_icon* methods AFAICT.

Now, I accept the API docs say that some window managers will not honour the icons, but this doesn't appear to be the case here.  

The GNOME shell wayland session *is* honouring icons someteimes, because when I run with GDK_BACKEND=x11 the icons somehow get passed from the app to Xwayland, and ultimately to the GNOME shell session. If that's possible, I'd expect it to be possible to to get the GDK wayland native backend to achieve the same.

If, however, this isn't possible at least the API docs for gtk_window_set_default_icon* / gtk_window_set_icon* ought to be updated to tell application developers what alternative APIs to use to get icons to be displayed.
Comment 1 Emmanuele Bassi (:ebassi) 2017-12-13 12:43:48 UTC
There is no Wayland protocol to pass around icons attached to window surfaces, that's why GDK does not implement it. Different windowing systems are not mandated to replicate the X11 backend — even though, sadly, we do have X11-only API that is part of the generic one, for historical reasons.

Different X11 window managers and Wayland compositors have different strategies for associating an icon to an application's window; GNOME, for instance, prefers the icon coming from the desktop file, and will use the window icon X11 property only on X11, and only if it cannot associate a desktop file with the application's window. There's no API involved for the toolkit to direct you to, in this case.

At most, the gtk_window_set_default_icon_* family of functions can tell you that it's up to the window manager to decide whether or not to display the icon you set there, which is what gtk_window_set_icon() already does:

https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-set-icon

> Some window managers or desktop environments may also place it in
> the window frame, or display it in other contexts. On others, the
> icon is not used at all, so your mileage may vary.

I'd be amenable to review a patch for the documentation of set_default_icon() to point out the same.
Comment 2 Daniel P. Berrange 2017-12-13 12:54:34 UTC
How should applications get an icon displayed if they don't have a desktop file ?

Also, how does it know what desktop file corresponds to an arbitrary running app ? It use of GtkApplication framework mandatory to get that working ?

My immediate case is QEMU, which has a GTK frontend, but doesn't have a desktop file as it isn't an app you can just point & click to launch from the GUI. The only practical way to launch QEMU is from the shell CLI passing all the needed args to configure the virtual machine. We still want QEMU to have its window icon displayed though once running.
Comment 3 Emmanuele Bassi (:ebassi) 2017-12-13 13:15:58 UTC
(In reply to Daniel P. Berrange from comment #2)
> How should applications get an icon displayed if they don't have a desktop
> file ?

Applications on Linux are supposed to ship a desktop file. This is not a new requirement, it's been the case for that for the past 15 years.

> Also, how does it know what desktop file corresponds to an arbitrary running
> app ? It use of GtkApplication framework mandatory to get that working ?

Of course, we strongly encourage you to use the GtkApplication class, because it's the API we provide for writing applications.

The way it's implemented, if you don't use the GtkApplication class, is to do the work yourself — mainly by setting the WM_CLASS property to the same name as the desktop file name, except the '.desktop' extension.

On Wayland, you should be able to use the xdg-shell v6 interface to set the id on the surface.

> My immediate case is QEMU, which has a GTK frontend, but doesn't have a
> desktop file as it isn't an app you can just point & click to launch from
> the GUI. The only practical way to launch QEMU is from the shell CLI passing
> all the needed args to configure the virtual machine. We still want QEMU to
> have its window icon displayed though once running.

You should add a desktop file with NoDisplay=true to have it not appear in the launchers, and yet provide application metadata.

Since you're already using GTK, you should still be able to use GtkApplication and GtkApplicationWindow, instead of a base GtkWindow, and thus set the application id necessary for GNOME to match it.

Just remember that your application id must match the name of the desktop file, minus the `.desktop` extension.
Comment 4 Daniel Boles 2017-12-14 15:47:36 UTC

*** This bug has been marked as a duplicate of bug 767966 ***