SunView again and again

Vern Paxson vern at sequoia.ee.lbl.gov
Sat Dec 10 17:17:36 AEST 1988


In article <8811151426.AA27702 at rice.edu> Sun-Spots at Rice.edu writes:
>X-Sun-Spots-Digest: Volume 7, Issue 25, message 5 of 16
>
>....What I need is the
>ability to use SunView's buttons, panels, cycles, etc TOGETHER with a
>graphics package without using extremely low level stuff.  I must be very
>dumb 'cause I have read the CGI and CORE manuals and couldn't find out how
>to do just that.  Is anyone listening? ....

Here's a sketch of the way I got this to work.  Use two separate programs,
one SunView and one SunCore, which communicate with each other via pipes
(or sockets).  The SunView program creates a canvas in which the SunCore
program writes, and the canvas' WIN_EVENT_PROC looks like:

        char canvas_name[WIN_NAMESIZE];

        win_fdtoname( (int) window_get( win, WIN_FD ), canvas_name );
        we_setgfxwindow( canvas_name );

	/* set up IPC here and fork the SunCore program.  If the graphics
	 * is only for output display, then a popen() is all that's needed.
	 * If the SunCore program does both input that needs to be
	 * communicated to the SunView program and output then either
	 * two pipes or a socket need to be created, followed by an exec().
	 */

When forked the SunCore program does a normal get_view_surface(), and then
uses the view surface struct's windowfd field along with the file
descriptor of its input pipe from the SunView program as arguments to
select() in order to listen to both activities like mouse motion and picks
in its window, and commands from the SunView program.  This approach
allows quite flexible interactions.  For example, if the SunCore program
gets a button down event it can send a message to the SunView program
telling it the location and the SunView program can pop up a menu at that
spot.  Or the SunView program can have a button labeled "Restore Zoom" and
when it's hit the SunView program sends an IPC message to the SunCore
program telling it to adjust its viewport accordingly.

		Vern

	Vern Paxson				vern at lbl-csam.arpa
	Real Time Systems			ucbvax!lbl-csam.arpa!vern
	Lawrence Berkeley Laboratory		(415) 486-6411



More information about the Comp.sys.sun mailing list