c – XRender创建屏幕外图片
发布时间:2020-12-16 06:53:04 所属栏目:百科 来源:网络整理
导读:我正在尝试创建一个合成窗口管理器.到目前为止它是有效的,但当一个窗口覆盖另一个窗口时,它会像疯了一样闪烁.我发现这是因为我正在创建一个图片,然后绘制它,这导致它绘制到屏幕上. 我希望的行为是有一个我可以绘制的屏幕外图片,然后使用XComposite将其绘制到
我正在尝试创建一个合成窗口管理器.到目前为止它是有效的,但当一个窗口覆盖另一个窗口时,它会像疯了一样闪烁.我发现这是因为我正在创建一个图片,然后绘制它,这导致它绘制到屏幕上.
我希望的行为是有一个我可以绘制的屏幕外图片,然后使用XComposite将其绘制到屏幕上的窗口.有没有办法让屏幕外的图片与根窗口大小相同? 到目前为止(此代码在无限循环中运行): Window root,parent,*children; uint children_count; XQueryTree(disp,DefaultRootWindow(disp),&root,&parent,&children,&children_count); // I'd like the following picture to be offscreen. // I suspect that I have to put else something where rootPicture is // Currently,when I draw to this picture,X11 renders it to the screen immediately,which is what I don't want. Picture pictureBuf = XRenderCreatePicture(disp,/* rootPicture */,XRenderFindVisualFormat(disp,DefaultVisual(disp,DefaultScreen(disp))),CPSubwindowMode,&RootAttributes); for (uint i = 0; i < children_count; i++) { // collapsed some stuff that doesn't matter Picture picture = XRenderCreatePicture(disp,children[i],pictureFormat,&pictureAttributes); // The following line should composite to an offscreen picture XRenderComposite(disp,hasAlpha ? PictOpOver : PictOpSrc,picture,None,pictureBuf,windowRect.x(),windowRect.y(),windowRect.width(),windowRect.height()); // collapsed some stuff that doesn't matter } // The following line should composite from the offscreen picture to an onscreen picture XRenderComposite(disp,PictOpSrc,rootPicture,RootAttr.x,RootAttr.y,RootAttr.width,RootAttr.height); 解决方法
我最近在寻找类似的东西,并认为我会回复.下面的代码片段显示了如何从现有窗口创建新的像素图,而无需直接绘制到该窗口.希望这会有所帮助.
Pixmap new_pixmap; new_pixmap = XCompositeNameWindowPixmap( display,src_window); Drawable draw = new_pixmap; if (!draw) draw = src_window; Picture origin; origin = XRenderCreatePicture( display,draw,format,CPSubWindowMode,&attributes); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |