removing nsMacMessageSink for standalone and embedding. Replacing with nsIEventSink and a couple of internal interfaces. r=ccarlen/sr=sfraser. bug#110851

This commit is contained in:
pinkerton%netscape.com 2001-11-29 14:38:56 +00:00
Родитель fdf1c1da51
Коммит d71235b9a6
24 изменённых файлов: 976 добавлений и 663 удалений

Двоичные данные
embedding/browser/powerplant/PPBrowser.mcp

Двоичный файл не отображается.

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

@ -79,9 +79,6 @@
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
// CBrowserShell static variables
nsMacMessageSink CBrowserShell::mMessageSink;
//*****************************************************************************
//*** CBrowserShell: constructors/destructor
@ -156,6 +153,11 @@ void CBrowserShell::FinishCreateSelf()
nsCOMPtr<nsIWidget> aWidget;
ourWindow->GetWidget(getter_AddRefs(aWidget));
ThrowIfNil_(aWidget);
// the widget is also our avenue for dispatching events into Gecko via
// nsIEventSink. Save this sink for later.
mEventSink = do_QueryInterface(aWidget);
ThrowIfNil_(mEventSink);
Rect portFrame;
CalcPortFrameRect(portFrame);
@ -209,7 +211,8 @@ void CBrowserShell::DrawSelf()
{
EventRecord osEvent;
osEvent.what = updateEvt;
mMessageSink.DispatchOSEvent(osEvent, Compat_GetMacWindow());
PRBool handled = PR_FALSE;
mEventSink->DispatchEvent(&osEvent, &handled);
}
@ -219,14 +222,16 @@ void CBrowserShell::ClickSelf(const SMouseDownEvent &inMouseDown)
SwitchTarget(this);
FocusDraw();
mMessageSink.DispatchOSEvent((EventRecord&)inMouseDown.macEvent, Compat_GetMacWindow());
PRBool handled = PR_FALSE;
mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMouseDown.macEvent), &handled);
}
void CBrowserShell::EventMouseUp(const EventRecord &inMacEvent)
{
FocusDraw();
mMessageSink.DispatchOSEvent((EventRecord&)inMacEvent, Compat_GetMacWindow());
PRBool handled = PR_FALSE;
mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMacEvent), &handled);
LEventDispatcher *dispatcher = LEventDispatcher::GetCurrentEventDispatcher();
if (dispatcher)
@ -288,7 +293,8 @@ Boolean CBrowserShell::HandleKeyPress(const EventRecord &inKeyEvent)
FocusDraw();
// dispatch the event
Boolean keyHandled = mMessageSink.DispatchOSEvent((EventRecord&)inKeyEvent, Compat_GetMacWindow());
PRBool handled = PR_FALSE;
Boolean keyHandled = mEventSink->DispatchEvent(&const_cast<EventRecord&>(inKeyEvent), &handled);
return keyHandled;
}
@ -466,12 +472,14 @@ void CBrowserShell::SpendTime(const EventRecord& inMacEvent)
{
case osEvt:
{
// The MacMessageSink will not set the cursor if we are in the background - which is right.
// The event sink will not set the cursor if we are in the background - which is right.
// We have to feed it suspendResumeMessages for it to know
unsigned char eventType = ((inMacEvent.message >> 24) & 0x00ff);
if (eventType == suspendResumeMessage)
mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), Compat_GetMacWindow());
if (eventType == suspendResumeMessage) {
PRBool handled = PR_FALSE;
mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMacEvent), &handled);
}
}
break;
}
@ -872,7 +880,8 @@ void CBrowserShell::HandleMouseMoved(const EventRecord& inMacEvent)
if (IsActive())
{
FocusDraw();
mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), Compat_GetMacWindow());
PRBool handled = PR_FALSE;
mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMacEvent), &handled);
}
}

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

@ -33,6 +33,7 @@
#include "nsIBaseWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWidget.h"
#include "nsIEventSink.h"
#include "nsMacMessageSink.h"
#include "nsIDocShellTreeItem.h"
#include "nsIWebProgress.h"
@ -162,11 +163,10 @@ protected:
Boolean HasFormElements();
protected:
static nsMacMessageSink mMessageSink;
protected:
LStr255 mInitURL;
nsCOMPtr<nsIEventSink> mEventSink; // for event dispatch
nsCOMPtr<nsIWebBrowser> mWebBrowser; // The thing we actually create
nsCOMPtr<nsIBaseWindow> mWebBrowserAsBaseWin; // Convenience interface to above
nsCOMPtr<nsIWebNavigation> mWebBrowserAsWebNav; // Ditto

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

@ -163,7 +163,7 @@ void CThrobber::DrawSelf()
{
#if 0
// Draw directly with the rendering context instead of passing an
// update event through nsMacMessageSink. By the time this routine is
// update event through event sink. By the time this routine is
// called, PowerPlant has taken care of the location, z order, and clipping
// of each view. Since focusing puts the the origin at our top left corner,
// all we have to do is get the bounds of the widget and put that at (0,0)

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

@ -26,9 +26,12 @@
#include "prthread.h"
#include "SIOUX.h"
#include "nsIWidget.h"
#include "nsIEventSink.h"
#include "nsCOMPtr.h"
// Static Variables
nsMacMessageSink CEmbedEventAttachment::mMessageSink;
WindowPtr CEmbedEventAttachment::mLastAlienWindowClicked;
//*****************************************************************************
@ -46,6 +49,46 @@ CEmbedEventAttachment::~CEmbedEventAttachment()
{
}
//
// GetTopWidget
//
// We've stashed the nsIWidget for the given windowPtr in the data
// properties of the window. Fetch it.
//
void
CEmbedEventAttachment::GetTopWidget ( WindowPtr aWindow, nsIWidget** outWidget )
{
nsIWidget* topLevelWidget = nsnull;
::GetWindowProperty ( aWindow, 'MOSS', 'GEKO', 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 of the
// root control. Fetch it.
//
void
CEmbedEventAttachment::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);
}
}
void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
void* ioParam)
{
@ -65,8 +108,13 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
inMacEvent = static_cast<EventRecord*>(ioParam);
::MacFindWindow(inMacEvent->where, &macWindowP);
if (IsAlienGeckoWindow(macWindowP)) {
mMessageSink.DispatchOSEvent(*inMacEvent, macWindowP);
SetExecuteHost(false);
nsCOMPtr<nsIEventSink> sink;
GetWindowEventSink(macWindowP, getter_AddRefs(sink));
if ( sink ) {
PRBool handled = PR_FALSE;
sink->DispatchEvent(inMacEvent, &handled);
SetExecuteHost(false);
}
}
} else if (inMessage == msg_Event) {
@ -97,9 +145,14 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
{
SInt16 thePart = ::MacFindWindow(inMacEvent->where, &macWindowP);
if (thePart == inContent && IsAlienGeckoWindow(macWindowP)) {
mMessageSink.DispatchOSEvent(*inMacEvent, macWindowP);
mLastAlienWindowClicked = macWindowP;
SetExecuteHost(false);
nsCOMPtr<nsIEventSink> sink;
GetWindowEventSink(macWindowP, getter_AddRefs(sink));
if ( sink ) {
PRBool handled = PR_FALSE;
sink->DispatchEvent(inMacEvent, &handled);
mLastAlienWindowClicked = macWindowP;
SetExecuteHost(false);
}
}
else
mLastAlienWindowClicked = nil;
@ -109,9 +162,14 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
case mouseUp:
{
if (mLastAlienWindowClicked) {
mMessageSink.DispatchOSEvent(*inMacEvent, mLastAlienWindowClicked);
nsCOMPtr<nsIEventSink> sink;
GetWindowEventSink(mLastAlienWindowClicked, getter_AddRefs(sink));
if ( sink ) {
PRBool handled = PR_FALSE;
sink->DispatchEvent(inMacEvent, &handled);
mLastAlienWindowClicked = nil;
SetExecuteHost(false);
}
}
}
break;
@ -119,10 +177,15 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
case updateEvt:
case activateEvt:
{
macWindowP = (WindowPtr)inMacEvent->message;
macWindowP = (WindowPtr)inMacEvent->message;
if (IsAlienGeckoWindow(macWindowP)) {
mMessageSink.DispatchOSEvent(*inMacEvent, macWindowP);
nsCOMPtr<nsIEventSink> sink;
GetWindowEventSink(macWindowP, getter_AddRefs(sink));
if ( sink ) {
PRBool handled = PR_FALSE;
sink->DispatchEvent(inMacEvent, &handled);
SetExecuteHost(false);
}
}
}
break;
@ -133,9 +196,18 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
Boolean CEmbedEventAttachment::IsAlienGeckoWindow(WindowPtr inMacWindow)
{
return (inMacWindow &&
!LWindow::FetchWindowObject(inMacWindow) &&
mMessageSink.IsRaptorWindow(inMacWindow));
PRBool isAlien = PR_FALSE;
// it's an 'alien' window if there's no LWindow object and there is
// an nsIEventSink stashed in the window's root control.
if (inMacWindow && !LWindow::FetchWindowObject(inMacWindow)) {
nsCOMPtr<nsIEventSink> sink;
GetWindowEventSink ( inMacWindow, getter_AddRefs(sink) );
if ( sink )
isAlien = PR_TRUE;
}
return isAlien;
}

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

@ -26,7 +26,9 @@
#include "LAttachment.h"
#include "LPeriodical.h"
#include "nsMacMessageSink.h"
class nsIWidget;
class nsIEventSink;
//*****************************************************************************
// class CEmbedEventAttachment
@ -51,7 +53,11 @@ public:
protected:
Boolean IsAlienGeckoWindow(WindowPtr inMacWindow);
static nsMacMessageSink mMessageSink;
// utility routines for getting the toplevel widget and event sink
// stashed in the properties of gecko windows.
static void GetWindowEventSink ( WindowPtr aWindow, nsIEventSink** outSink ) ;
static void GetTopWidget ( WindowPtr aWindow, nsIWidget** outWidget ) ;
static WindowPtr mLastAlienWindowClicked;
};

Двоичные данные
widget/macbuild/WidgetSupport.mcp

Двоичный файл не отображается.

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

@ -1,7 +1,3 @@
#define _IMPL_NS_WIDGET 1
#if !TARGET_CARBON
#define USE_MENUSELECT 1
#endif

Двоичные данные
widget/macbuild/widgetIDL.mcp

Двоичный файл не отображается.

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

@ -79,6 +79,10 @@ XPIDLSRCS = \
nsIXRemoteClient.idl \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),mac)
XPIDLSRCS += nsIEventSink.idl
endif
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

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

