godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.99k stars 21.16k forks source link

When running in Wayland, taskbar and window icons do not use Godot icon because Godot does not use a consistent `app_id` throughout its execution #96074

Open Kingwad opened 2 months ago

Kingwad commented 2 months ago

Tested versions

Reproducible in v4.3.stable.official [77dcf97d8], v4.3.rc1.official [e343dbbcc]

System information

Gentoo Linux, KDE Plasma 5.27.11, Wayland graphics platform

Issue description

Wayland maps a window to an application by matching the application's app_id to a matching .desktop file in /usr/share/applications or ~/.local/share/applications/. The .desktop file included in the Godot source is misc/dist/linux/org.godotengine.Godot.desktop, meaning that once that file is properly copied to the appropriate directories Wayland will only be able to match the window to the application when the app_id is exactly org.godotengine.Godot.

The .desktop files appropriately placed in the application directories is also what allows application menus to automatically populate all the applications installed in the system.

In platform/linuxbsd/wayland/display_server_wayland.cpp, function DisplayServerWayland::_get_app_id_from_context, Godot sets a different app_id based on the context it is running in: org.godotengine.Editor, org.godotengine.ProjectManager, org.godotengine.Godot, or the value set in application/config/name.

Consequently the taskbar and window frame show the default Wayland app icon instead of the Godot icon.

The value set in application/config/name would of course be the user's responsibility to have a .desktop file appropriate for their own game, so that is not an issue for this bug, although may require some documentation changes to note the connection between the application/config/name and the user’s own generated and distributed .desktop file.

Steps to reproduce

Enable the Prefer Wayland option in the editor settings.

Copy the file misc/dist/linux/org.godotengine.Godot.desktop to either /usr/share/applications or ~/.local/share/applications/

Run Godot, opens in ProjectManager context with the app_id org.godotengine.ProjectManager.

Open a project, Godot reloads with the app_id org.godotengine.Editor

In both of these contexts, the taskbar and window decoration icons use the default Wayland icon.

Minimal reproduction project (MRP)

N/A

Kingwad commented 2 months ago

The initially apparent workaround of having separate .desktop files for each context would introduce the bug of having Godot show up multiple times in the Application menu.

akien-mga commented 2 months ago

CC @Riteo

Riteo commented 2 months ago

Thank you for the report!

In the past it was reported that it was impossible to write proper window rules without different ids^1, so I think that this is the right solution.

I eventually came to the conclusion that multiple desktop entries are the right choice, which seems quite consistent to me as they're conceptually different applications, even if they come from the same executable.

The initially apparent workaround of having separate .desktop files for each context would introduce the bug of having Godot show up multiple times in the Application menu.

I do agree that it would be quite unpleasant to see. The documentation talks about the NoDisplay^2 tag which seems perfect for the job, as it apparently hides the entry from the menu while still letting it get parsed (e.g. for media type associations). I think we can use this tag to write different entries but I didn't try it yet.

Note that I have very little experience with this stuff. As we say it here, TIWAGOS (take it with a grain of salt) :D

I hope this sheds some light on the current situation regarding app ids and packaging.

Kingwad commented 2 months ago

Tested by adding extra .desktop files to , named org.godotengine.Editor.desktop and org.godotengine.ProjectManager.desktop, identical to the original but with NoDisplay=true appended, and this solution does work: one entry in the application menu, all contexts use the correct icons.