Lea-fish / Leafish

A minecraft-like multi version client implemented in Rust.
Apache License 2.0
812 stars 46 forks source link

Support Window icon #301

Open terrarier2111 opened 7 months ago

terrarier2111 commented 7 months ago
skillman623 commented 7 months ago

Protocol specification for Wayland. https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html

I am running Wayland and can test this.

skillman623 commented 7 months ago

Icons can be stored at one of three paths according to the spec. We should check for the existence of the folders and, should the path exist, copy the Leafish icon there. The folder paths should be checked in the following order:

For Ubuntu, it looks like we can place the icon in /home/$USER/.local/share/icons in the respective folder (based on the resolution). If this path is consistent on all major distros, we wouldn't need root to load the icon.

terrarier2111 commented 7 months ago

Icons can be stored at one of three paths according to the spec. We should check for the existence of the folders and, should the path exist, copy the Leafish icon there. The folder paths should be checked in the following order:

* [ ]  $HOME/.icons

* [ ]   $XDG_DATA_DIRS/icons

* [ ]  /usr/share/pixmaps

For Ubuntu, it looks like we can place the icon in /home/$USER/.local/share/icons in the respective folder (based on the resolution). If this path is consistent on all major distros, we wouldn't need root to load the icon.

Does it load the icon based on the window name?

skillman623 commented 7 months ago

It's based on the application name if it's placed at one of those directories. See the table here. The two options seem to be either to place any icon you need in the legacy hicolor theme folder, or to create a .desktop file that the window manager can pull information from, located at either /usr/share/applications , /usr/local/share/applications, or ~/. local/share/applications.

For dynamically changing the icon, we will have to wait for winit to add this feature for wayland as it's currently unsupported. It looks like an API hit implementation is in the works in staging for freedesktop 2 weeks ago but as it's not final it could be a while until its supported.

skillman623 commented 2 months ago

The required upstream patch was merged here Next is seeing if winit has implemented the change or if we should roll our own fix.

skillman623 commented 2 months ago

Winit still doesn't support setting the icon on Wayland via set_window_icon.

It seems like creating a file and copying it to the correct path is the method that most apps are using, although it is possible to handle this with Wayland calls directly, although only in Wayland staging for now