[comp.windows.x] Multiple-server X clients - do they exist?

mbader@blake.acs.washington.edu (Mark Bader) (09/08/89)

Does anyone know if a multiple-server X client is possible?  For
instance, is there a way to start up an X client and sent its output
to multiple displays at the same time?

Is this possible by hacking the source?  Or is there an easier way to
do it (a new feature for X11R4?)

Thanks,
Mark Bader                               INTERNET:  mbader@cac.washington.edu
Networks and Distributed Computing, UW     BITNET:  mbader@uwav1
3737 Brooklyn Ave. NE  	                     BELL:  (206) 543-5128
Seattle, WA  98105                          
	

envbvs@epb2.lbl.gov (Brian V. Smith) (09/08/89)

In article <3522@blake.acs.washington.edu>,
mbader@blake.acs.washington.edu (Mark Bader) writes:
 
< Does anyone know if a multiple-server X client is possible?  For
< instance, is there a way to start up an X client and sent its output
< to multiple displays at the same time?
< 
< Is this possible by hacking the source?  Or is there an easier way to
< do it (a new feature for X11R4?)
	
This feature has existed since X11R1.
No hacking needed.  Every Xlib call requires the Display pointer to be passed.
RT*Fine*M please.

< Thanks,
< Mark Bader                               INTERNET:  mbader@cac.washington.edu
< Networks and Distributed Computing, UW     BITNET:  mbader@uwav1
< 3737 Brooklyn Ave. NE  	                     BELL:  (206) 543-5128
< Seattle, WA  98105                          
___________________________________
Brian V. Smith    (bvsmith@lbl.gov)
Lawrence Berkeley Laboratory
I don't speak for LBL, these non-opinions are all mine.

barmar@think.COM (Barry Margolin) (09/08/89)

In article <3522@blake.acs.washington.edu> mbader@cac.washington.edu (Mark Bader) writes:
>Does anyone know if a multiple-server X client is possible?  

Certainly.  An application program can call XOpenDisplay as many times
as it wants, with a different host name each time.

>For
>instance, is there a way to start up an X client and sent its output
>to multiple displays at the same time?

This sounds like you're talking about taking an existing application
that only uses one display and making it automatically deal with
multiple displays.  If it only calls XOpenDisplay once, it will only
talk to one server.

>Is this possible by hacking the source?  Or is there an easier way to
>do it (a new feature for X11R4?)

What you could do is implement a multiplexing pseudo-server.  This
could be a server that simply forwards X requests to multiple normal
servers, and forwards events from the servers back to the clients.  I
don't know how you would deal with different responses from the
different servers, though (e.g., if the client asks for the dimensions
of the root window, which response should be forwarded?).

Barry Margolin
Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

klee@gilroy.pa.dec.com (Ken Lee) (09/08/89)

In article <3522@blake.acs.washington.edu>, mbader@blake.acs.washington.edu (Mark Bader) writes:
> Does anyone know if a multiple-server X client is possible?

If you're using Xlib, just do several XOpenDisplay()'s, one for each server.
You can provide a user interface to this on the command line, so the user can
select displays.  Due to bugs in X11R3, this is more difficult in Xt.  I know
of no public domain programs that use multiple displays right now, possibly
because of the second restriction.

Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@decwrl.dec.com
uucp: uunet!decwrl!klee

dmc%satori@Sun.COM (Doug Cook) (09/08/89)

In article <3522@blake.acs.washington.edu> mbader@cac.washington.edu (Mark Bader) writes:
>Does anyone know if a multiple-server X client is possible?  For
>instance, is there a way to start up an X client and sent its output
>to multiple displays at the same time?
>
>Is this possible by hacking the source?  Or is there an easier way to
>do it (a new feature for X11R4?)

You need to write the client so that it's intelligent enough to handle multiple
display connections. You'll have to explicitly create the resources you need on
each server. The main changes you need to make are in the event-handling loop. On 
a BSD box, you can then use select() on your server connection fd's to determine when 
events are available from any server. Look at the return value from select() to 
determine which server's events you want to process. If data is waiting on more 
than one server connection, use a round-robin algorithm to select a connection. Then 
call the normal Xlib routines (XNextEvent(), etc.) for that server and process the 
event as you would for a single-server client.

There are some subtleties, though. Because you're using select() rather than 
XNextEvent() to determine when server events are waiting, you need to explicitly
flush events for all the display connections at key points (XNextEvent flushes
events before it tries to read them). 

This is a pretty generalized response, but I hope it's enough to answer your
question. If not, please write me directly, and I'll send you some sample code.

	-Doug

dce@Solbourne.COM (David Elliott) (09/08/89)

In article <124309@sun.Eng.Sun.COM> dmc@sun.UUCP (Doug Cook) writes:
>In article <3522@blake.acs.washington.edu> mbader@cac.washington.edu (Mark Bader) writes:
>>Does anyone know if a multiple-server X client is possible?  For
>>instance, is there a way to start up an X client and sent its output
>>to multiple displays at the same time?
>
>There are some subtleties, though. Because you're using select() rather than 
>XNextEvent() to determine when server events are waiting, you need to explicitly
>flush events for all the display connections at key points (XNextEvent flushes
>events before it tries to read them). 

There's another subtlety that can cause problems when using select() to
handle multiple connections.  On EOF, select() can return "there's something
to read", whereas the ioctl FIONREAD, as used by BytesReadable defined in
Xlibos.h and used in the code to get new events, returns "there are 0
bytes to read".

In other words, be prepared to handle a select() returning a 0 followed
by a "no event" indication as a "connection closed".

Gary Aitken (garya@Solbourne.COM) can be contacted for more information.
I can't.
-- 
David Elliott		dce@Solbourne.COM
			...!{uunet,boulder,nbires,sun}!stan!dce

"We don't do this because we love you or like you...we don't even know you!"

bob@tinman.cis.ohio-state.edu (Bob Sutterfield) (09/09/89)

There used to be a mailing list "sharedx@itsgw.rpi.edu" that discussed
just this sort of issue.  The mail alias still exists, but the list
has been dormant since last October.

schwartz@shire.cs.psu.edu (Scott Schwartz) (09/09/89)

In article <1788@bacchus.dec.com> Ken Lee writes:
| Due to bugs in X11R3, this is more difficult in Xt.  I know
| of no public domain programs that use multiple displays right now, possibly
| because of the second restriction.

Xconq uses multiple displays.
--
Scott Schwartz		<schwartz@shire.cs.psu.edu>
"APAR's?  We don' neeed no steeenking APARS!"