Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!csd4.milw.wisc.edu!bionet!agate!saturn!helios!mongo From: mongo@helios (Mongo Package) Newsgroups: comp.windows.x Subject: Re: XNextEvent vs. select(2) Summary: This is neat, but system-dependent Keywords: Command-driven programs Message-ID: <5832@saturn.ucsc.edu> Date: 22 Dec 88 16:20:56 GMT References: <2214@daisy.UUCP> Sender: usenet@saturn.ucsc.edu Reply-To: mongo@helios.ucsc.edu (Mongo Package) Organization: University of California, Santa Cruz; UCO/Lick Observatory Lines: 29 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