From 64c1a2e7e191598591346e97e2e97f3dbd8cd31b Mon Sep 17 00:00:00 2001 From: Bill Gianopoulos Date: Fri, 30 Jul 2010 14:24:36 -0500 Subject: [PATCH] Bug 575245 - Fix for fx window z-Level issue with windows taskbar set to auto-hide. r=neil, sr=jimm. --- widget/src/windows/nsWindow.cpp | 61 +++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 6b1b7ccbbaf..29c19568283 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -1974,34 +1974,46 @@ nsWindow::UpdateNonClientMargins(PRInt32 aSizeMode, PRBool aReflowWindow) else if (mNonClientMargins.top > 0) mNonClientOffset.top = mCaptionHeight - mNonClientMargins.top; - if (!mNonClientMargins.left) + if (!mNonClientMargins.left) mNonClientOffset.left = mHorResizeMargin; - else if (mNonClientMargins.left > 0) + else if (mNonClientMargins.left > 0) mNonClientOffset.left = mHorResizeMargin - mNonClientMargins.left; - if (!mNonClientMargins.right) + if (!mNonClientMargins.right) mNonClientOffset.right = mHorResizeMargin; - else if (mNonClientMargins.right > 0) + else if (mNonClientMargins.right > 0) mNonClientOffset.right = mHorResizeMargin - mNonClientMargins.right; - if (!mNonClientMargins.bottom) + if (!mNonClientMargins.bottom) mNonClientOffset.bottom = mVertResizeMargin; - else if (mNonClientMargins.bottom > 0) + else if (mNonClientMargins.bottom > 0) mNonClientOffset.bottom = mVertResizeMargin - mNonClientMargins.bottom; - NS_ASSERTION(mNonClientOffset.top >= 0, "non-client top margin is negative!"); - NS_ASSERTION(mNonClientOffset.left >= 0, "non-client left margin is negative!"); - NS_ASSERTION(mNonClientOffset.right >= 0, "non-client right margin is negative!"); - NS_ASSERTION(mNonClientOffset.bottom >= 0, "non-client bottom margin is negative!"); - - if (mNonClientOffset.top < 0) - mNonClientOffset.top = 0; - if (mNonClientOffset.left < 0) - mNonClientOffset.left = 0; - if (mNonClientOffset.right < 0) - mNonClientOffset.right = 0; - if (mNonClientOffset.bottom < 0) - mNonClientOffset.bottom = 0; +#ifndef WINCE + if (aSizeMode == nsSizeMode_Maximized) { + // Address an issue with auto-hide taskbars which fall behind the window. + // Ensure a 1 pixel margin at the bottom of the monitor so that unhiding + // the taskbar works properly. + MONITORINFO info = {sizeof(MONITORINFO)}; + if (::GetMonitorInfo(::MonitorFromWindow(mWnd, MONITOR_DEFAULTTOPRIMARY), + &info)) { + RECT r; + if (::GetWindowRect(mWnd, &r)) { + // Adjust window rect to account for non-client margins. + r.top += mVertResizeMargin - mNonClientOffset.top; + r.left += mHorResizeMargin - mNonClientOffset.left; + r.bottom -= mVertResizeMargin - mNonClientOffset.bottom; + r.right -= mHorResizeMargin - mNonClientOffset.right; + // Leave the 1 pixel margin if the window covers the monitor. + if (r.top <= info.rcMonitor.top && + r.left <= info.rcMonitor.left && + r.right >= info.rcMonitor.right && + r.bottom >= info.rcMonitor.bottom) + mNonClientOffset.bottom -= r.bottom - info.rcMonitor.bottom + 1; + } + } + } +#endif if (aReflowWindow) { // Force a reflow of content based on the new client @@ -5942,6 +5954,17 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS *wp, PRBool& result) #ifdef WINSTATE_DEBUG_OUTPUT printf("*** Resize window: %d x %d x %d x %d\n", wp->x, wp->y, newWidth, newHeight); #endif + + // If a maximized window is resized, recalculate the non-client margins and + // ensure a 1 pixel margin at screen bottom to allow taskbar unhiding to + // work properly. + if (mSizeMode == nsSizeMode_Maximized) { + if (UpdateNonClientMargins(nsSizeMode_Maximized, PR_TRUE)) { + // gecko resize event already sent by UpdateNonClientMargins. + result = PR_TRUE; + return; + } + } // Recalculate the width and height based on the client area for gecko events. if (::GetClientRect(mWnd, &r)) {