From 31f63c43edd7d716b9b0419a101d06cc4d05f088 Mon Sep 17 00:00:00 2001 From: "rjc%netscape.com" Date: Fri, 19 Apr 2002 10:29:16 +0000 Subject: [PATCH] Fix adt1.0.0+ bug #132493 on MOZILLA_1_0_0_BRANCH (already on tip): Mac OS X multiple sheets issue. r=pink sr=ben a=asa git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_0_BRANCH@119390 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/mac/nsMacWindow.cpp | 73 +++++++++++++++++------- mozilla/widget/src/mac/nsPIWidgetMac.idl | 3 + 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/mozilla/widget/src/mac/nsMacWindow.cpp b/mozilla/widget/src/mac/nsMacWindow.cpp index 70640c0f32f..8c30b89a9f8 100644 --- a/mozilla/widget/src/mac/nsMacWindow.cpp +++ b/mozilla/widget/src/mac/nsMacWindow.cpp @@ -829,7 +829,16 @@ NS_IMETHODIMP nsMacWindow::Show(PRBool bState) if ( mIsSheet && parentWindowRef ) { WindowPtr top = GetWindowTop(parentWindowRef); if (piParentWidget) + { piParentWidget->SetIgnoreDeactivate(PR_TRUE); + PRBool sheetFlag = PR_FALSE; + if (parentWindowRef && + NS_SUCCEEDED(piParentWidget->GetIsSheet(&sheetFlag)) && (sheetFlag)) + { + ::GetSheetWindowParent(parentWindowRef, &top); + ::HideSheetWindow(parentWindowRef); + } + } ::ShowSheetWindow(mWindowPtr, top); UpdateWindowMenubar(parentWindowRef, PR_FALSE); gEventDispatchHandler.DispatchGuiEvent(this, NS_GOTFOCUS); @@ -863,28 +872,45 @@ NS_IMETHODIMP nsMacWindow::Show(PRBool bState) #if TARGET_CARBON // Mac OS X sheet support if (mIsSheet) { + if (piParentWidget) + piParentWidget->SetIgnoreDeactivate(PR_FALSE); + + // get sheet's parent *before* hiding the sheet (which breaks the linkage) + WindowPtr sheetParent = nsnull; + ::GetSheetWindowParent(mWindowPtr, &sheetParent); + + ::HideSheetWindow(mWindowPtr); + + gEventDispatchHandler.DispatchGuiEvent(this, NS_DEACTIVATE); + + // if we had several sheets open, when the last one goes away + // we need to ensure that the top app window is active + WindowPtr top = GetWindowTop(parentWindowRef); + piParentWidget = do_QueryInterface(parentWidget); + + PRBool sheetFlag = PR_FALSE; + if (parentWindowRef && piParentWidget && + NS_SUCCEEDED(piParentWidget->GetIsSheet(&sheetFlag)) && (sheetFlag)) + { + nsCOMPtr parentWidget; + nsToolkit::GetTopWidget(sheetParent, getter_AddRefs(parentWidget)); + piParentWidget = do_QueryInterface(parentWidget); if (piParentWidget) - piParentWidget->SetIgnoreDeactivate(PR_FALSE); - ::HideSheetWindow(mWindowPtr); + piParentWidget->SetIgnoreDeactivate(PR_TRUE); + ::ShowSheetWindow(parentWindowRef, sheetParent); + } + else if ( mAcceptsActivation ) { + ::ShowWindow(top); + } + else { + ::ShowHide(top, true); + ::BringToFront(top); // competes with ComeToFront, but makes popups work + } + ComeToFront(); - gEventDispatchHandler.DispatchGuiEvent(this, NS_DEACTIVATE); - - // if we had several sheets open, when the last one goes away - // we need to ensure that the top app window is active - WindowPtr top = GetWindowTop(parentWindowRef); - - if ( mAcceptsActivation ) { - ::ShowWindow(top); - } - else { - ::ShowHide(top, true); - ::BringToFront(top); // competes with ComeToFront, but makes popups work - } - ComeToFront(); - - if (top == parentWindowRef) { - UpdateWindowMenubar(parentWindowRef, PR_TRUE); - } + if (top == parentWindowRef) { + UpdateWindowMenubar(parentWindowRef, PR_TRUE); + } } else #endif @@ -1372,6 +1398,13 @@ nsMacWindow::SetIgnoreDeactivate(PRBool ignoreDeactivate) return(NS_OK); } +NS_IMETHODIMP +nsMacWindow::GetIsSheet(PRBool *_retval) +{ + *_retval = mIsSheet; + return(NS_OK); +} + //------------------------------------------------------------------------- // diff --git a/mozilla/widget/src/mac/nsPIWidgetMac.idl b/mozilla/widget/src/mac/nsPIWidgetMac.idl index 3f8027a0c03..fbf46480259 100644 --- a/mozilla/widget/src/mac/nsPIWidgetMac.idl +++ b/mozilla/widget/src/mac/nsPIWidgetMac.idl @@ -46,5 +46,8 @@ interface nsPIWidgetMac : nsISupports // True if window should ignore the next deactivate event it receives attribute boolean ignoreDeactivate; + // True if window is a sheet + readonly attribute boolean isSheet; + }; // nsPIWidgetMac