Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!jarthur!uunet!mcsun!corton!imag!gourdol From: gourdol@imag.imag.fr (Gourdol Arnaud) Newsgroups: comp.sys.mac.programmer Subject: Re: Unexpected Update Events Message-ID: <21052@imag.imag.fr> Date: 29 Apr 91 21:56:22 GMT References: <11082@bunny.GTE.COM> <1991Apr29.170744.12029@news.iastate.edu> Organization: IMAG Institute, University of Grenoble, France Lines: 46 >In article <11082@bunny.GTE.COM> CAH0@bunny.gte.com (Chuck Hoffman) writes: >> Using THINK C 4.0, and its Debugger, I've written a short program with >>three windows open. With the Debugger, I'm finding that about every >>second there is an update event generated for one or the other of the >>second and third windows. I get all the update events I expect; these are > >I was writing a game and it only had one window. I had it redraw the >screen every time there was an update event... Same problem! There >were so many update events that that the screen constantly flickered >while it was doing the updating... > >doesn't GetNextEvent remove the event? GetNextEvent (but you should use WaitNextEvent) DOES remove the events from the event queue. Note that update events are not standards events, as they are generated by the window manager on idle events. That is, when an idle event is received (aka null event), the window manager sweeps the window list, and if it finds a window whose updateRgn is not empty, it post an update event for this window. This implies that you can do as many InvalRect, InvalRgn as you want, you will receive only ONE updateEvt the next time you call GNE or WNE. >Do you HAVE to use the BEGIN UPDATE and END UPDATE procedures to >get it to stop? Got'it. That's what you have to do. Calling BeginUpdate changes the visRgn to something appropriate (the intersection of the visRgn and the updateRgn) and, most importantely, sets the updateRgn to the emptyRgn. Calling EndUpdate later restores the visRgn to its previous value. As the updateRgn is now empty, the window manager won't post other updateEvt for this window. Also, don't forget to set the correct port before calling BeginUpdate and to restore it after EndUpdate. Arno. -- /======================//==========================================/ / Arnaud Gourdol. // On the Netland: Gourdol@imag.fr / / // Via AppleLink: Gourdol@imag.fr@INTERNET# / /======================//==========================================/