mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
106695 Rewrite activate/update events as Carbon events. These are implemented a
s window-scope event handlers. The unnecessary application-scope handlers are r emoved. r=josh sr=pink
This commit is contained in:
parent
a42278ba05
commit
1072616980
@ -79,7 +79,6 @@ static Boolean KeyDown(const UInt8 theKey)
|
||||
#define botRight(r) (((Point *) &(r))[1])
|
||||
#endif
|
||||
|
||||
PRBool nsMacEventHandler::sInBackground = PR_FALSE;
|
||||
PRBool nsMacEventHandler::sMouseInWidgetHit = PR_FALSE;
|
||||
|
||||
nsMacEventDispatchHandler gEventDispatchHandler;
|
||||
@ -397,14 +396,6 @@ PRBool nsMacEventHandler::HandleOSEvent ( EventRecord& aOSEvent )
|
||||
|
||||
switch (aOSEvent.what)
|
||||
{
|
||||
case activateEvt:
|
||||
retVal = HandleActivateEvent(aOSEvent);
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
retVal = UpdateEvent();
|
||||
break;
|
||||
|
||||
case mouseDown:
|
||||
retVal = HandleMouseDownEvent(aOSEvent);
|
||||
break;
|
||||
@ -416,22 +407,9 @@ PRBool nsMacEventHandler::HandleOSEvent ( EventRecord& aOSEvent )
|
||||
case osEvt:
|
||||
{
|
||||
unsigned char eventType = ((aOSEvent.message >> 24) & 0x00ff);
|
||||
if (eventType == suspendResumeMessage)
|
||||
if (eventType == mouseMovedMessage)
|
||||
{
|
||||
if ((aOSEvent.message & 1) == resumeFlag) {
|
||||
sInBackground = PR_FALSE; // resume message
|
||||
} else {
|
||||
sInBackground = PR_TRUE; // suspend message
|
||||
if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) {
|
||||
gRollupListener->Rollup();
|
||||
}
|
||||
}
|
||||
HandleActivateEvent(aOSEvent);
|
||||
}
|
||||
else if (eventType == mouseMovedMessage)
|
||||
{
|
||||
if (! sInBackground)
|
||||
retVal = HandleMouseMoveEvent(aOSEvent);
|
||||
retVal = HandleMouseMoveEvent(aOSEvent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1121,7 +1099,7 @@ PRBool nsMacEventHandler::HandleUKeyEvent(const PRUnichar* text, long charCount,
|
||||
// HandleActivateEvent
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsMacEventHandler::HandleActivateEvent(EventRecord& aOSEvent)
|
||||
void nsMacEventHandler::HandleActivateEvent(PRBool aActive)
|
||||
{
|
||||
#if PINK_PROFILING_ACTIVATE
|
||||
if (KeyDown(0x39)) // press [caps lock] to start the profile
|
||||
@ -1129,20 +1107,8 @@ if (KeyDown(0x39)) // press [caps lock] to start the profile
|
||||
#endif
|
||||
|
||||
OSErr err;
|
||||
Boolean isActive = true;
|
||||
|
||||
switch (aOSEvent.what)
|
||||
{
|
||||
case activateEvt:
|
||||
isActive = ((aOSEvent.modifiers & activeFlag) != 0);
|
||||
break;
|
||||
|
||||
case osEvt:
|
||||
isActive = ! sInBackground;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isActive)
|
||||
if (aActive)
|
||||
{
|
||||
//
|
||||
// Activate The TSMDocument associated with this handler
|
||||
@ -1192,7 +1158,10 @@ if (KeyDown(0x39)) // press [caps lock] to start the profile
|
||||
{
|
||||
|
||||
if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) {
|
||||
if( mTopLevelWidget == gRollupWidget)
|
||||
// If there's a widget to be rolled up, it's got to
|
||||
// be attached to the active window, so it's OK to
|
||||
// roll it up on any deactivate event without
|
||||
// further checking.
|
||||
gRollupListener->Rollup();
|
||||
}
|
||||
//
|
||||
@ -1221,21 +1190,6 @@ if (KeyDown(0x39)) // press [caps lock] to start the profile
|
||||
ProfileSuspend();
|
||||
ProfileStop();
|
||||
#endif
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// UpdateEvent
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsMacEventHandler::UpdateEvent ( )
|
||||
{
|
||||
mTopLevelWidget->HandleUpdateEvent(nil);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,10 +137,10 @@ public:
|
||||
// Synthetic events, generated internally to do things at specific times and
|
||||
// not have to rely on hacking up EventRecords to fake it.
|
||||
//
|
||||
virtual PRBool UpdateEvent ( ) ;
|
||||
virtual PRBool ResizeEvent ( WindowRef inWindow ) ;
|
||||
virtual PRBool Scroll ( EventMouseWheelAxis inAxis, PRInt32 inDelta, const Point& inMouseLoc, nsWindow* inWindow, PRUint32 inModifiers );
|
||||
|
||||
virtual void HandleActivateEvent(PRBool aActive);
|
||||
protected:
|
||||
#if 1
|
||||
virtual void InitializeKeyEvent(nsKeyEvent& aKeyEvent, EventRecord& aOSEvent,
|
||||
@ -149,7 +149,6 @@ protected:
|
||||
virtual PRBool IsSpecialRaptorKey(UInt32 macKeyCode);
|
||||
virtual PRUint32 ConvertKeyEventToUnicode(EventRecord& aOSEvent);
|
||||
#endif
|
||||
virtual PRBool HandleActivateEvent(EventRecord& aOSEvent);
|
||||
virtual PRBool HandleMouseDownEvent(EventRecord& aOSEvent);
|
||||
virtual PRBool HandleMouseUpEvent(EventRecord& aOSEvent);
|
||||
virtual PRBool HandleMouseMoveEvent(EventRecord& aOSEvent);
|
||||
|
@ -81,12 +81,6 @@ nsMacMessagePump::nsMacMessagePump(nsToolkit *aToolkit)
|
||||
{ kEventClassMouse, kEventMouseUp },
|
||||
{ kEventClassMouse, kEventMouseMoved },
|
||||
{ kEventClassMouse, kEventMouseDragged },
|
||||
{ kEventClassWindow, kEventWindowUpdate },
|
||||
{ kEventClassWindow, kEventWindowActivated },
|
||||
{ kEventClassWindow, kEventWindowDeactivated },
|
||||
{ kEventClassWindow, kEventWindowCursorChange },
|
||||
{ kEventClassApplication, kEventAppActivated },
|
||||
{ kEventClassApplication, kEventAppDeactivated },
|
||||
{ kEventClassAppleEvent, kEventAppleEvent },
|
||||
{ kEventClassControl, kEventControlTrack },
|
||||
};
|
||||
@ -166,31 +160,10 @@ PRBool nsMacMessagePump::DispatchEvent(EventRecord *anEvent)
|
||||
handled = DoMouseUp(*anEvent);
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
handled = DoUpdate(*anEvent);
|
||||
break;
|
||||
|
||||
case activateEvt:
|
||||
handled = DoActivate(*anEvent);
|
||||
break;
|
||||
|
||||
case osEvt: {
|
||||
unsigned char eventType = ((anEvent->message >> 24) & 0x00ff);
|
||||
switch (eventType)
|
||||
{
|
||||
case suspendResumeMessage:
|
||||
if (anEvent->message & resumeFlag)
|
||||
nsToolkit::AppInForeground(); // resume message
|
||||
else
|
||||
nsToolkit::AppInBackground(); // suspend message
|
||||
|
||||
handled = DoMouseMove(*anEvent);
|
||||
break;
|
||||
|
||||
case mouseMovedMessage:
|
||||
handled = DoMouseMove(*anEvent);
|
||||
break;
|
||||
}
|
||||
if (eventType == mouseMovedMessage)
|
||||
handled = DoMouseMove(*anEvent);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -203,25 +176,6 @@ PRBool nsMacMessagePump::DispatchEvent(EventRecord *anEvent)
|
||||
return handled;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DoUpdate
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsMacMessagePump::DoUpdate(EventRecord &anEvent)
|
||||
{
|
||||
|
||||
WindowPtr whichWindow = reinterpret_cast<WindowPtr>(anEvent.message);
|
||||
|
||||
StPortSetter portSetter(whichWindow);
|
||||
|
||||
::BeginUpdate(whichWindow);
|
||||
// The app can do its own updates here
|
||||
DispatchOSEventToRaptor(anEvent, whichWindow);
|
||||
::EndUpdate(whichWindow);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DoMouseDown
|
||||
@ -457,45 +411,12 @@ PRBool nsMacMessagePump::DoMouseMove(EventRecord &anEvent)
|
||||
return handled;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DoActivate
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsMacMessagePump::DoActivate(EventRecord &anEvent)
|
||||
{
|
||||
WindowPtr whichWindow = (WindowPtr)anEvent.message;
|
||||
nsGraphicsUtils::SafeSetPortWindowPort(whichWindow);
|
||||
if (anEvent.modifiers & activeFlag)
|
||||
{
|
||||
::HiliteWindow(whichWindow,TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
PRBool ignoreDeactivate = PR_FALSE;
|
||||
nsCOMPtr<nsIWidget> windowWidget;
|
||||
nsToolkit::GetTopWidget ( whichWindow, getter_AddRefs(windowWidget));
|
||||
if (windowWidget)
|
||||
{
|
||||
nsCOMPtr<nsPIWidgetMac> window ( do_QueryInterface(windowWidget) );
|
||||
if (window)
|
||||
{
|
||||
window->GetIgnoreDeactivate(&ignoreDeactivate);
|
||||
window->SetIgnoreDeactivate(PR_FALSE);
|
||||
}
|
||||
}
|
||||
if (!ignoreDeactivate)
|
||||
::HiliteWindow(whichWindow,FALSE);
|
||||
}
|
||||
|
||||
return DispatchOSEventToRaptor(anEvent, whichWindow);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DispatchOSEventToRaptor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
PRBool nsMacMessagePump::DispatchOSEventToRaptor(
|
||||
EventRecord &anEvent,
|
||||
WindowPtr aWindow)
|
||||
|
@ -67,8 +67,6 @@ class nsMacMessagePump
|
||||
PRBool DoMouseDown(EventRecord &anEvent);
|
||||
PRBool DoMouseUp(EventRecord &anEvent);
|
||||
PRBool DoMouseMove(EventRecord &anEvent);
|
||||
PRBool DoUpdate(EventRecord &anEvent);
|
||||
PRBool DoActivate(EventRecord &anEvent);
|
||||
|
||||
PRBool DispatchOSEventToRaptor(EventRecord &anEvent, WindowPtr aWindow);
|
||||
|
||||
|
@ -205,7 +205,6 @@ NS_IMPL_ISUPPORTS_INHERITED4(nsMacWindow, Inherited, nsIEventSink, nsPIWidgetMac
|
||||
nsMacWindow::nsMacWindow() : Inherited()
|
||||
, mWindowMadeHere(PR_FALSE)
|
||||
, mIsSheet(PR_FALSE)
|
||||
, mIgnoreDeactivate(PR_FALSE)
|
||||
, mAcceptsActivation(PR_TRUE)
|
||||
, mIsActive(PR_FALSE)
|
||||
, mZoomOnShow(PR_FALSE)
|
||||
@ -592,6 +591,9 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent,
|
||||
{ kEventClassWindow, kEventWindowConstrain },
|
||||
// to handle update events
|
||||
{ kEventClassWindow, kEventWindowUpdate },
|
||||
// to handle activation
|
||||
{ kEventClassWindow, kEventWindowActivated },
|
||||
{ kEventClassWindow, kEventWindowDeactivated },
|
||||
};
|
||||
|
||||
static EventHandlerUPP sWindowEventHandlerUPP;
|
||||
@ -688,11 +690,10 @@ pascal OSStatus
|
||||
nsMacWindow::WindowEventHandler ( EventHandlerCallRef inHandlerChain, EventRef inEvent, void* userData )
|
||||
{
|
||||
OSStatus retVal = eventNotHandledErr; // Presume we won't consume the event
|
||||
WindowRef myWind = NULL;
|
||||
::GetEventParameter ( inEvent, kEventParamDirectObject, typeWindowRef, NULL, sizeof(myWind), NULL, &myWind );
|
||||
if ( myWind ) {
|
||||
UInt32 what = ::GetEventKind ( inEvent );
|
||||
switch ( what ) {
|
||||
nsMacWindow* self = NS_REINTERPRET_CAST(nsMacWindow*, userData);
|
||||
if (self) {
|
||||
UInt32 what = ::GetEventKind(inEvent);
|
||||
switch (what) {
|
||||
|
||||
case kEventWindowBoundsChanged:
|
||||
{
|
||||
@ -700,15 +701,16 @@ nsMacWindow::WindowEventHandler ( EventHandlerCallRef inHandlerChain, EventRef i
|
||||
UInt32 attributes = 0;
|
||||
::GetEventParameter ( inEvent, kEventParamAttributes, typeUInt32, NULL, sizeof(attributes), NULL, &attributes );
|
||||
if ( attributes & kWindowBoundsChangeSizeChanged ) {
|
||||
WindowRef myWind = NULL;
|
||||
::GetEventParameter(inEvent, kEventParamDirectObject, typeWindowRef, NULL, sizeof(myWind), NULL, &myWind);
|
||||
Rect bounds;
|
||||
::InvalWindowRect(myWind, ::GetWindowPortBounds(myWind, &bounds));
|
||||
|
||||
// resize the window and repaint
|
||||
nsMacWindow* self = NS_REINTERPRET_CAST(nsMacWindow*, userData);
|
||||
NS_ENSURE_TRUE(self->mMacEventHandler.get(), eventNotHandledErr);
|
||||
if ( self && !self->mResizeIsFromUs ) {
|
||||
if (!self->mResizeIsFromUs ) {
|
||||
self->mMacEventHandler->ResizeEvent(myWind);
|
||||
self->mMacEventHandler->UpdateEvent();
|
||||
self->Update();
|
||||
}
|
||||
retVal = noErr; // We did consume the resize event
|
||||
}
|
||||
@ -719,20 +721,17 @@ nsMacWindow::WindowEventHandler ( EventHandlerCallRef inHandlerChain, EventRef i
|
||||
{
|
||||
// Ignore this event if we're an invisible window, otherwise pass along the
|
||||
// chain to ensure it's onscreen.
|
||||
nsMacWindow* self = NS_REINTERPRET_CAST(nsMacWindow*, userData);
|
||||
if ( self ) {
|
||||
if ( self->mWindowType != eWindowType_invisible )
|
||||
retVal = ::CallNextEventHandler(inHandlerChain, inEvent);
|
||||
else
|
||||
retVal = noErr; // consume the event for the hidden window
|
||||
}
|
||||
if ( self->mWindowType != eWindowType_invisible )
|
||||
retVal = ::CallNextEventHandler(inHandlerChain, inEvent);
|
||||
else
|
||||
retVal = noErr; // consume the event for the hidden window
|
||||
break;
|
||||
}
|
||||
|
||||
case kEventWindowUpdate:
|
||||
{
|
||||
nsMacWindow *self = NS_REINTERPRET_CAST(nsMacWindow *, userData);
|
||||
if (self) self->Update();
|
||||
self->Update();
|
||||
retVal = noErr; // consume
|
||||
}
|
||||
break;
|
||||
|
||||
@ -741,10 +740,7 @@ nsMacWindow::WindowEventHandler ( EventHandlerCallRef inHandlerChain, EventRef i
|
||||
{
|
||||
if ( gRollupListener && gRollupWidget )
|
||||
gRollupListener->Rollup();
|
||||
nsMacWindow *self = NS_REINTERPRET_CAST(nsMacWindow *, userData);
|
||||
if (self) {
|
||||
gEventDispatchHandler.DispatchGuiEvent(self, NS_DEACTIVATE);
|
||||
}
|
||||
gEventDispatchHandler.DispatchGuiEvent(self, NS_DEACTIVATE);
|
||||
retVal = ::CallNextEventHandler(inHandlerChain, inEvent);
|
||||
}
|
||||
break;
|
||||
@ -753,18 +749,25 @@ nsMacWindow::WindowEventHandler ( EventHandlerCallRef inHandlerChain, EventRef i
|
||||
// the restored window will be able to take focus.
|
||||
case kEventWindowExpanded:
|
||||
{
|
||||
nsMacWindow *self = NS_REINTERPRET_CAST(nsMacWindow *, userData);
|
||||
if (self) {
|
||||
gEventDispatchHandler.DispatchGuiEvent(self, NS_ACTIVATE);
|
||||
}
|
||||
gEventDispatchHandler.DispatchGuiEvent(self, NS_ACTIVATE);
|
||||
retVal = ::CallNextEventHandler(inHandlerChain, inEvent);
|
||||
}
|
||||
break;
|
||||
|
||||
case kEventWindowActivated:
|
||||
{
|
||||
self->mMacEventHandler->HandleActivateEvent(PR_TRUE);
|
||||
retVal = ::CallNextEventHandler(inHandlerChain, inEvent);
|
||||
}
|
||||
break;
|
||||
|
||||
case kEventWindowDeactivated:
|
||||
{
|
||||
self->mMacEventHandler->HandleActivateEvent(PR_FALSE);
|
||||
retVal = ::CallNextEventHandler(inHandlerChain, inEvent);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// do nothing...
|
||||
break;
|
||||
|
||||
} // case of which event?
|
||||
}
|
||||
|
||||
@ -841,8 +844,6 @@ NS_IMETHODIMP nsMacWindow::Show(PRBool aState)
|
||||
if (parentWindowRef) {
|
||||
WindowPtr top = parentWindowRef;
|
||||
if (piParentWidget) {
|
||||
piParentWidget->SetIgnoreDeactivate(PR_TRUE);
|
||||
|
||||
PRBool parentIsSheet = PR_FALSE;
|
||||
if (NS_SUCCEEDED(piParentWidget->GetIsSheet(&parentIsSheet)) &&
|
||||
parentIsSheet) {
|
||||
@ -945,8 +946,6 @@ NS_IMETHODIMP nsMacWindow::Show(PRBool aState)
|
||||
else {
|
||||
// Sheet, that was hard. No more siblings or parents, going back
|
||||
// to a real window.
|
||||
if (piParentWidget)
|
||||
piParentWidget->SetIgnoreDeactivate(PR_FALSE);
|
||||
|
||||
// if we had several sheets open, when the last one goes away
|
||||
// we need to ensure that the top app window is active
|
||||
@ -1436,26 +1435,6 @@ nsMacWindow::GetMenuBar(nsIMenuBar **_retval)
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// getter/setter for window to ignore the next deactivate event received
|
||||
// if a Mac OS X sheet is being opened
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsMacWindow::GetIgnoreDeactivate(PRBool *_retval)
|
||||
{
|
||||
*_retval = mIgnoreDeactivate;
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacWindow::SetIgnoreDeactivate(PRBool ignoreDeactivate)
|
||||
{
|
||||
mIgnoreDeactivate = ignoreDeactivate;
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacWindow::GetIsSheet(PRBool *_retval)
|
||||
{
|
||||
|
@ -158,7 +158,6 @@ protected:
|
||||
|
||||
PRPackedBool mWindowMadeHere; // true if we created the window
|
||||
PRPackedBool mIsSheet; // true if the window is a sheet (Mac OS X)
|
||||
PRPackedBool mIgnoreDeactivate; // true if this window has a (Mac OS X) sheet as a child
|
||||
PRPackedBool mAcceptsActivation;
|
||||
PRPackedBool mIsActive;
|
||||
PRPackedBool mZoomOnShow;
|
||||
|
@ -48,7 +48,7 @@ interface nsMacWindow;
|
||||
// A private interface (unfrozen, private to the widget implementation) that
|
||||
// gives us access to some extra features on a widget/window.
|
||||
//
|
||||
[scriptable, uuid(41C2C9C5-C6A1-4A2E-A761-ADBBF0F11E55)]
|
||||
[scriptable, uuid(5C58DA7A-196F-4A2C-84BA-61D56CD7FF99)]
|
||||
interface nsPIWidgetMac : nsISupports
|
||||
{
|
||||
// Like OS ::BringToFront, but constrains the window to its z-level
|
||||
@ -65,9 +65,6 @@ interface nsPIWidgetMac : nsISupports
|
||||
// wants to be displayed (if !aShown)
|
||||
nsMacWindow GetChildSheet ( in boolean aShown );
|
||||
|
||||
// True if window should ignore the next deactivate event it receives
|
||||
attribute boolean ignoreDeactivate;
|
||||
|
||||
// True if window is a sheet
|
||||
readonly attribute boolean isSheet;
|
||||
|
||||
|
@ -46,9 +46,6 @@
|
||||
|
||||
|
||||
|
||||
// assume we begin as the fg app
|
||||
bool nsToolkit::sInForeground = true;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
@ -75,26 +72,6 @@ nsToolkit::InitEventQueue(PRThread * aThread)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsToolkit :: AppInForeground ( )
|
||||
{
|
||||
sInForeground = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsToolkit :: AppInBackground ( )
|
||||
{
|
||||
sInForeground = false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
nsToolkit :: IsAppInForeground ( )
|
||||
{
|
||||
return sInForeground;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return the OS X version as returned from Gestalt(gestaltSystemVersion, ...)
|
||||
|
@ -82,11 +82,6 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
// helpers to determine if the app is in the fg or bg
|
||||
static void AppInForeground ( ) ;
|
||||
static void AppInBackground ( ) ;
|
||||
static bool IsAppInForeground ( ) ;
|
||||
|
||||
// utility routines for getting the toplevel widget and event sink
|
||||
// stashed in properties of the window.
|
||||
static void GetWindowEventSink ( WindowPtr aWindow, nsIEventSink** outSink ) ;
|
||||
@ -95,9 +90,5 @@ public:
|
||||
// Returns the OS X version as returned from
|
||||
// Gestalt(gestaltSystemVersion, ...)
|
||||
static long OSXVersion ( ) ;
|
||||
|
||||
protected:
|
||||
|
||||
static bool sInForeground;
|
||||
};
|
||||
#endif // TOOLKIT_H
|
||||
|
@ -684,13 +684,6 @@ NS_METHOD nsWindow::SetCursor(nsCursor aCursor)
|
||||
{
|
||||
nsBaseWidget::SetCursor(aCursor);
|
||||
|
||||
// allow the cursor to be set internally if we're in the bg, but
|
||||
// don't actually set it.
|
||||
if ( !nsToolkit::IsAppInForeground() )
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if ( gCursorSpinner == nsnull )
|
||||
{
|
||||
gCursorSpinner = new CursorSpinner();
|
||||
@ -1223,7 +1216,21 @@ NS_IMETHODIMP nsWindow::Update()
|
||||
StRegionFromPool saveUpdateRgn;
|
||||
if (!saveUpdateRgn)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
::GetWindowUpdateRegion(mWindowPtr, saveUpdateRgn);
|
||||
::GetWindowRegion(mWindowPtr, kWindowUpdateRgn, saveUpdateRgn);
|
||||
|
||||
// Sometimes, the window update region will be larger than the window
|
||||
// itself. Because we obviously don't redraw anything outside of the
|
||||
// window, redrawnRegion won't include that larger area, and the
|
||||
// larger area will be re-invalidated. That triggers an endless
|
||||
// sequence of kEventWindowUpdate events. Avoid that condition by
|
||||
// restricting the update region to the content region.
|
||||
StRegionFromPool windowContentRgn;
|
||||
if (!windowContentRgn)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
::GetWindowRegion(mWindowPtr, kWindowContentRgn, windowContentRgn);
|
||||
|
||||
::SectRgn(saveUpdateRgn, windowContentRgn, saveUpdateRgn);
|
||||
|
||||
// draw the widget
|
||||
StPortSetter portSetter(mWindowPtr);
|
||||
@ -1253,6 +1260,7 @@ NS_IMETHODIMP nsWindow::Update()
|
||||
// figure out the difference between the old update region
|
||||
// and what we redrew
|
||||
::DiffRgn(saveUpdateRgn, redrawnRegion, saveUpdateRgn);
|
||||
|
||||
// and invalidate it
|
||||
::InvalWindowRgn(mWindowPtr, saveUpdateRgn);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user