Bug 105445 - Difficult to process PLEvents without either latency or CPU hogging. r=pink/sr=sfraser/a=asa
git-svn-id: svn://10.0.0.236/trunk@117623 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
0ba7820f18
commit
2fc0a652f0
@ -369,9 +369,6 @@ PRBool nsMacMessagePump::BrowserIsBusy()
|
||||
|
||||
PRBool nsMacMessagePump::GetEvent(EventRecord &theEvent)
|
||||
{
|
||||
const UInt32 kWNECallIntervalTicks = 4;
|
||||
static UInt32 sNextWNECall = 0;
|
||||
|
||||
// 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
|
||||
@ -379,26 +376,17 @@ PRBool nsMacMessagePump::GetEvent(EventRecord &theEvent)
|
||||
::EventAvail(kEventAvailMask, &tempEvent) ||
|
||||
(!(tempEvent.modifiers & btnState) && nsToolkit::IsAppInForeground());
|
||||
|
||||
// don't call more than once every 4 ticks
|
||||
if (!havePendingEvent && (::TickCount() < sNextWNECall))
|
||||
return PR_FALSE;
|
||||
|
||||
// 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;
|
||||
|
||||
PRBool browserBusy = BrowserIsBusy();
|
||||
SInt32 sleepTime = (havePendingEvent || browserBusy) ? 0 : 2;
|
||||
SInt32 sleepTime = (havePendingEvent) ? 0 : 5;
|
||||
|
||||
::SetEventMask(everyEvent); // we need keyUp events
|
||||
PRBool haveEvent = ::WaitNextEvent(everyEvent, &theEvent, sleepTime, mouseRgn);
|
||||
|
||||
// if we are not busy, call WNE as often as possible to yield time to
|
||||
// other apps (especially important on Mac OS X)
|
||||
sNextWNECall = browserBusy ? (::TickCount() + kWNECallIntervalTicks) : 0;
|
||||
|
||||
#if !TARGET_CARBON
|
||||
if (haveEvent && ::TSMEvent(&theEvent) )
|
||||
haveEvent = PR_FALSE;
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#include <AppleEvents.h>
|
||||
#include <Processes.h>
|
||||
#if !defined(DARWIN)
|
||||
#include "pprthred.h"
|
||||
#endif
|
||||
@ -112,6 +113,8 @@ struct PLEventQueue {
|
||||
PRBool removeMsg;
|
||||
#elif defined(XP_BEOS)
|
||||
port_id eventport;
|
||||
#elif defined(XP_MAC)
|
||||
ProcessSerialNumber psn;
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -170,6 +173,9 @@ static PLEventQueue * _pl_CreateEventQueue(char *name,
|
||||
self->removeMsg = PR_TRUE;
|
||||
#endif
|
||||
self->notified = PR_FALSE;
|
||||
#if defined (XP_MAC)
|
||||
self->psn.lowLongOfPSN = kNoProcess;
|
||||
#endif
|
||||
|
||||
PR_INIT_CLIST(&self->queue);
|
||||
if ( qtype == EventQueueIsNative ) {
|
||||
@ -901,7 +907,7 @@ _pl_NativeNotify(PLEventQueue* self)
|
||||
static PRStatus
|
||||
_pl_NativeNotify(PLEventQueue* self)
|
||||
{
|
||||
#pragma unused (self)
|
||||
WakeUpProcess(&self->psn);
|
||||
return PR_SUCCESS; /* XXX can fail? */
|
||||
}
|
||||
#endif /* XP_MAC */
|
||||
@ -1188,15 +1194,12 @@ static void _md_CreateEventQueue( PLEventQueue *eventQueue )
|
||||
} /* end _md_CreateEventQueue() */
|
||||
#endif /* XP_OS2 */
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_BEOS)
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
/*
|
||||
** _md_CreateEventQueue() -- ModelDependent initializer
|
||||
*/
|
||||
static void _md_CreateEventQueue( PLEventQueue *eventQueue )
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
#pragma unused(eventQueue)
|
||||
#endif
|
||||
/* there's really nothing special to do here,
|
||||
** the guts of the unix stuff is in the setupnativenotify
|
||||
** and related functions.
|
||||
@ -1205,6 +1208,17 @@ static void _md_CreateEventQueue( PLEventQueue *eventQueue )
|
||||
} /* end _md_CreateEventQueue() */
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#if defined(XP_MAC)
|
||||
/*
|
||||
** _md_CreateEventQueue() -- ModelDependent initializer
|
||||
*/
|
||||
static void _md_CreateEventQueue( PLEventQueue *eventQueue )
|
||||
{
|
||||
OSErr err = GetCurrentProcess(&eventQueue->psn);
|
||||
PR_ASSERT(err == noErr);
|
||||
} /* end _md_CreateEventQueue() */
|
||||
#endif /* XP_MAC */
|
||||
|
||||
/* extra functions for unix */
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user