@ -23,14 +23,46 @@
#include "nsISupports.idl"
/* THIS IS A PUBLIC EMBEDDING API */
/**
* The nsIEventSink is implemented internally by Gecko as the conduit
* through which native events travel into Gecko. You obtain an
* event sink by QI'ing the top-level nsIWidget, usually a window.
*
* @status UNDER_REVIEW
*/
[uuid(c0d3a7c8-1dd1-11b2-8903-adcd22d004ab)]
interface nsIEventSink : nsISupports
{
/**
* Entry point for native events into Gecko
*/
/**
* Entry point for native events into Gecko.
*
* @return <code>PR_TRUE</code> if event was handled
* <code>PR_FALSE</code> if not handled
*
* On Mac, <code>anEvent</code> is a native <code>EventRecord*</code>.
*/
boolean dispatchEvent ( in voidPtr anEvent ) ;
boolean DispatchEvent ( in voidPtr anEvent, in voidPtr aNativeChild ) ;
/**
* Alerts gecko of a drag event.
*
* @param aMessage the message parameter for a Gecko NS_DRAGDROP_EVENT (See nsGUIEvent.h for list).
* @param aMouseGlobalX x coordinate of mouse, in global coordinates
* @param aMouseGlobalY y coordinate of mouse, in global coordinates
* @param aKeyModifiers a native bitfield of which modifier keys are currently pressed
*
* @return <code>PR_TRUE</code> if event was handled
* <code>PR_FALSE</code> if not handled
*/
boolean dragEvent ( in unsigned long aMessage, in short aMouseGlobalX, in short aMouseGlobalY,
in unsigned short aKeyModifiers ) ;
/**
* Perform any idle processing (handle timers, set the cursor, etc)
*/
void Idle ( ) ;
};

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

