Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!newstop!sun!satori!dmc From: dmc%satori@Sun.COM (Doug Cook) Newsgroups: comp.windows.x Subject: Re: Multiple-server X clients - do they exist? Keywords: X Message-ID: <124309@sun.Eng.Sun.COM> Date: 7 Sep 89 23:23:58 GMT References: <3522@blake.acs.washington.edu> Sender: news@sun.Eng.Sun.COM Reply-To: dmc@sun.UUCP (Doug Cook) Distribution: usa Organization: Sun Microsystems, Mountain View Lines: 27 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