Path: utzoo!mnetor!uunet!cbmvax!steveb From: steveb@cbmvax.UUCP (Steve Beats) Newsgroups: comp.sys.amiga Subject: Re: Dealing with lots of messages Message-ID: <3094@cbmvax.UUCP> Date: 7 Jan 88 00:58:49 GMT References: <4346@garfield.UUCP> Reply-To: steveb@cbmvax.UUCP (Steve Beats) Distribution: na Organization: Commodore Technology, West Chester, PA Lines: 57 Keywords: messages IDCMP MOUSEMOVE In article <4346@garfield.UUCP> john13@garfield.UUCP (John Russell) writes: >None of the messages on dealing with many messages (esp. mousemove) from one >or more ports has mentioned a very simple technique that can speed up >response time greatly. > >It goes something like this (this is from memory): > > msg = GetMsg(window->UserPort); > > class = msg->Class; > x = msg->MouseX , y = msg->MouseY; > > ReplyMsg(msg); > > switch(class) { > case MOUSEMOVE: > if (window->MouseX != x || window->MouseY != y) > /* user has moved the mouse since this message > so I will ignore it */ > break; > else > > } > >By doing this you can minimize the number of redraws (say when rubberbanding >a line). It gives a really great speedup when applied to a time-consuming >interactive operation, eg dragging a DPaint-style curve around the screen. >If you try to process all movement messages for that, you can easily move >the mouse enough so that it will take >10 seconds for the drawing to catch up. > Actually, I have found that the best way to handle MOUSEMOVE events is to use the ReportMouse( window, BOOLEAN) function. When you receive a mouse event, switch off mouse reporting before you begin to process the event and switch it back on again when you have finished. (Of course, you still should check the x and y values to see if there is any work to do). This has the effect of making the mouse reports more granular and you don't get problems with memory being eaten if Intuition gets tons of MOUSEMOVES while you're processing the last one. So I guess it would go something like this:- Wait( 1<UserPort.mp_SigBit ); while( msg = GetMsg(w->UserPort) ) { switch( msg->Class ) { CASE : MOUSEMOVE ReportMouse( w, FALSE ); DoNeatStuff( msg ); ReportMouse( w, TRUE); break; CASE etc. etc } ReplyMsg( msg ); } My 'C' is really rusty, I've spent the last year writing in assembler so don't try to compile this :-) (Anyone want an assembler example ?) Steve