From c94631fb82f9073a2c538c99f59067359b2b394b Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Wed, 7 Aug 2002 02:23:00 +0000 Subject: [PATCH] Fix for bug 102797: remove call to EventAvail, firstly because it is redundant (WaitNextEvent will return promptly if there is an event to handle), and because it nullifies the effects of an earlier WakeUpProcess call, which can kill performance in some areas. r=sdagley, sr=scc. git-svn-id: svn://10.0.0.236/trunk@126579 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/mac/nsMacMessagePump.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mozilla/widget/src/mac/nsMacMessagePump.cpp b/mozilla/widget/src/mac/nsMacMessagePump.cpp index 9054de2a414..9de9fb17750 100644 --- a/mozilla/widget/src/mac/nsMacMessagePump.cpp +++ b/mozilla/widget/src/mac/nsMacMessagePump.cpp @@ -365,24 +365,20 @@ PRBool nsMacMessagePump::BrowserIsBusy() * @param NONE * @return A boolean which states whether we have a real event */ -#define kEventAvailMask (mDownMask | mUpMask | keyDownMask | keyUpMask | autoKeyMask | updateMask | activMask | osMask) - PRBool nsMacMessagePump::GetEvent(EventRecord &theEvent) { - // Make sure we call WNE if we have user events, or the mouse is down - EventRecord tempEvent; - // When checking btnState make sure to test if we're in the background - PRBool havePendingEvent = - ::EventAvail(kEventAvailMask, &tempEvent) || - (!(tempEvent.modifiers & btnState) && nsToolkit::IsAppInForeground()); + PRBool inForeground = nsToolkit::IsAppInForeground(); + PRBool buttonDown = ::Button(); // when in the background, we don't want to chew up time processing mouse move // events, so set the mouse region to null. If we're in the fg, however, // we want every mouseMove event we can get our grubby little hands on, so set // it to a 1x1 rect. - RgnHandle mouseRgn = nsToolkit::IsAppInForeground() ? mMouseRgn : nsnull; + RgnHandle mouseRgn = inForeground ? mMouseRgn : nsnull; - SInt32 sleepTime = (havePendingEvent) ? 0 : 5; + // if the mouse is down, and we're in the foreground, then eat + // CPU so we respond quickly when scrolling etc. + SInt32 sleepTime = (buttonDown && inForeground) ? 0 : 5; ::SetEventMask(everyEvent); // we need keyUp events PRBool haveEvent = ::WaitNextEvent(everyEvent, &theEvent, sleepTime, mouseRgn);