OK, I found something interesting. It's turn out that for some reason on-screen rendering is a problem too.
Greatly oversimplified description of my application: There is a mai windows with 2 buttons ('A', and 'B') When buttons 'A' pressed Windows 'W' (with a lot of child windows) created and shown on the screen. It's done with function 'callback_A' When I press button 'B' I want following to happened: 1. Window 'W" created, like it was created, when button 'A' pressed 2. Window 'W" content is captured. So I have callback_B like this: void callback_B() { callback_A(); // create Window 'W' capture_window(); } So far so good. The only trouble is that requests sent to XServer in the function callback_A have no chance to be processed before call to capture_window() function, because application does not retirned to it's main application loop, which process events. To get XServer chance to process events callback_B was modified as following: void callback_B() { callback_A(); // create Window 'W' handle_events(); capture_window(); } Where handle_events looks like: void handle_events() { XFlush(display); XSync(display, False); while (XtAppPending(appContext)) { XtAppProcessEvent(appContext,Mask ); } } This functions used in this application in other cases when events should be handled and it's works OK. But in this case, Window 'W' was only partially drawn. I found workaround modifie callback_B void callback_B() { callback_A(); // create Window 'W' handle_events(); usleep(100000); handle_events(); capture_window(); } After some sleep and addition handle_events call Window 'W' rendered on screen as expected. But I don't why first approach didn't work. From the XSync man page: ------------------------------------------------------------------------- The XSync function flushes the output buffer and then waits until all requests have been received and processed by the X server. Any errors generated must be handled by the error handler. For each protocol error received by Xlib, XSync calls the client application’s error han- dling routine (see section 11.8.2). Any events generated by the server are enqueued into the library’s event queue. ------------------------------------------------------------------- So it's looks like XSync alone should do the job. Obviously it was not - and it was a reason, that event_handle function was written. What I did with sleep and two calls to even_handle is work, but it's ugly. Anyone has idea why XSync alone is not enough and how I can wait to all requests to be processed by XServer ? Regards, Valery. --- On Sun, 3/7/10, Nadav Har'El <n...@math.technion.ac.il> wrote: > From: Nadav Har'El <n...@math.technion.ac.il> > Subject: Re: XWindows - how capture window ? > To: "Erez D" <erez0...@gmail.com> > Cc: "Valery Reznic" <valery_rez...@yahoo.com>, "linux-il." > <linux-il@cs.huji.ac.il> > Date: Sunday, March 7, 2010, 10:38 AM > On Thu, Mar 04, 2010, Erez D wrote > about "Re: XWindows - how capture window ?": > > composite window managers (i.e. compiz, baryl) work by > drawing the original > > window off screen, then read it as a 2D picture, and > render it back to the > > screen with certain effects. > > So i know it is possible to grab an off screen window. > I do not know however > > how to make it off screen. > > This is done using the "Composite" extension. See > http://www.freedesktop.org/wiki/Software/CompositeExt > > But please note that all these "extensions", as their title > implies, are > not available in every installation of X. The "right way" > to use them is > to use them when they're available, but fall back to some > slower or uglier > alternative when they aren't. > > > There is an X Extension called XDamage, which reports > changes on the window > > so you do not have to poll it for changes. These > window managers use it. > > Right. http://www.freedesktop.org/wiki/Software/XDamage > > > -- > Nadav Har'El > | > Sunday, Mar 7 2010, 21 Adar 5770 > n...@math.technion.ac.il > > |----------------------------------------- > Phone +972-523-790466, ICQ 13349191 |Business jargon is the > art of saying > http://nadav.harel.org.il > |nothing while appearing to say a lot. > _______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il