与how-to-resize-a-pixmap-with-xlib相关
正如在上述主题中得出的结论,不可能调整像素图的大小。将pixmap复制到窗口后,窗口怎么样?在下面的示例中,一切都很好,直到调整窗口大小。图标在复制到窗口后绘制,但在调整窗口大小后丢失。我在这里遗漏了什么或者没有办法调整pixmap内容的大小吗?
上下文:尝试将客户端图标添加到dwm的tab patch.
unsigned int px_w, px_h, dummy_i;
Window icon_w, dummy_w;
Pixmap getWindowIcon (Window *w) {
XWMHints *wmh;
Pixmap pxmp = NULL;
if(wmh = XGetWMHints(dpy, w)) {
pxmp = wmh->icon_pixmap;
XFree(wmh);
}
return pxmp;
}
Pixmap client_icon = getWindowIcon(current_window); // current_window is already existing Window instance
// find the pixmap dimensions and store in px_w, px_h:
XGetGeometry(dpy, client_icon, &dummy_w, &dummy_i, &dummy_i, &px_w, &px_h, &dummy_i, &dummy_i );
icon_w = XCreateSimpleWindow(dpy, root_window, 0, 0, px_w, px_h, 0, 0, color);
XMapRaised(dpy, icon_w);
// copy pixmap to the newly created win:
XCopyArea(dpy, client_icon, icon_w, cellDC.gc, 0, 0, px_w, px_h, 0, 0);
// resize - after which the pixmap is lost in the window:
XResizeWindow(dpy, icon_w, px_w+1, px_h+1);