зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
9601eccbbb
Коммит
2853914fcf
|
@ -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)
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mark Mentovai <mark@moxienet.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Dispatcher for a variety of application-scope events. The real event loop
|
||||
* is in nsAppShell.
|
||||
*/
|
||||
|
||||
#ifndef nsMacMessagePump_h__
|
||||
#define nsMacMessagePump_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
#include <Events.h>
|
||||
|
||||
class nsToolkit;
|
||||
class nsMacTSMMessagePump;
|
||||
|
||||
class nsMacMessagePump
|
||||
{
|
||||
public:
|
||||
nsMacMessagePump(nsToolkit *aToolKit);
|
||||
virtual ~nsMacMessagePump();
|
||||
|
||||
PRBool ProcessEvents(PRBool aProcessEvents);
|
||||
|
||||
// returns PR_TRUE if the event was handled
|
||||
PRBool DispatchEvent(EventRecord *anEvent);
|
||||
|
||||
protected:
|
||||
// these all return PR_TRUE if the event was handled
|
||||
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);
|
||||
|
||||
static pascal OSStatus MouseClickEventHandler(
|
||||
EventHandlerCallRef aHandlerCallRef,
|
||||
EventRef aEvent,
|
||||
void* aUserData);
|
||||
static pascal OSStatus WNETransitionEventHandler(
|
||||
EventHandlerCallRef aHandlerCallRef,
|
||||
EventRef aEvent,
|
||||
void* aUserData);
|
||||
|
||||
protected:
|
||||
nsToolkit* mToolkit;
|
||||
nsMacTSMMessagePump* mTSMMessagePump;
|
||||
EventHandlerRef mMouseClickEventHandler;
|
||||
EventHandlerRef mWNETransitionEventHandler;
|
||||
};
|
||||
#endif // nsMacMessagePump_h__
|
|
@ -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,17 +749,24 @@ 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;
|
||||
|
||||
default:
|
||||
// do nothing...
|
||||
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;
|
||||
|
||||
} // 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;
|
||||
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsToolkit.h"
|
||||
|
||||
#include "nsIEventSink.h"
|
||||
|
||||
#include "nsWidgetSupport.h"
|
||||
|
||||
#include <Gestalt.h>
|
||||
#include <Movies.h>
|
||||
|
||||
|
||||
|
||||
// assume we begin as the fg app
|
||||
bool nsToolkit::sInForeground = true;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::nsToolkit()
|
||||
{
|
||||
::EnterMovies(); // Required for nsSound to Work! -- fix for bug 194632
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::~nsToolkit()
|
||||
{
|
||||
::ExitMovies(); // done with Movie Toolbox -- fix for bug 194632
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult
|
||||
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, ...)
|
||||
//
|
||||
long
|
||||
nsToolkit :: OSXVersion()
|
||||
{
|
||||
static long gOSXVersion = 0x0;
|
||||
if (gOSXVersion == 0x0) {
|
||||
OSErr err = ::Gestalt(gestaltSystemVersion, &gOSXVersion);
|
||||
if (err != noErr) {
|
||||
NS_ERROR("Couldn't determine OS X version, assume 10.0");
|
||||
gOSXVersion = MAC_OS_X_VERSION_10_0_HEX;
|
||||
}
|
||||
}
|
||||
return gOSXVersion;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetTopWidget
|
||||
//
|
||||
// We've stashed the nsIWidget for the given windowPtr in the data
|
||||
// properties of the window. Fetch it.
|
||||
//
|
||||
void
|
||||
nsToolkit::GetTopWidget ( WindowPtr aWindow, nsIWidget** outWidget )
|
||||
{
|
||||
nsIWidget* topLevelWidget = nsnull;
|
||||
::GetWindowProperty ( aWindow,
|
||||
kTopLevelWidgetPropertyCreator, kTopLevelWidgetRefPropertyTag,
|
||||
sizeof(nsIWidget*), nsnull, (void*)&topLevelWidget);
|
||||
if ( topLevelWidget ) {
|
||||
*outWidget = topLevelWidget;
|
||||
NS_ADDREF(*outWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetWindowEventSink
|
||||
//
|
||||
// We've stashed the nsIEventSink for the given windowPtr in the data
|
||||
// properties of the window. Fetch it.
|
||||
//
|
||||
void
|
||||
nsToolkit::GetWindowEventSink ( WindowPtr aWindow, nsIEventSink** outSink )
|
||||
{
|
||||
*outSink = nsnull;
|
||||
|
||||
nsCOMPtr<nsIWidget> topWidget;
|
||||
GetTopWidget ( aWindow, getter_AddRefs(topWidget) );
|
||||
nsCOMPtr<nsIEventSink> sink ( do_QueryInterface(topWidget) );
|
||||
if ( sink ) {
|
||||
*outSink = sink;
|
||||
NS_ADDREF(*outSink);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkitBase* NS_CreateToolkitInstance()
|
||||
{
|
||||
return new nsToolkit();
|
||||
}
|
|
@ -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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче