From 59ed7a18cc057a9b22ef592eac5e78d36ca47375 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Fri, 12 Aug 2005 03:29:18 +0000 Subject: [PATCH] Bug 300297. Be careful about choosing the top-level window when making a transparent window. r+sr=me,a=shaver/cbeard,patch by Dainis.Jonitis git-svn-id: svn://10.0.0.236/trunk@177632 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/windows/nsWindow.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index a55bacdeffa..58f8e04b5ee 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -690,7 +690,7 @@ static PRBool LangIDToCP(WORD aLangID, UINT& oCP) } } -static HWND GetTopLevelHWND(HWND aWnd) +static HWND GetTopLevelHWND(HWND aWnd, PRBool aStopOnFirstTopLevel = PR_FALSE) { HWND curWnd = aWnd; HWND topWnd = NULL; @@ -698,7 +698,16 @@ static HWND GetTopLevelHWND(HWND aWnd) while (curWnd) { topWnd = curWnd; - curWnd = ::GetParent(curWnd); + + if (aStopOnFirstTopLevel) + { + DWORD style = nsToolkit::mGetWindowLong(curWnd, GWL_STYLE); + + if (!(style & WS_CHILDWINDOW)) // first top-level window + break; + } + + curWnd = ::GetParent(curWnd); // Parent or owner (if has no parent) } return topWnd; @@ -2950,7 +2959,7 @@ NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor, NS_IMETHODIMP nsWindow::HideWindowChrome(PRBool aShouldHide) { - HWND hwnd = GetTopLevelHWND(mWnd); + HWND hwnd = GetTopLevelHWND(mWnd, PR_TRUE); if (!GetNSWindowPtr(hwnd)) { NS_WARNING("Trying to hide window decorations in an embedded context"); @@ -8165,7 +8174,7 @@ nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTranslucent) if (aTranslucent == mIsTranslucent) return NS_OK; - HWND hWnd = GetTopLevelHWND(mWnd); + HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE); nsWindow* topWindow = GetNSWindowPtr(hWnd); if (!topWindow) @@ -8377,7 +8386,7 @@ nsresult nsWindow::UpdateTranslucentWindow() SIZE winSize = { mBounds.width, mBounds.height }; POINT srcPos = { 0, 0 }; HDC hScreenDC = ::GetDC(NULL); - HWND hWnd = GetTopLevelHWND(mWnd); + HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE); RECT winRect; ::GetWindowRect(hWnd, &winRect); @@ -8507,7 +8516,7 @@ void nsWindow::SetWindowRegionToAlphaMask() ::DeleteObject(hrgnRectBlock); } - HWND hWnd = GetTopLevelHWND(mWnd); + HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE); nsWindow* topWindow = GetNSWindowPtr(hWnd); topWindow->w9x.mPerformingSetWindowRgn = PR_TRUE;