我正在使用Xft在根窗口上绘制一些文本,比如
XftDrawStringUtf8(drw, &xftc, f, 50, 50, (XftChar8 *)buf, x);
之后,即使我的程序被杀死,我仍希望保留该文本,类似于feh
或xsetroot
行为。我查看了他们的来源,他们似乎都
Pixmap
结构中绘制的内容Atom
嵌入到XChangeProperty
XSetCloseDownMode
致电RetainPermanent
。来自xsetroot
的示例:
/* Free past incarnation if needed, and retain state if needed. */
static void
FixupState(void)
{
Atom prop, type;
int format;
unsigned long length, after;
unsigned char *data;
if (!(DefaultVisual(dpy, screen)->class & Dynamic))
unsave_past = 0;
if (!unsave_past && !save_colors)
return;
prop = XInternAtom(dpy, "_XSETROOT_ID", False);
if (unsave_past) {
(void)XGetWindowProperty(dpy, root, prop, 0L, 1L, True, AnyPropertyType,
&type, &format, &length, &after, &data);
if ((type == XA_PIXMAP) && (format == 32) &&
(length == 1) && (after == 0))
XKillClient(dpy, *((Pixmap *)data));
else if (type != None)
fprintf(stderr, "%s: warning: _XSETROOT_ID property is garbage\n",
program_name);
}
if (save_colors) {
if (!save_pixmap)
save_pixmap = XCreatePixmap(dpy, root, 1, 1, 1);
XChangeProperty(dpy, root, prop, XA_PIXMAP, 32, PropModeReplace,
(unsigned char *) &save_pixmap, 1);
XSetCloseDownMode(dpy, RetainPermanent);
}
}
但是,xsetroot
已准备好Pixmap
结构,在此之前保存为XCopyPlane
。我不知道如何将我用Xft绘制的内容保存为Pixmap
。