klee@daisy.UUCP (Ken Lee) (12/20/88)
We are building an application that contains 2 (or more) UNIX processes. Each process is an X client. We would like to communicate between the processes with UNIX sockets and wait on these events with select(2). At the same time, we would like to wait on X events with XNextEvent(). Unfortunately, the UNIX input stream seems to be incompatible with the X input stream. Is there any (preferably portable) way to register the X event stream with select()? Alternatively, is there any way to be notified of UNIX events through XNextEvent()? Thanks much for your help! Ken Lee Daisy Systems Corp., Interactive Graphics Tools Dept. -- uucp: uunet!daisy!klee arpanet: daisy!klee@uunet.uu.net "DC6 which is being used for [Contra weapons supply] runs out of New Orleans is probably being used for drug runs into U.S." - Oliver North, August, 1985
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (12/20/88)
Unfortunately, the UNIX input stream seems to be incompatible with the X input stream. Not that I know of. Is there any (preferably portable) way to register the X event stream with select()? Yes. You can get the file descriptor with ConnectionNumber(dpy). Alternatively, is there any way to be notified of UNIX events through XNextEvent()? No, but if you use the Xt Intrinsics, you can be notified of Unix file and timer events through the Xt event mechanisms.
klee@daisy.UUCP (Ken Lee) (12/22/88)
I asked about combining XNextEvent() with select(). Several people responded with the solution. Several others asked for a summary of responses, as they had the same problem. Thanks to all that helped me. The solution is simple: Get the X connection file descriptor with ConnectionNumber(dpy) or XConnectionNumber(dpy) (Xlib manual section 2.2.1). Do a select on this and any other interesting fd's (including sockets). If the X connection fd fires, read it with XNextEvent. Read your other fd's as you would normally. Thanks again for your help! Ken Lee Daisy Systems Corp., Interactive Graphics Tools Dept. -- uucp: uunet!daisy!klee arpanet: daisy!klee@uunet.uu.net "DC6 which is being used for [Contra weapons supply] runs out of New Orleans is probably being used for drug runs into U.S." - Oliver North, August, 1985
mongo@helios (Mongo Package) (12/23/88)
In article <2214@daisy.UUCP> klee@daisy.UUCP (Ken Lee) writes: >I asked about combining XNextEvent() with select(). [stuff deleted] >The solution is simple: > Get the X connection file descriptor with ConnectionNumber(dpy) or > XConnectionNumber(dpy) (Xlib manual section 2.2.1). > Do a select on this and any other interesting fd's (including sockets). > If the X connection fd fires, read it with XNextEvent. Read your > other fd's as you would normally. This is exactly the way that I have begun to follow up my earlier questions on porting a large, clunky, old, command-driven program to use X11 for its display. Instead of doing fgets() to get a line from the user at the terminal, I call a function which does the above. When X events come in they are handled, until a command line is completed. Then the program continues past this new function doing the old, clunky, command-driven code. While this old code is running, no X events are handled. Not handling X events would be irritating, but fortunately, the old code occasionally checks to see if it has been interrupted, and I just add some X event handling to the interrupt checkpoints. Now my only trouble with this is that my code is supposed to run on other systems than Unix (i.e., VMS). I haven't looked into how a select() would be done in VMS, but I suppose it could be faked using QIOs to set flags saying input is ready. If anybody has any pointers about this, I'd still like to hear them. Steve Allen sla@helios.ucsc.edu sla@ucscloa.bitnet ...!ucbvax!ucscc!helios!sla