mirror of https://github.com/FreeRDP/FreeRDP
9292b2231f
Icons on X11 windows are configured using the _NET_WM_ICON property described in Extended Window Manager Hints. Here we implement converison from DIB bitmaps used by RAIL to the format expected by _NET_WM_ICON, and actually set the icon for RAIL app windows. Both DIB format and _NET_WM_ICON (or rather, Xlib) are weird. Let's start with RAIL's format. That's the one used in BMP and ICO formats on Windows. It has some strange properties but thankfully FreeRDP's freerdp_image_copy() can handle most of them for us. (With an exception of monochrome and 16-color formats that it does not support. Sorry, but I'm too lazy to fix them. They are not seem to be used by any real application either.) The one thing that it can't do is to apply the alpha transparency bitmask so we have to do it manually. This instantly reminds us that DIB format has HISTORY: it's vertically flipped and each must be padded to 4 bytes. Both these quirks having reasonable (for a certain definition of 'reason') explanations. Such is life. (Also, 8-bit images require a color palette which we must fill in.) So okay, now comes _NET_WM_ICON. It is more sane (or rather, easier to deal with). The bitmap is represented with a tiny [width, height] header followed by an array of pixels in ARGB format. There is no padding, no weird color formats. But here's a catch: you can't simply take the output of freerdp_image_copy() and cast to (unsigned char*) of colors. We have to allocate an array of C's longs and copy the pixels there, because that's what Xlib expects (and this is mentioned in the spec). Simply casting an array of bytes causes crashes on 64-bit systems. So don't try to cheat or "optimize" and read the docs, kids. Note that XFlush() call after XChangeProperty(). It's there because it seems to helps see the icon quicker with Unity on Ubuntu 14.04. I don't know why. (And Unity does not support _NET_WM_ICON officially. But it sorta kinda works sometimes.) Oh, and while we're here, delete some old, unused, and commented out code that was setting window icons in the past. It's not needed anymore. |
||
---|---|---|
.. | ||
Android | ||
DirectFB | ||
Mac | ||
Sample | ||
Wayland | ||
Windows | ||
X11 | ||
common | ||
iOS | ||
.gitignore | ||
CMakeLists.txt | ||
FreeRDP-ClientConfig.cmake.in | ||
freerdp-client.pc.in |