XWindows - how capture window ?

XWindows - how capture window ?

Valery Reznic valery_reznic at yahoo.com
Sat Mar 13 16:42:55 IST 2010



--- On Sat, 3/13/10, guy keren <choo at actcom.co.il> wrote:

> From: guy keren <choo at actcom.co.il>
> Subject: Re: XWindows - how capture window ?
> To: "Valery Reznic" <valery_reznic at yahoo.com>
> Date: Saturday, March 13, 2010, 3:56 PM
> 
> the reason is: background jobs.
> 
> the application does not necessarily do everything in one
> shot. some of its widgets leave some processing to be done
> during "idle" periods - which, i imagine, are triggered by
> timers. for this, they need the main loop to be executed for
> some (non-zero) duration.
At least application itself do nothing with timers.
And widgets are the standard ones - labels, buttons, text and draw areas.

So I don't sure what's background jobs is.

Valery.
> 
> i had a similar problem in an application, and i did
> something similar to what you did (only that as long sa
> there were events handled in the 'handle events' loop - i
> retried to sleep and do the handle events loop).
> 
> if you want it done differently, - you'll have to know
> which is the last object to become visible, and synchronize
> with it. i think this is not any better then the
> sleepy-event-loop method you chose.
> 
> --guy
> 
> Valery Reznic wrote:
> > 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 <nyh at math.technion.ac.il>
> wrote:
> > 
> >> From: Nadav Har'El <nyh at math.technion.ac.il>
> >> Subject: Re: XWindows - how capture window ?
> >> To: "Erez D" <erez0001 at gmail.com>
> >> Cc: "Valery Reznic" <valery_reznic at yahoo.com>,
> "linux-il." <linux-il at 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
> >> nyh at 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 at cs.huji.ac.il
> > http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
> 
> 


      



More information about the Linux-il mailing list