XRender Create Screen Image

I am trying to create a layout window manager. While this works, but when the window overlays another, it flickers like crazy. I found that it was because I was creating a Picture and then drawing on it, which made it draw on the screen.

My desired behavior was to have an off-screen Picture that I can draw on, and then use XComposite to draw it on the screen window. Is there a way to have an off-screen Picture that is the same size as the root window?

So far (this code runs in an endless thingy loop):

 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, CPSubwindowMode, &pictureAttributes); // The following line should composite to an offscreen picture XRenderComposite(disp, hasAlpha ? PictOpOver : PictOpSrc, picture, None, pictureBuf, 0, 0, 0, 0, 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, pictureBuf, None, rootPicture, 0, 0, 0, 0, RootAttr.x, RootAttr.y, RootAttr.width, RootAttr.height); 
+5
source share
1 answer

I recently studied something similar and decided that I would answer. The following code snippet shows how to create a new pixmap from an existing window without directly drawing in that window. Hope this helps.

 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); 
0
source

Source: https://habr.com/ru/post/1262794/


All Articles