Replacing a window icon in X11?
Glynn Clements
glynn at gclements.plus.com
Wed Apr 1 22:07:35 PDT 2009
Wirawan Purwanto wrote:
> Today most window managers has an area on the top left corner of the
> window decoration which shows a small bitmap, which in Windows world
> called "icon". I wonder if there is any way for an external program, if it
> knows the window ID of a given X11 window, to change that image to
> something else. Older X programs such as xterm seems to not have an option
> to set this icon pixmap (or did I miss it?). If I have a lot of such
> programs open, then the "task bar" of desktop managers (xfce/gnome/kde)
> only shows a bland box or "X" icon, which is not meaningful. I wonder if I
> can replace that with a more suggestive pixmap, thus speeding up my search
> for a particular window.
>
> I am quite uneducated about X11 programming, so if you can give me the
> subroutine name, header file, and pointer to more information, I'd
> appreciate it. If it can be accomplished using gtk, I'm fine, too.
The property in question is WM_HINTS, which is set using the
XSetWMHints() function. The property contains multiple fields, so in
order to preserve any existing hints, you would need to read the
existing value with XGetWMHints(), modify it, then write the updated
value.
But as Daniel suggests, most window managers provide a mechanism to
override a window's icon (or lack of one). This would normally be
preferable to modifying the WM_HINTS property. Apart from anything
else, it's possible that your changes will be discarded whenever the
application (or WM) updates the WM_HINTS property.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the xorg
mailing list