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