[comp.windows.x] Delayed screen snapshots

klong@wilkins.bcm.tmc.edu (Kevin Long) (03/17/90)

I need something to take a snap shot of a region of my screen, but delay
doing it for enough time for me to bring up a pop-up menu.

Sun has a fairly buggy but interesting program called "snapshot", which
only runs on a Sun w/OpenWindows.  It lets you sweep out the region to
be snapped, similar to xwd, but can delay taking the snapshot for a few
seconds.  The delay gives the user time to bring up a pop-up menu, etc, to 
be included in the screen snapshot.  Very useful.

Is there something like xwd that would let me specify the window id
to be dumped instead of having me click on the window?  I'm thinking
that I could bring up the pop-up menu on display A, and then from display
B run xwd -display A:0.0 -window 0x8000, where 0x8000 is the root window.

Other ideas/suggestions?  I'll repost what I learn.

Regards,
	Kevin Long
	Baylor College of Medicine
	klong@bcm.tmc.edu

klong@wilkins.bcm.tmc.edu (Kevin Long) (03/17/90)

In article <312@gazette.bcm.tmc.edu>, I write:
> I need something to take a snap shot of a region of my screen, but delay
> doing it for enough time for me to bring up a pop-up menu.

Steve Jacobson (csvsj@garnet.berkeley.edu) writes with a good idea:
>Here's what I do (it requires two displays...):
>
>On display one, start up the application you want to dump.
>On display two, run xwatchwin, to watch the root window on display one.
>
>On display one, ...pop up the menu...
>On display two, execute xwd, picking the xwatchwin window.
>
>Steve

I think this will do the trick nicely.
I'd still like for the authors to allow specififying a window ID as a 
command line parameter to xwd so I don't have to use the mouse to click
on the window.  It would only require one display, I think, with a 
scheme like:

	open an xterm
	xlswins the display to get the root window ID
	sleep 10; xwd -display A:0.0 -windowid 0x8023 -out blah.xwd &
        exit to close the xterm
        10 seconds later: voila.

I'll try to mail to them, if I can figure out their mail ids.  The R4
manual page only says:
  >AUTHORS
  >     Tony Della Fera, Digital Equipment Corp., MIT Project Athena
  >     William F. Wyatt, Smithsonian Astrophysical Observatory
Any pointers would be appreciated.


Regards,

	Kevin Long
	Baylor College of Medicine
	klong@bcm.tmc.edu

klong@wilkins.bcm.tmc.edu (Kevin Long) (03/17/90)

In article <315@gazette.bcm.tmc.edu> I write:
>In article <312@gazette.bcm.tmc.edu>, I write:
>> I need something to take a snap shot of a region of my screen, but delay
>> doing it for enough time for me to bring up a pop-up menu.
>
>Steve Jacobson (csvsj@garnet.berkeley.edu) writes with a good idea:
>>On display one, start up the application you want to dump.
>>On display two, run xwatchwin, to watch the root window on display one.
>>On display one, ...pop up the menu...
>>On display two, execute xwd, picking the xwatchwin window.
>
>I'd still like for the authors to allow specififying a window ID as a 
>command line parameter...

Well, guess what, folks: xwd DOES support this already.  It's
an undocumented feature.  As asente@decwrl.dec.com (Paul Asente) writes:
>Try
>sleep 5; xwd -id 0x12345 -out whatever

It works!  The manual page we've got came off the R4 tape.  It's first line
is: 
     .TH XWD 1 "Release 4" "X Version 11"
and a grep for "id" comes up empty. 

****************************************************************************
* I hope the MIT folks add this to the docs (or ask the authors to do so). *
****************************************************************************

	Kevin Long
	Baylor College of Medicine
	klong@bcm.tmc.edu

stripes@eng.umd.edu (Joshua Osborne) (03/17/90)

