Skip to content

x11: Sort _NET_WM_ICON by ascending icon size

This is to help having at least some icons making it, no matter their input order, as the size limit of 262144 blocks is not enough for a single 512*512 icon, thus possibly leading to no icon at all if such an icon appears first.

Sorting the icons allows to have as many working as possible as it would put the offending icons near the end, and the sum of all common icon sizes below 512 is under the limit so they are likely to all fit.

As a nice side effect of actually sorting the icons, if a client is fetching less data than what we upload, having smaller icons first will allow it to get the most it can, instead of possibly nothing if the first icon we store is bigger than the client's request. This is not unusual for some clients to limit their request to the minimal X11 size of 65536 blocks, which is not enough to fit a single 256*256 icon. An example of such a client app is xprop.


This applies to icons automatically added from the theme as apparently the theme's icon order is mostly random, so most applications suffer from it -- although not so many clients do use the property (but e.g. Compiz does), and often enough we are lucky and quite a few icons make it anyway, but it's fragile.

Edited by Colomban Wendling

Merge request reports