Getting window previews

adlo adloconwy at
Sat Aug 1 02:52:05 CEST 2015

For the record, xfwm4 uses the functions XCompositeRedirectWindow and XCompositeNameWindowPixmap to get the previews. These functions are part of X11's Composite extension. As far as I can tell, this is the fastest and most efficient way of doing it.

The XCompositeNameWindowPixmap function returns an X11 Pixmap containing the image of the window. This can be wrapped into a GdkPixmap and drawn onto a GtkImage, but this doesn't always work properly due to differing bit depths. Also, there is still the matter of how to resize it to fit in my image.

I have tried to use Cairo before, but I have never been able to get it to work. I always end up with black rectangles where my images should be. xfwm4 uses XRender to display the images, so perhaps that is an alternative option? Though, I'm not sure how to convert an XRender Picture into something that can be drawn onto a GtkImage.

I am not sure whether Cairo or XRender is the better option.

> On 1 Aug 2015, at 01:04, Matthew Brush <mbrush at> wrote:
>> On 15-07-31 11:09 AM, adlo wrote:
>> I am writing a GTK2 program that gets previews of all open windows. It uses the XCompositeNameWindowPixmap function.
>> How do I put these previews into GtkImages?
> You'd probably get better answers on a GTK+ (or XLib) related mailing list but I think this function does what you want:
> And then create the GtkImage from the GdkPixbuf. I'd probably use Cairo for this myself since you can just make a surface from the Pixmap and draw it straight onto whichever widget you need (ex. a GtkDrawingArea).
> Cheers,
> Matthew Brush
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at

More information about the Xfce4-dev mailing list