remove watch task, it went into gfx. add accessors to get it.

This commit is contained in:
pinkerton%netscape.com 2000-09-21 05:11:54 +00:00
Родитель f664beb064
Коммит cce6bd95ac
2 изменённых файлов: 17 добавлений и 151 удалений

Просмотреть файл

@ -60,6 +60,8 @@
#include <Devices.h>
#include <Quickdraw.h>
#include "nsCarbonHelpers.h"
#include "nsWatchTask.h"
#include "nsISocketTransportService.h"
#include "nsIFileTransportService.h"
@ -90,10 +92,6 @@ extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget;
// A class encapsulating our VBL task to spin the watch cursor if we're
// away from WNE for too long
WatchTask gWatchTask;
//======================================================================================
// PROFILE
@ -334,7 +332,7 @@ PRBool nsMacMessagePump::GetEvent(EventRecord &theEvent)
haveEvent = PR_FALSE;
#endif
gWatchTask.EventLoopReached();
nsWatchTask::GetTask().EventLoopReached();
return haveEvent;
}
@ -388,10 +386,11 @@ void nsMacMessagePump::DispatchEvent(PRBool aRealEvent, EventRecord *anEvent)
switch (eventType)
{
case suspendResumeMessage:
if ((anEvent->message & 1) == resumeFlag)
if ( anEvent->message & resumeFlag )
nsToolkit::AppInForeground(); // resume message
else
nsToolkit::AppInBackground(); // suspend message
DoMouseMove(*anEvent);
break;
@ -431,8 +430,6 @@ void nsMacMessagePump::DispatchEvent(PRBool aRealEvent, EventRecord *anEvent)
//#include "ProfilerUtils.h"
void nsMacMessagePump::DoUpdate(EventRecord &anEvent)
{
//INST_TRACE("nsMacMessagePump:DoUpdate");
WindowPtr whichWindow = reinterpret_cast<WindowPtr>(anEvent.message);
StPortSetter portSetter(whichWindow);
@ -476,9 +473,9 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
}
else
{
gWatchTask.Suspend();
nsWatchTask::GetTask().Suspend();
long menuResult = ::MenuSelect(anEvent.where);
gWatchTask.Resume();
nsWatchTask::GetTask().Resume();
if (HiWord(menuResult) != 0)
{
menuResult = ConvertOSMenuResultToPPMenuResult(menuResult);
@ -509,10 +506,10 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
// grrr... DragWindow calls SelectWindow, no way to stop it. For now,
// we'll just let it come to the front and then push it back if necessary.
Rect screenRect;
gWatchTask.Suspend();
nsWatchTask::GetTask().Suspend();
::GetRegionBounds(::GetGrayRgn(), &screenRect);
::DragWindow(whichWindow, anEvent.where, &screenRect);
gWatchTask.Resume();
nsWatchTask::GetTask().Resume();
// only activate if the command key is not down
if (!(anEvent.modifiers & cmdKey))
@ -602,9 +599,9 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
sizeRect.top = kMinWindowHeight;
sizeRect.left = kMinWindowWidth;
gWatchTask.Suspend();
nsWatchTask::GetTask().Suspend();
long newSize = ::GrowWindow(whichWindow, anEvent.where, &sizeRect);
gWatchTask.Resume();
nsWatchTask::GetTask().Resume();
if (newSize != 0)
::SizeWindow(whichWindow, newSize & 0x0FFFF, (newSize >> 16) & 0x0FFFF, true);
::DrawGrowIcon(whichWindow);
@ -620,19 +617,19 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
case inGoAway:
{
gWatchTask.Suspend();
nsWatchTask::GetTask().Suspend();
::SetPortWindowPort(whichWindow);
if (::TrackGoAway(whichWindow, anEvent.where)) {
gWatchTask.Resume();
nsWatchTask::GetTask().Resume();
DispatchOSEventToRaptor(anEvent, whichWindow);
}
gWatchTask.Resume();
nsWatchTask::GetTask().Resume();
break;
}
case inZoomIn:
case inZoomOut:
gWatchTask.Suspend();
nsWatchTask::GetTask().Suspend();
if (::TrackBox(whichWindow, anEvent.where, partCode)) {
GrafPtr savePort;
GDHandle gdNthDevice;
@ -644,7 +641,7 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
long sectArea, greatestArea = 0;
Boolean sectFlag;
gWatchTask.Resume();
nsWatchTask::GetTask().Resume();
GetPort(&savePort);
::SetPortWindowPort(whichWindow);
@ -690,7 +687,7 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
tempRect.bottom - 3);
::SetWindowStandardState ( whichWindow, &zoomRect );
}
gWatchTask.Resume();
nsWatchTask::GetTask().Resume();
SetPort(savePort);
@ -877,8 +874,6 @@ extern const PRInt16 kAppleMenuID; // Danger Will Robinson!!! - this currently r
//-------------------------------------------------------------------------
void nsMacMessagePump::DoActivate(EventRecord &anEvent)
{
//INST_TRACE("nsMacMessagePump:DoActivate");
WindowPtr whichWindow = (WindowPtr)anEvent.message;
::SetPortWindowPort(whichWindow);
if (anEvent.modifiers & activeFlag)
@ -943,86 +938,3 @@ PRBool nsMacMessagePump::DispatchMenuCommandToRaptor(
return handled;
}
#pragma mark -
WatchTask :: WatchTask ( )
: mChecksum('mozz'), mSelf(this), mTicks(::TickCount()), mBusy(PR_FALSE), mSuspended(PR_FALSE),
mInstallSucceeded(PR_FALSE), mAnimation(0)
{
// setup the task
mTask.qType = vType;
mTask.vblAddr = NewVBLProc((VBLProcPtr)DoWatchTask);
mTask.vblCount = kRepeatInterval;
mTask.vblPhase = 0;
// install it
mInstallSucceeded = ::VInstall((QElemPtr)&mTask) == noErr;
}
WatchTask :: ~WatchTask ( )
{
if ( mInstallSucceeded )
::VRemove ( (QElemPtr)&mTask );
InitCursor();
}
//
// DoWatchTask
//
// Called at vertical retrace. If we haven't been to the event loop for
// |kTicksToShowWatch| ticks, animate the cursor.
//
// Note: assumes that the VBLTask, mTask, is the first member variable, so
// that we can piggy-back off the pointer to get to the rest of our data.
//
// (Do we still need the check for LMGetCrsrBusy()? It's not in carbon...)
//
pascal void
WatchTask :: DoWatchTask ( WatchTask* inSelf )
{
if ( inSelf->mChecksum == 'mozz' ) {
if ( !inSelf->mSuspended ) {
if ( !inSelf->mBusy && !LMGetCrsrBusy() ) {
if ( ::TickCount() - inSelf->mTicks > kTicksToShowWatch ) {
::SetAnimatedThemeCursor(kThemeWatchCursor, inSelf->mAnimation);
inSelf->mBusy = PR_TRUE;
}
}
else
::SetAnimatedThemeCursor(kThemeWatchCursor, inSelf->mAnimation);
// next frame in cursor animation
++inSelf->mAnimation;
}
// reset the task to fire again
inSelf->mTask.vblCount = kRepeatInterval;
} // if valid checksum
} // DoWatchTask
//
// EventLoopReached
//
// Called every time we reach the event loop (or an event loop), this tickles
// our internal tick count to reset the time since our last visit to WNE and
// if we were busy, we're not any more.
//
void
WatchTask :: EventLoopReached ( )
{
// reset the cursor if we were animating it
if ( mBusy )
::InitCursor();
mBusy = PR_FALSE;
mTicks = ::TickCount();
mAnimation = 0;
}

Просмотреть файл

@ -39,8 +39,6 @@
#define nsMacMessagePump_h__
#include <Retrace.h>
#include <Events.h>
#include "prtypes.h"
#include "nsIEventQueueService.h"
@ -50,50 +48,6 @@ class nsMacMessageSink;
class nsMacTSMMessagePump;
//
// class WatchTask
//
// A nice little class that installs/removes a VBL to set the cursor to
// the watch if we're away from the event loop for a while. Will also
// animate the watch cursor.
//
class WatchTask
{
public:
WatchTask ( ) ;
~WatchTask ( ) ;
// call from the main event loop
void EventLoopReached ( ) ;
// turn off when we know we're going into an area where it's ok
// that WNE is not called (eg, the menu code)
void Suspend ( ) { mSuspended = PR_TRUE; };
void Resume ( ) { mSuspended = PR_FALSE; };
private:
enum {
kRepeatInterval = 10, // check every 1/6 of a second if we should show watch (10/60)
kTicksToShowWatch = 45, // show watch if haven't seen WNE for 3/4 second (45/60)
kStepsInAnimation = 12
};
// the VBL task
static pascal void DoWatchTask(WatchTask* theTaskPtr) ;
VBLTask mTask; // this must be first!!
long mChecksum; // 'mozz' to validate we have real data at interrupt time (not needed?)
void* mSelf; // so we can get back to |this| from the static routine
long mTicks; // last time the event loop was hit
PRPackedBool mBusy; // are we currently spinning the cursor?
PRPackedBool mSuspended; // set if we've temporarily suspended operation
PRPackedBool mInstallSucceeded; // did we succeed in installing the task? (used in dtor)
short mAnimation; // stage of animation
};
//================================================