保留在根窗口上使用Xft呈现的文本

时间:2016-11-20 18:11:58

标签: c x11 xlib

我正在使用Xft在根窗口上绘制一些文本,比如

XftDrawStringUtf8(drw, &xftc, f, 50, 50, (XftChar8 *)buf, x);

之后,即使我的程序被杀死,我仍希望保留该文本,类似于fehxsetroot行为。我查看了他们的来源,他们似乎都

  • 保存他们在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

0 个答案:

没有答案