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
This commit is contained in:
roc+%cs.cmu.edu
2005-08-12 03:29:18 +00:00
parent 81a741b925
commit 59ed7a18cc

View File

@@ -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;