From 930e16ca9705ef180c433e8f8787b3923c656e06 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Fri, 3 Dec 1999 01:14:57 +0000 Subject: [PATCH] fix inGoAway event to dispatch the corresponding nsGUIEvent directly to the top-level window. fixes bug 20538. pinkerton suggested the change. git-svn-id: svn://10.0.0.236/trunk@55146 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/mac/nsMacEventHandler.cpp | 40 ++++++++++---------- mozilla/widget/src/mac/nsMacEventHandler.h | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mozilla/widget/src/mac/nsMacEventHandler.cpp b/mozilla/widget/src/mac/nsMacEventHandler.cpp index 382be637fb3..2bd59d80285 100644 --- a/mozilla/widget/src/mac/nsMacEventHandler.cpp +++ b/mozilla/widget/src/mac/nsMacEventHandler.cpp @@ -90,21 +90,21 @@ nsMacEventDispatchHandler::~nsMacEventDispatchHandler() //------------------------------------------------------------------------- // //------------------------------------------------------------------------- -void nsMacEventDispatchHandler::DispatchGuiEvent(PRUint32 aEventType) +void nsMacEventDispatchHandler::DispatchGuiEvent(nsWindow *aWidget, PRUint32 aEventType) { - if (mActiveWidget) - { - nsGUIEvent guiEvent; - guiEvent.eventStructType = NS_GUI_EVENT; - guiEvent.point.x = 0; - guiEvent.point.y = 0; - guiEvent.time = PR_IntervalNow(); - guiEvent.widget = nsnull; - guiEvent.nativeMsg = nsnull; - guiEvent.message = aEventType; - guiEvent.widget = mActiveWidget; - mActiveWidget->DispatchWindowEvent(guiEvent); - } + NS_ASSERTION(aWidget,"attempted to dispatch gui event to null widget"); + if (!aWidget) + return; + + nsGUIEvent guiEvent; + guiEvent.eventStructType = NS_GUI_EVENT; + guiEvent.point.x = 0; + guiEvent.point.y = 0; + guiEvent.time = PR_IntervalNow(); + guiEvent.nativeMsg = nsnull; + guiEvent.message = aEventType; + guiEvent.widget = aWidget; + aWidget->DispatchWindowEvent(guiEvent); } //------------------------------------------------------------------------- @@ -120,7 +120,7 @@ void nsMacEventDispatchHandler::SetFocus(nsWindow *aFocusedWidget) if (mActiveWidget) { mActiveWidget->RemoveDeleteObserver(this); - DispatchGuiEvent(NS_LOSTFOCUS); + DispatchGuiEvent(mActiveWidget, NS_LOSTFOCUS); } mActiveWidget = aFocusedWidget; @@ -129,7 +129,7 @@ void nsMacEventDispatchHandler::SetFocus(nsWindow *aFocusedWidget) if (mActiveWidget) { mActiveWidget->AddDeleteObserver(this); - DispatchGuiEvent(NS_GOTFOCUS); + DispatchGuiEvent(mActiveWidget, NS_GOTFOCUS); } } @@ -147,7 +147,7 @@ void nsMacEventDispatchHandler::SetActivated(nsWindow *aActivatedWidget) if (mActiveWidget) { mActiveWidget->AddDeleteObserver(this); - DispatchGuiEvent(NS_ACTIVATE); + DispatchGuiEvent(mActiveWidget, NS_ACTIVATE); } } @@ -159,7 +159,7 @@ void nsMacEventDispatchHandler::SetDeactivated(nsWindow *aDeactivatedWidget) // let the old one know it lost activation if (mActiveWidget) { - DispatchGuiEvent(NS_DEACTIVATE); + DispatchGuiEvent(mActiveWidget, NS_DEACTIVATE); mActiveWidget->RemoveDeleteObserver(this); mActiveWidget = nsnull; } @@ -1087,8 +1087,8 @@ PRBool nsMacEventHandler::HandleMouseDownEvent( if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) { gRollupListener->Rollup(); } - gEventDispatchHandler.DispatchGuiEvent(NS_XUL_CLOSE); -// mTopLevelWidget->Destroy(); + gEventDispatchHandler.DispatchGuiEvent(mTopLevelWidget, NS_XUL_CLOSE); + // mTopLevelWidget->Destroy(); (this, by contrast, would immediately close the window) break; } diff --git a/mozilla/widget/src/mac/nsMacEventHandler.h b/mozilla/widget/src/mac/nsMacEventHandler.h index c0d7d5d9181..8de1dae089a 100644 --- a/mozilla/widget/src/mac/nsMacEventHandler.h +++ b/mozilla/widget/src/mac/nsMacEventHandler.h @@ -45,7 +45,7 @@ public: nsMacEventDispatchHandler(); virtual ~nsMacEventDispatchHandler(); - void DispatchGuiEvent(PRUint32 aEventType); + void DispatchGuiEvent(nsWindow *aWidget, PRUint32 aEventType); void SetFocus(nsWindow *aFocusedWidget);