我正在编写一个x11剪贴板客户端,使用INCR时遇到了困难。基本上,我的问题是,当我调用XDeleteProperty来启动INCR传输时,我得到了一个BadRequest错误代码
这里有一个片段:
if (type == ctx->incr_atom)
{
ctx->pendingIncr.status = INCR_REQUEST_NEW;
if(XGetWindowProperty(ctx->display, ctx->window,
ctx->property_atom, 0, remaining, FALSE, AnyPropertyType,
&type, &format_property, &length, &remaining, &data) == Success)
{
fprintf(stderr, "Getting window property : %lu bytes fetchedn", length);
}
else
{
fprintf(stderr, "Failed getting window propertyn");
}
error = XDeleteProperty(ctx->display, ctx->window, ctx->property_atom);
if(error == Success)
{
fprintf(stderr, "Entering INCR Protocol!n");
}
else
{
fprintf(stderr, "Failed deleting window property : error code %dn", error);
}
XFlush(ctx->display);
return 1;
}
我在查看Xlib源代码时发现,除非返回代码1是BadRequest异常,否则XDeleteProperty的返回总是1……很高兴知道!