[comp.windows.x] XSelect? is there such a thing

thoth@shark.cis.ufl.edu (Robert Forsman) (09/10/89)

  TWO QUESTIONS

  I'm a novice (started two weeks ago) Xwindows programmer and I've
got a question for people familiar with multi window programs.  Is
there a way to "select" on events from several windows?
  I know there is a way to block on events from a single window so you
don't waste CPU polling for some user to hit a button.  The problem is
that with several windows you will just have them taking turns on
input (i tried it once just to see how it looked).  I need a way to
say - "If I get an event on any of these windows wake me up and tell
me which one."  I've written multi socket game daemons before and
select does the job perfectly but I have no idea what the analogous
call is in X.
  If anyone has better docs handy could they tell me (all the docs on
X I've seen so far suck sewage)?  If there is no such call could
someone suggest an alternative?

SECOND QUESTION.

  I wrote a "fractal" landscape generator that draws oceans and
continents in 3-D into a pixmap and then copies it into the root
window background.  It looks real cool and doesn't refresh _too_ slow,
but when I run something like xconq or even run the "martian" version
of the program it can change the colors of the background.
  I assume that xconq and the "martian" version (the martian landscape
just has altered colors and color altitude boundaries) are overwriting
the colormap entries.  Is there any way to reserve these colors even
after the program exits? (I've set the background.  Why stick around?)
This could be tough because if I change the background again I will
have to DEallocate the colors, but that's another problem.
  I just want to know how to preserve the colors after the generator
has copied the pixmap into the root window.
  If anyone wants the source (the fractals really look neat) I'll have
to warn you that it is now set up for screens that are 1152x900 (Sun
color monitor) and it will take some fiddling before it looks as
pretty on anything else.  I haven't documented it, but it is pretty
simple (probably has sloppy programming style too).

  Please respond by mail since this newsgroup is too big for me to
read on a regular basis.  Thanks ahead of time, and if you have decent
docs you are miles ahead of me already.
  THOTH out -=O=-
--
(U. of F.,  the only place where the CIS department has its own beach :)

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (09/11/89)

    Is there a way to "select" on events from several windows?

What's the problem?  If you just have one X connection open, using XNextEvent
or one of its variants should work just fine.

    Is there any way to reserve these colors even after the program exits?

Look at what the R3 xsetroot does.

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

In article <THOTH.89Sep9174745@shark.cis.ufl.edu>, thoth@shark.cis.ufl.edu (Robert Forsman) writes:
>I've written multi socket game daemons before and
> select does the job perfectly but I have no idea what the analogous
> call is in X.

If you're talking about selecting events from many windows on 1 server,
XSelectEvent and XNextEvent will work fine.  If you're talking about
many servers, you have to use your operating system's inter-process
communication multiplexing facilities.  On BSD UNIX, you can use
ConnectionNumber() to get file descriptors and select() on those.

>   If anyone has better docs handy could they tell me (all the docs on
> X I've seen so far suck sewage)?  If there is no such call could
> someone suggest an alternative?

Well, the X manuals do assume that you have some background in C
programming, raster graphics, and window systems.  There are many
tutorials on these from other sources.  There are also some "intro to
X" type books around.  Check any good technical bookstore.

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

janssen@holmes (Bill Janssen) (09/12/89)

In article <1800@bacchus.dec.com>, klee@gilroy (Ken Lee) writes:
>...  Check any good technical bookstore.
>
>Ken Lee
>DEC Western Software Laboratory, Palo Alto, Calif.

I finally understand what "Check any good technical bookstore" means.
It's code for "I live in Palo Alto or Boston".

Bill
--
 Bill Janssen        janssen.pa@xerox.com      (415) 494-4763
 Xerox Palo Alto Research Center
 3333 Coyote Hill Road, Palo Alto, California   94304