Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!apple!voder!dtg.nsc.com!waggoner From: waggoner@dtg.nsc.com (Mark Waggoner) Newsgroups: comp.sys.amiga.tech Subject: Re: window/event/conman questions Message-ID: <375@icebox.nsc.com> Date: 7 Dec 89 21:21:00 GMT References: <29800002@inmet> <4688@sugar.hackercorp.com> Reply-To: waggoner@icebox.UUCP (Mark Waggoner) Organization: National Semiconductor, Santa Clara Lines: 57 In article <4688@sugar.hackercorp.com> peter@sugar.hackercorp.com (Peter da Silva) writes: >In article <29800002@inmet> rich@inmet.inmet.com writes: (among other things) >> I am writing a programming environment (a smalltalk that is derived from >> Tim Budd's Little Smalltalk, but faster) for Ami. ... >> What happen if a program opens multiple windows and each one ants to wait >> for some events? How does one code that? > >Say you have a null-terminated array of windows, w: > > bits = 0; > for(i = 0; w[i]; i++) > bits |= 1<UserPort->mp_SigBit; > for(;;) > { > for(i = 0; w[i]; i++) > if(msg = GetMsg(w->UserPort)) { > if(handleEvent(msg)) > goto break2; > break; > } > if(!msg) > wait(bits); > } >break2: /* So sue me for using a goto. I wanted to make it match his code > * pretty closely. This was the cleanest way. > */ You can also use just one signal bit for all the windows you open. This is fairly well documented in the old intuition manual and the newer (blue) rom kernal manual. You basically open each new window with NO IDCMP flags. Then, copy the w->UserPort from an already open window, or from a port you have already opened, to the UserPort of the new window. Now, use ModifyIDCMP to set the flags you want. Then, before closing the window, NULL the UserPort so it doesn't get closed and deallocated by CloseWindow. This is the only way to support an arbitrarily large number of windows. You must use the WindowPtr field of the IDCMP messages to distinguish which window the message came from and process it accordingly. These posters that make you write more than you include are a pain. -- ,------------------------------------------------------------------. | Mark Waggoner (408) 721-6306 waggoner@dtg.nsc.com | `------------------------------------------------------------------'