Re: XWindows - how capture window ?

2010-03-13 Thread Valery Reznic
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(10);
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


Re: XWindows - how capture window ?

2010-03-13 Thread Micha





ב-13/03/2010, בשעה 13:03, Valery Reznic valery_rez...@yahoo.com  
כתב/ה:



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();
}



Problem is, like you stated that you to wait for all the drawing  
callbacks to finish


The best approach for such a thing is to post and event to do the  
capture that will go on the queue after the draw events and then  
process the capture in that callback


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(10);
   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 e 
rror 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
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: XWindows - how capture window ?

2010-03-13 Thread Valery Reznic


--- On Sat, 3/13/10, Micha mi...@post.tau.ac.il wrote:

From: Micha mi...@post.tau.ac.il
Subject: Re: XWindows - how capture window ?
To: 
Cc: linux-il. linux-il@cs.huji.ac.il
Date: Saturday, March 13, 2010, 4:00 PM





ב-13/03/2010, בשעה 13:03, Valery Reznic valery_rez...@yahoo.com כתב/ה:

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();
}


Problem is, like you stated that you to wait for all the drawing callbacks to 
finish
The best approach for such a thing is to post and event to do the capture that 
will go on the queue after the draw events and then process the capture in that 
callback

I though about this but it's looks like events reported to be processed, while 
them still not - or I misunderstood meaning of XSync function.

Valery.

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(10);
    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.





___

Re: XWindows - how capture window ?

2010-03-13 Thread Valery Reznic


--- On Sat, 3/13/10, guy keren c...@actcom.co.il wrote:

 From: guy keren c...@actcom.co.il
 Subject: Re: XWindows - how capture window ?
 To: Valery Reznic valery_rez...@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(10);
      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 

Re: XWindows - how capture window ?

2010-03-13 Thread guy keren

Valery Reznic wrote:


--- On Sat, 3/13/10, guy keren c...@actcom.co.il wrote:


From: guy keren c...@actcom.co.il
Subject: Re: XWindows - how capture window ?
To: Valery Reznic valery_rez...@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.


in my program, i used the gtk+ toolkit, and specifically the TextView 
widget.


in this widget, when you populate it with a large amount of text, it 
calculates the size of lines in the background (as an idle task), in 
order to be able to draw the window withthe first lines of text as soon 
as possible. i needed to be able to show the text and immediately jump 
to some line - this failed because the widget didn't yet know exactly 
where to draw each line.


there was no method for the widget to tell me it finished calculating 
its background tasks, so i had to use this kind of sleep-and-wait as a 
work-around.


--guy

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


[HAIFUX Lecture] Scientific programming with modern Fortran - Shimon Panfil, Ph.D.

2010-03-13 Thread Orr Dunkelman
Next Monday, March 15th at 18:30, Haifux will gather to hear Shimon
Panfil, Ph.D.,  talk about:

  Scientific programming with modern Fortran

Abstract

Fortran is the most known language for scientific and engineering
problems. However growth of popularity of C/C++,Java, Matlab etc has
shadowed the development and mere existence of Fortran from wider
community. Situation may change know. Fortran 2003 standard provides
all language features, one expects from modern programming language
and gfortran which replaced g77 in gcc starting from version 4.0
implements this standard.

===

Please note that this meeting is going to be held in Taub 8 (!). For
instructions how to get to Taub 6 (which is very close to Taub 8):
http://www.haifux.org/where.html

Attendance is free, and you are all invited!

==
Future lectures:

12/4/10 Genetic Algorithms - Omer Boehm

==

We are always interested in hearing your talks and ideas. If you wish to
give a talk, hold a discussion, or just plan some event haifux might be
interested in, please contact us at webmas...@haifux.org

-- 
Orr Dunkelman,
orr.dunkel...@gmail.com

GPG fingerprint: C2D5 C6D6 9A24 9A95 C5B3  2023 6CAB 4A7C B73F D0AA
(This key will never sign Emails, only other PGP keys. The key
corresponds to o...@vipe.technion.ac.il)

___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


INOVA USB DVB receiver??

2010-03-13 Thread geoffrey mendelson
Home Center has the Inova USB DVB receiver dongles on sale for 99 NIS  
this week. Anyone have one? Does it work with Linux?


From what I can see on the various forums, the GeniaTech (sold here  
as APEX) is not (yet?) supported by Linux. The old version (never sold  
here AFAIK), works, but the one sold here uses a different tuner chip.


Thanks in advance,

Geoff.
--
geoffrey mendelson N3OWJ/4X1GM
Jerusalem Israel geoffreymendel...@gmail.com
New word I coined 12/13/09, Sub-Wikipedia adj, describing knowledge  
or understanding, as in he has a sub-wikipedia understanding of the  
situation. i.e possessing less facts or information than can be found  
in the Wikipedia.








___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il