@ -68,7 +68,6 @@ CPPSRCS = nsAppShell.cpp \
nsMacControl.cpp \
nsMacEventHandler.cpp \
nsMacMessagePump.cpp \
nsMacMessageSink.cpp \
nsMacResources.cpp \
nsMacTSMMessagePump.cpp \
nsMacWindow.cpp \
@ -90,6 +89,8 @@ CPPSRCS = nsAppShell.cpp \
XPIDLSRCS += \
nsIChangeManager.idl \
nsIMenuCommandDispatcher.idl \
nsPIWidgetMac.idl \
nsPIEventSinkStandalone.idl \
$(NULL)
GARBAGE += $(GFX_LCPPSRCS)

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

@ -98,12 +98,11 @@ NS_IMETHODIMP nsAppShell::Create(int* argc, char ** argv)
rv = NS_GetCurrentToolkit(getter_AddRefs(mToolkit));
if (NS_FAILED(rv))
return rv;
mMacSink.reset(new nsMacMessageSink());
nsIToolkit* toolkit = mToolkit.get();
mMacPump.reset(new nsMacMessagePump(static_cast<nsToolkit*>(toolkit), mMacSink.get()));
mMacPump.reset(new nsMacMessagePump(static_cast<nsToolkit*>(toolkit)));
mMacMemoryCushion.reset(new nsMacMemoryCushion());
if (!mMacSink.get() || !mMacPump.get() || !mMacMemoryCushion.get())
if (!mMacPump.get() || !mMacMemoryCushion.get())
return NS_ERROR_OUT_OF_MEMORY;
OSErr err = mMacMemoryCushion->Init(nsMacMemoryCushion::kMemoryBufferSize, nsMacMemoryCushion::kMemoryReserveSize);

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

@ -56,7 +56,6 @@
using std::auto_ptr;
class nsMacMessagePump;
class nsMacMessageSink;
class nsMacMemoryCushion;
@ -73,7 +72,6 @@ class nsAppShell : public nsIAppShell
nsDispatchListener *mDispatchListener; // note: we don't own this, but it can be NULL
nsCOMPtr<nsIToolkit> mToolkit;
auto_ptr<nsMacMessagePump> mMacPump;
auto_ptr<nsMacMessageSink> mMacSink; // this will be COM, so use scc's COM_auto_ptr
auto_ptr<nsMacMemoryCushion> mMacMemoryCushion;
PRBool mExitCalled;
static PRBool mInitializedToolbox;

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

@ -32,6 +32,8 @@
#include "nsIURL.h"
#include "nsVoidArray.h"
#include "nsIFileChannel.h"
#include "nsToolkit.h"
#include "nsIEventSink.h"
#include <InternetConfig.h>
@ -39,8 +41,6 @@
#include "nsCarbonHelpers.h"
#include "nsFilePicker.h"
#include "nsMacWindow.h"
#include "nsMacMessageSink.h"
#include "nsWatchTask.h"
#include "nsIInternetConfigService.h"
@ -169,6 +169,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
}
//
// FileDialogEventHandlerProc
//
@ -181,13 +182,14 @@ static pascal void FileDialogEventHandlerProc( NavEventCallbackMessage msg, NavC
switch ( cbRec->eventData.eventDataParms.event->what ) {
case updateEvt:
WindowPtr window = reinterpret_cast<WindowPtr>(cbRec->eventData.eventDataParms.event->message);
nsMacWindow* macWindow = nsMacMessageSink::GetNSWindowFromMacWindow(window);
::BeginUpdate(window);
if (macWindow) {
EventRecord theEvent = *cbRec->eventData.eventDataParms.event;
macWindow->HandleOSEvent(theEvent);
nsCOMPtr<nsIEventSink> sink;
nsToolkit::GetWindowEventSink ( window, getter_AddRefs(sink) );
if ( sink ) {
::BeginUpdate(window);
PRBool handled = PR_FALSE;
sink->DispatchEvent(cbRec->eventData.eventDataParms.event, &handled);
::EndUpdate(window);
}
::EndUpdate(window);
break;
}
break;

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

@ -1522,6 +1522,13 @@ PRBool nsMacEventHandler::HandleMouseDownEvent(EventRecord& aOSEvent)
mTopLevelWidget->Resize(macRect.right - macRect.left, macRect.bottom - macRect.top, PR_FALSE);
break;
}
#if TARGET_CARBON
case inToolbarButton: // rjc: Mac OS X
gEventDispatchHandler.DispatchGuiEvent(mTopLevelWidget, NS_XUL_CLOSE);
break;
#endif
}
return retVal;
}

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

