Taking a screenshot with translucent windows

Anthony Petrov anthony.petrov at oracle.com
Tue Oct 11 09:21:42 PDT 2011


Our application needs to be able to take screenshots programmatically. 
Historically, we used an xwd-like approach for this - basically, drawing 
the entire windows hierarchy starting from the root window into a pixmap.

However, on modern systems with translucency effects enabled, the areas 
occupied by translucent windows are painted black when we take a 
screenshot using this method. This can easily be reproduced with the xwd 
utility itself.

We tried to retrieve a handle to the overlay window provided by the 
XComposite extension and use it instead of the root window for our 
purposes. Basically we were doing the following (pseudo-code):

Window window = XRootWindow();

if (XComposite is available) {
    window = XCompositeGetOverlayWindow();


if (XComposite is available) {

This works fine as long as only one screenshot is taken during the app's 
life-cycle. However, if we need to take several screenshots in a row, 
for some reason subsequent images contain various visual artifacts 
regardless of whether the translucency effects are enabled on the X 
server or not.

Could anyone suggest the correct way to take a screenshot 
programmatically when we know that translucent windows may be present on 
the screen?

Please point me to a correct mailing list if this question doesn't 
belong here. Any help is appreciated.

PS. Please keep me in the CC list as I'm not subscribed to this mailing 

best regards,

More information about the xorg-devel mailing list