Archived
0
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/suckless/tabbed/patch/icon.c

42 lines
1.3 KiB
C
Raw Normal View History

2021-12-28 05:04:49 +00:00
static unsigned long icon[ICON_WIDTH * ICON_HEIGHT + 2];
void
xseticon(void)
{
Atom ret_type;
XWMHints *wmh, *cwmh;
int ret_format;
unsigned long ret_nitems, ret_nleft;
long offset = 0L;
unsigned char *data;
wmh = XGetWMHints(dpy, win);
wmh->flags &= ~(IconPixmapHint | IconMaskHint);
wmh->icon_pixmap = wmh->icon_mask = None;
if (XGetWindowProperty(dpy, clients[sel]->win, wmatom[WMIcon], offset, LONG_MAX, False,
XA_CARDINAL, &ret_type, &ret_format, &ret_nitems,
&ret_nleft, &data) == Success &&
ret_type == XA_CARDINAL && ret_format == 32)
{
XChangeProperty(dpy, win, wmatom[WMIcon], XA_CARDINAL, 32,
PropModeReplace, data, ret_nitems);
} else if ((cwmh = XGetWMHints(dpy, clients[sel]->win)) && cwmh->flags & IconPixmapHint) {
XDeleteProperty(dpy, win, wmatom[WMIcon]);
wmh->flags |= IconPixmapHint;
wmh->icon_pixmap = cwmh->icon_pixmap;
if (cwmh->flags & IconMaskHint) {
wmh->flags |= IconMaskHint;
wmh->icon_mask = cwmh->icon_mask;
}
XFree(cwmh);
} else {
XChangeProperty(dpy, win, wmatom[WMIcon], XA_CARDINAL, 32,
PropModeReplace, (unsigned char *) icon, ICON_WIDTH * ICON_HEIGHT + 2);
}
XSetWMHints(dpy, win, wmh);
XFree(wmh);
XFree(data);
}