@ -51,7 +51,6 @@
//
#include "nsMacMessagePump.h"
#include "nsMacMessageSink.h"
#include "nsWidgetsCID.h"
#include "nsToolkit.h"
#include "nscore.h"
@ -79,6 +78,9 @@
#include "nsCarbonHelpers.h"
#include "nsWatchTask.h"
#include "nsIEventSink.h"
#include "nsPIWidgetMac.h"
#include "nsPIEventSinkStandalone.h"
#include "nsISocketTransportService.h"
#include "nsIFileTransportService.h"
@ -195,8 +197,8 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
* @param aToolkit -- The toolkit created by the application
* @return NONE
*/
nsMacMessagePump::nsMacMessagePump(nsToolkit *aToolkit, nsMacMessageSink* aSink)
: mToolkit(aToolkit), mMessageSink(aSink), mTSMMessagePump(NULL)
nsMacMessagePump::nsMacMessagePump(nsToolkit *aToolkit)
: mToolkit(aToolkit), mTSMMessagePump(NULL)
{
mRunning = PR_FALSE;
mMouseRgn = ::NewRgn();
@ -560,9 +562,11 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
if ( IsWindowHilited(whichWindow) || (gRollupListener && gRollupWidget) )
DispatchOSEventToRaptor(anEvent, whichWindow);
else {
nsMacWindow *mw = mMessageSink->GetNSWindowFromMacWindow(whichWindow);
if (mw)
mw->ComeToFront();
nsCOMPtr<nsIWidget> topWidget;
nsToolkit::GetTopWidget ( whichWindow, getter_AddRefs(topWidget) );
nsCOMPtr<nsPIWidgetMac> macWindow ( do_QueryInterface(topWidget) );
if ( macWindow )
macWindow->ComeToFront();
}
break;
}
@ -589,9 +593,11 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
// only activate if the command key is not down
if (!(anEvent.modifiers & cmdKey))
{
nsMacWindow *mw = mMessageSink->GetNSWindowFromMacWindow(whichWindow);
if (mw)
mw->ComeToFront();
nsCOMPtr<nsIWidget> topWidget;
nsToolkit::GetTopWidget ( whichWindow, getter_AddRefs(topWidget) );
nsCOMPtr<nsPIWidgetMac> macWindow ( do_QueryInterface(topWidget) );
if ( macWindow )
macWindow->ComeToFront();
}
// Dispatch the event because some windows may want to know that they have been moved.
@ -707,11 +713,12 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
if (partCode == inZoomOut)
{
nsMacWindow *whichMacWindow = nsMacMessageSink::GetNSWindowFromMacWindow(whichWindow);
if (whichMacWindow)
whichMacWindow->CalculateAndSetZoomedSize();
}
nsCOMPtr<nsIWidget> topWidget;
nsToolkit::GetTopWidget ( whichWindow, getter_AddRefs(topWidget) );
nsCOMPtr<nsPIWidgetMac> macWindow ( do_QueryInterface(topWidget) );
if ( macWindow )
macWindow->CalculateAndSetZoomedSize();
}
// !!! Do not call ZoomWindow before calling DispatchOSEventToRaptor
// otherwise nsMacEventHandler::HandleMouseDownEvent won't get
// the right partcode for the click location
@ -722,15 +729,12 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
break;
#if TARGET_CARBON
case inToolbarButton: // rjc: Mac OS X
nsWatchTask::GetTask().Suspend();
nsMacWindow *mw = mMessageSink->GetNSWindowFromMacWindow(whichWindow);
if (mw)
{
gEventDispatchHandler.DispatchGuiEvent(mw, NS_OS_TOOLBAR);
}
nsWatchTask::GetTask().Resume();
break;
case inToolbarButton: // rjc: Mac OS X
nsWatchTask::GetTask().Suspend();
::SetPortWindowPort(whichWindow);
DispatchOSEventToRaptor(anEvent, whichWindow);
nsWatchTask::GetTask().Resume();
break;
#endif
}
@ -937,6 +941,9 @@ void nsMacMessagePump::DoIdle(EventRecord &anEvent)
#pragma mark -
//-------------------------------------------------------------------------
//
// DispatchOSEventToRaptor
@ -946,9 +953,12 @@ PRBool nsMacMessagePump::DispatchOSEventToRaptor(
EventRecord &anEvent,
WindowPtr aWindow)
{
if (mMessageSink->IsRaptorWindow(aWindow))
return mMessageSink->DispatchOSEvent(anEvent, aWindow);
return PR_FALSE;
PRBool handled = PR_FALSE;
nsCOMPtr<nsIEventSink> sink;
nsToolkit::GetWindowEventSink ( aWindow, getter_AddRefs(sink) );
if ( sink )
sink->DispatchEvent ( &anEvent, &handled );
return handled;
}
@ -967,9 +977,11 @@ PRBool nsMacMessagePump::DispatchMenuCommandToRaptor(
PRBool handled = PR_FALSE;
WindowPtr theFrontWindow = GetFrontApplicationWindow();
if (mMessageSink->IsRaptorWindow(theFrontWindow))
handled = mMessageSink->DispatchMenuCommand(anEvent, menuResult, theFrontWindow);
nsCOMPtr<nsIEventSink> sink;
nsToolkit::GetWindowEventSink ( theFrontWindow, getter_AddRefs(sink) );
nsCOMPtr<nsPIEventSinkStandalone> menuSink ( do_QueryInterface(sink) );
if ( menuSink )
menuSink->DispatchMenuEvent ( &anEvent, menuResult, &handled );
return handled;
}

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