In article <312@gazette.bcm.tmc.edu> klong@wilkins.bcm.tmc.edu (Kevin Long) writes:
>I need something to take a snap shot of a region of my screen, but delay
>doing it for enough time for me to bring up a pop-up menu.
>
[snapshot info deleted]
>
>Is there something like xwd that would let me specify the window id
>to be dumped instead of having me click on the window?  I'm thinking
>that I could bring up the pop-up menu on display A, and then from display
>B run xwd -display A:0.0 -window 0x8000, where 0x8000 is the root window.

The X11R4 xwd -help reports:
usage: xwd [-display host:dpy] [-debug] [-help] [{-root|-id <id>|-font <font>|-n
ame <name>}] [-nobdrs] [-out <file>] [-xy] [-add value] [-frame]

I have used the -root and -id options.  They work fine, I think they were in R3 
too.  I'm not shure exactly how the -name or -font options work (esp -font, what
does that do?).  When I need a delay to move stuff down I normally do something
like "sleep 4;xwd -id 0x80004"...
-- 
           stripes@eng.umd.edu          "Security for Unix is like
      Josh_Osborne@Real_World,The          Mutitasking for MS-DOS"
      "The dyslexic porgramer"                  - Kevin Lockwood
"Don't try to change C into some nice, safe, portable programming language
 with all sharp edges removed, pick another language."  - John Limpert

david@ics.ics.com (David B. Lewis) (03/19/90)

RE: doing xwd dumps and needing a second display.
We have a homebrew screen-dump program that's used heavily here [puts out
EPS, though] which handles the problem by offering a window id, a delay
option, and an option to interactively snarf out a section of the root
window.  The additions come essentially for free. I have found that I have
the same need for xwd and will look into duplicating the additions in xwd.



David B. Lewis  david@ics.com  david%ics.UUCP@bu.edu  ...!uunet!ics.com!david

Today is the last day of your life so far.

jcb@frisbee.Sun.COM (Jim Becker) (03/21/90)

klong@wilkins.bcm.tmc.edu (Kevin Long) writes:

   I need something to take a snap shot of a region of my screen, but delay
   doing it for enough time for me to bring up a pop-up menu.

   Other ideas/suggestions?  I'll repost what I learn.

A bit over a year ago I needed to write a program that did this, and
took a different approach than others. This program I also posted to
the net, around Feb 89, and should still be around somewhere.

The need was to get bitmaps of main application windows and popups to
be integrated into the text/graphics help system that I developed.

The approach that I took was really simple, and just a few pages of
code. Here goes:

	1) create a master window that defines the outline that will
           be snapshot. the content of this is null, just the placement
	   and size is of interest.

	2) map the window, so the user can define the area of the
           snapshot via window manager resize and movement.
	
	3) run a loop that *polls* the keyboard a couple of times	
	   a second with XQueryKeymap().

	4) notice when certain non-typical keys are pressed. perform
	   actions associated with the keys. I had front, back and
	   snapshot bound to the physical keys.

	5) when the user hits the desired key, do a XGetWindowAttributes()
	   to synch the size and position of the master outline
	   window on the root window.

	6) save the area where the window is using the storage means
	   of interest. at the time I saved in pixwin formats. one
	   can also do an XGetImage() to get the bits. note that the
           master window should be backed before getting the image!
	   (the image is lifted from the RootWindow)

	7) have some scheme where the snapshots are numbered, and
	   allow the user to make lots of them.

I  whipped  up this program in a couple of hours. Not fancy but it got
the  job  done  for  our  tech  writers to generate hundreds of screen
snapshots to be integrated into the help text content.

The popups that I wrote also grabbed the server, so I added a variable
to the interface system that checked a global  variable  that  toggled
the server grab. (It was called `DONTGRABSERVER'!)

This code should be out there on the archive servers somewhere, called
snap.c.  It  isn't  fancy,  but it worked great. Something simple that
gets the job done. KISS?


-Jim Becker
--    
	 Jim Becker / jcb%frisbee@sun.com  / Sun Microsystems