[comp.windows.x] X input & select

garrity@garrity.applicon.UUCP (05/28/87)

  Is there any "correct" way to use select on X's input queue.  The only way
of obtaining input which I see documented is to call XNextEvent.  Down in the
bowels, this calls read on the display's fd.  I have an application which 
would like to sleep until there is input, OR another unrelated device is 
available for write.  In other words, I would like to do this.


done = 0;
while( !done )
{	read_mask  = 1<<dpy->fd;
	write_mask = 1<<other_fd;

	nfds = select(getdtablesize(),&readmask,&writemask,0,0);
	
	if( read_mask & 1<<dpy->fd )
		done = process_input();
	else
		done = process_output();
}

  Does anyone have any ideas?  I can obviously hack something up, but it would
be awfully nice if it was somewhere in the neighborhood of "standard X".

--                                           
-- Mike Garrity
--
-- Asking is just polite demanding.
--                           Max Headroom
--
-- snail: Applicon, a division of Schlumberger Systems, Inc.
--        829 Middlesex Tpk.
--        P.O. box 7004
--        Billerica MA, 01821
--
-- uucp: {allegra|decvax|mit-eddie|utzoo}!linus!raybed2!applicon!garrity
--       {amd|bbncca|cbosgd|wjh12|ihnp4|yale}!ima!applicon!garrity

haynes@DECWRL.DEC.COM (05/31/87)

I believe that selecting on the fd in the display variable is
"standard". That's what the toolkit does to combine input from multiple sources.

	-- Charles

swick@ATHENA.MIT.EDU (Ralph R. Swick) (06/01/87)

Asynchronous i/o has proven to be a very difficult area to tackle in an
os-independent manner.  Several alternatives have been discussed, but none
has yet been deemed entirely adequate.  If anyone has anything to offer
here, let us know.

Doing your own select() on the display fd is perfectly acceptable for now.
You just have to be careful to first ask XPending() if there is anything
remaining to process in Xlib's internal queue.

-Ralph