@ -59,9 +59,9 @@
#include "nsIEventQueueService.h"
class nsToolkit;
class nsMacMessageSink;
class nsMacTSMMessagePump;
class nsIEventSink;
class nsIWidget;
//================================================
@ -75,13 +75,12 @@ private:
Point mMousePoint; // keep track of where the mouse is at all times
RgnHandle mMouseRgn;
nsToolkit* mToolkit;
nsMacMessageSink* mMessageSink;
nsMacTSMMessagePump* mTSMMessagePump;
// CLASS METHODS
public:
nsMacMessagePump(nsToolkit *aToolKit, nsMacMessageSink* aSink);
nsMacMessagePump(nsToolkit *aToolKit);
virtual ~nsMacMessagePump();
void DoMessagePump();

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -44,6 +44,9 @@ using std::auto_ptr;
#include "nsWindow.h"
#include "nsMacEventHandler.h"
#include "nsIEventSink.h"
#include "nsPIWidgetMac.h"
#include "nsPIEventSinkStandalone.h"
#if TARGET_CARBON
#include <CarbonEvents.h>
@ -59,7 +62,7 @@ struct PhantomScrollbarData;
//-------------------------------------------------------------------------
// MacOS native window
class nsMacWindow : public nsChildWindow
class nsMacWindow : public nsChildWindow, public nsIEventSink, public nsPIWidgetMac, public nsPIEventSinkStandalone
{
private:
typedef nsChildWindow Inherited;
@ -68,6 +71,11 @@ public:
nsMacWindow();
virtual ~nsMacWindow();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIEVENTSINK
NS_DECL_NSPIWIDGETMAC
NS_DECL_NSPIEVENTSINKSTANDALONE
/*
// nsIWidget interface
NS_IMETHOD Create(nsIWidget *aParent,
@ -103,7 +111,6 @@ public:
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
NS_IMETHOD PlaceBehind(nsIWidget *aWidget, PRBool aActivate);
NS_IMETHOD SetSizeMode(PRInt32 aMode);
void CalculateAndSetZoomedSize();
NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
NS_IMETHOD GetScreenBounds(nsRect &aRect);
@ -111,20 +118,6 @@ public:
NS_IMETHOD SetTitle(const nsString& aTitle);
virtual PRBool HandleOSEvent(
EventRecord& aOSEvent);
#if USE_MENUSELECT
virtual PRBool HandleMenuCommand(
EventRecord& aOSEvent,
long aMenuResult);
#endif
// be notified that a some form of drag event needs to go into Gecko
virtual PRBool DragEvent ( unsigned int aMessage, Point aMouseGlobal, UInt16 aKeyModifiers ) ;
void ComeToFront();
// nsIKBStateControl interface
NS_IMETHOD ResetInputState();

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

@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
/**
* The nsPIEventSinkStandalone is implemented internally by Gecko as the conduit
* through which native menu events travel into Gecko. You obtain an
* event sink by QI'ing the top-level nsIWidget, usually a window.
*
* This api extends nsIEventSink for events that the stand-alone mozilla
* client needs but embedding does not. It is not intended to be public.
*/
[uuid(912fa496-91ab-4bba-b502-524218ffb1b1)]
interface nsPIEventSinkStandalone : nsISupports
{
/**
* Entry point for native menu events into Gecko.
*
* @return <code>PR_TRUE</code> if event was handled
* <code>PR_FALSE</code> if not handled
*
* @param anEvent a native <code>EventRecord*</code>.
* @param aNativeResult the result of ::MenuSelect().
*/
boolean dispatchMenuEvent ( in voidPtr anEvent, in long aNativeResult ) ;
};

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

@ -0,0 +1,43 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
* Mike Pinkerton
*/
#include "nsISupports.idl"
//
// nsPIWidgetMac
//
// A private interface (unfrozen, private to the widget implementation) that
// gives us access to some extra features on a widget/window.
//
[scriptable, uuid(59356b39-2031-4fd2-a856-435cda1ef700)]
interface nsPIWidgetMac : nsISupports
{
// Like OS ::BringToFront, but constrains the window to its z-level
void ComeToFront ( ) ;
// Recomputes the zoomed window size taking things such as window chrome,
// dock position, menubar, and finder icons into account
void CalculateAndSetZoomedSize ( );
}; // nsPIWidgetMac

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

@ -36,13 +36,15 @@
* ***** END LICENSE BLOCK ***** */
#include "nsToolkit.h"
#include "nsWindow.h"
#include "nsIWidget.h"
#include "nsGUIEvent.h"
#include "nsWidgetAtoms.h"
#include <Gestalt.h>
#include <Appearance.h>
#include "nsIEventSink.h"
#include "nsIEventQueue.h"
#include "nsIEventQueueService.h"
#include "nsIServiceManager.h"
@ -265,6 +267,45 @@ nsToolkit :: IsAppInForeground ( )
}
//
// 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, 'MOSS', 'GEKO', 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);
}
}
//-------------------------------------------------------------------------
//
// Return the nsIToolkit for the current thread. If a toolkit does not

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

@ -70,6 +70,10 @@
#include <MacTypes.h>
class nsIEventSink;
class nsIWidget;
class nsToolkit : public nsIToolkit
{
@ -94,6 +98,11 @@ public:
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 ) ;
static void GetTopWidget ( WindowPtr aWindow, nsIWidget** outWidget ) ;
protected:
bool mInited;
static bool sInForeground;