diff --git a/mozilla/dom/src/base/nsScreen.cpp b/mozilla/dom/src/base/nsScreen.cpp index 4864652cf05..7ce981a68fc 100644 --- a/mozilla/dom/src/base/nsScreen.cpp +++ b/mozilla/dom/src/base/nsScreen.cpp @@ -87,19 +87,16 @@ ScreenImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) NS_IMETHODIMP ScreenImpl::GetTop(PRInt32* aTop) { -/* - *** for now... - nsCOMPtr context ( getter_AddRefs(GetDeviceContext() ); + nsCOMPtr context ( getter_AddRefs(GetDeviceContext()) ); if ( context ) { - PRInt32 left; - context->GetDeviceTopLeft( *aTop, left ); + nsRect rect; + context->GetRect( rect ); float devUnits; context->GetDevUnitsToAppUnits(devUnits); - *aTop = NSToIntRound(float(*aTop) / devUnits ); + *aTop = NSToIntRound(float(rect.y) / devUnits ); return NS_OK; } - */ *aTop = -1; return NS_ERROR_FAILURE; } @@ -108,19 +105,16 @@ ScreenImpl::GetTop(PRInt32* aTop) NS_IMETHODIMP ScreenImpl::GetLeft(PRInt32* aLeft) { -/* - *** for now... - nsCOMPtr context ( getter_AddRefs(GetDeviceContext() ); + nsCOMPtr context ( getter_AddRefs(GetDeviceContext()) ); if ( context ) { - PRInt32 top; - context->GetDeficeTopLeft( top, *aLeft ); + nsRect rect; + context->GetRect( rect ); float devUnits; context->GetDevUnitsToAppUnits(devUnits); - *aLeft = NSToIntRound(float(*aLeft) / devUnits ); + *aLeft = NSToIntRound(float(rect.x) / devUnits ); return NS_OK; } - */ *aLeft = -1; return NS_ERROR_FAILURE; } diff --git a/mozilla/gfx/idl/nsIScreen.idl b/mozilla/gfx/idl/nsIScreen.idl index bb0d71a74a2..21582f47b17 100644 --- a/mozilla/gfx/idl/nsIScreen.idl +++ b/mozilla/gfx/idl/nsIScreen.idl @@ -25,15 +25,11 @@ [scriptable, uuid(f728830e-1dd1-11b2-9598-fb9f414f2465)] interface nsIScreen : nsISupports { - readonly attribute long width; - readonly attribute long height; - readonly attribute long pixelDepth; - readonly attribute long colorDepth; - readonly attribute long availWidth; - readonly attribute long availHeight; - readonly attribute long availLeft; - readonly attribute long availTop; + void GetRect ( out long left, out long top, out long width, out long height ); + void GetAvailRect ( out long left, out long top, out long width, out long height ); + readonly attribute long pixelDepth; + readonly attribute long colorDepth; }; diff --git a/mozilla/gfx/public/nsIDeviceContext.h b/mozilla/gfx/public/nsIDeviceContext.h index 80b7619ba15..391b3087d5b 100644 --- a/mozilla/gfx/public/nsIDeviceContext.h +++ b/mozilla/gfx/public/nsIDeviceContext.h @@ -362,13 +362,23 @@ public: */ NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) = 0; + /** + * Get the size of the content area of the output device in app units. + * This corresponds on a screen device, for instance, to the entire screen. + * @param aRect out parameter for full rect. Position (x,y) will be (0,0) or + * relative to the primary monitor if this is not the primary. + * @return error status + */ + NS_IMETHOD GetRect ( nsRect &aRect ) = 0; + /** * Get the size of the content area of the output device in app units. * This corresponds on a screen device, for instance, to the area reported * by GetDeviceSurfaceDimensions, minus the taskbar (Windows) or menubar * (Macintosh). * @param aRect out parameter for client rect. Position (x,y) will be (0,0) - * adjusted for any upper/left non-client space if present. + * adjusted for any upper/left non-client space if present or + * relative to the primary monitor if this is not the primary. * @return error status */ NS_IMETHOD GetClientRect(nsRect &aRect) = 0; diff --git a/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp b/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp index 016e22a74d1..0f43a073cda 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp @@ -95,10 +95,8 @@ NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget) nsCOMPtr screen; sm->GetPrimaryScreen ( getter_AddRefs(screen) ); if ( screen ) { - PRInt32 width, height, depth; - screen->GetAvailWidth ( &width ); - screen->GetAvailHeight ( &height ); - screen->GetPixelDepth ( &depth ); + PRInt32 x, y, width, height, depth; + screen->GetAvailRect ( &x, &y, &width, &height ); mWidthFloat = float(width); mHeightFloat = float(height); mDepth = NS_STATIC_CAST ( PRUint32, depth ); @@ -388,7 +386,9 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PR return NS_OK; } -NS_IMETHODIMP nsDeviceContextGTK::GetClientRect(nsRect &aRect) + + +NS_IMETHODIMP nsDeviceContextGTK::GetRect(nsRect &aRect) { PRInt32 width, height; nsresult rv; @@ -400,6 +400,13 @@ NS_IMETHODIMP nsDeviceContextGTK::GetClientRect(nsRect &aRect) return rv; } + +NS_IMETHODIMP nsDeviceContextGTK::GetClientRect(nsRect &aRect) +{ +//XXX do we know if the client rect should ever differ from the screen rect? + return GetRect ( aRect ); +} + NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext) { diff --git a/mozilla/gfx/src/gtk/nsDeviceContextGTK.h b/mozilla/gfx/src/gtk/nsDeviceContextGTK.h index 477a2026c17..d27048d05da 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextGTK.h +++ b/mozilla/gfx/src/gtk/nsDeviceContextGTK.h @@ -62,6 +62,7 @@ public: NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); NS_IMETHOD GetClientRect(nsRect &aRect); + NS_IMETHOD GetRect(nsRect &aRect); NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); diff --git a/mozilla/gfx/src/gtk/nsScreenGtk.cpp b/mozilla/gfx/src/gtk/nsScreenGtk.cpp index 2ec6d0410fc..aebd83f0bde 100644 --- a/mozilla/gfx/src/gtk/nsScreenGtk.cpp +++ b/mozilla/gfx/src/gtk/nsScreenGtk.cpp @@ -46,22 +46,26 @@ nsScreenGtk :: ~nsScreenGtk() NS_IMPL_ISUPPORTS(nsScreenGtk, NS_GET_IID(nsIScreen)) -NS_IMETHODIMP -nsScreenGtk :: GetWidth(PRInt32 *aWidth) +NS_IMETHODIMP +nsScreenGtk :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { - *aWidth = gdk_screen_width(); - return NS_OK; + *outTop = 0; + *outLeft = 0; + *outWidth = gdk_screen_width(); + *outHeight = gdk_screen_height(); -} // GetWidth +} // GetRect -NS_IMETHODIMP -nsScreenGtk :: GetHeight(PRInt32 *aHeight) +NS_IMETHODIMP +nsScreenGtk :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { - *aHeight = gdk_screen_height(); - return NS_OK; + *outTop = 0; + *outLeft = 0; + *outWidth = gdk_screen_width(); + *outHeight = gdk_screen_height(); -} // GetHeight +} // GetAvailRect NS_IMETHODIMP @@ -83,36 +87,3 @@ nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth) } // GetColorDepth -NS_IMETHODIMP -nsScreenGtk :: GetAvailWidth(PRInt32 *aAvailWidth) -{ - return GetWidth(aAvailWidth); - -} // GetAvailWidth - - -NS_IMETHODIMP -nsScreenGtk :: GetAvailHeight(PRInt32 *aAvailHeight) -{ - return GetHeight(aAvailHeight); - -} // GetAvailHeight - - -NS_IMETHODIMP -nsScreenGtk :: GetAvailLeft(PRInt32 *aAvailLeft) -{ - *aAvailLeft = 0; - return NS_OK; - -} // GetAvailLeft - - -NS_IMETHODIMP -nsScreenGtk :: GetAvailTop(PRInt32 *aAvailTop) -{ - *aAvailTop = 0; - return NS_OK; - -} // GetAvailTop - diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index e8cc06a0d6d..c56eb5a56c2 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -523,9 +523,8 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 & outWidth, nsCOMPtr screen; FindScreenForSurface ( getter_AddRefs(screen) ); if ( screen ) { - PRInt32 width, height; - screen->GetWidth ( &width ); - screen->GetHeight ( &height ); + PRInt32 width, height, ignored; + screen->GetRect ( &ignored, &ignored, &width, &height ); outWidth = NSToIntRound(width * mDevUnitsToAppUnits); outHeight = NSToIntRound(height * mDevUnitsToAppUnits); @@ -543,9 +542,9 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 & outWidth, /** --------------------------------------------------- * See documentation in nsIDeviceContext.h - * @update 12/9/98 dwc */ -NS_IMETHODIMP nsDeviceContextMac::GetClientRect(nsRect &aRect) +NS_IMETHODIMP +nsDeviceContextMac::GetRect(nsRect &aRect) { if( mSpec ) { // we have a printer device @@ -556,15 +555,48 @@ NS_IMETHODIMP nsDeviceContextMac::GetClientRect(nsRect &aRect) } else { // we have a screen device. find the screen that the window is on and + // return its top/left coordinates. + nsCOMPtr screen; + FindScreenForSurface ( getter_AddRefs(screen) ); + if ( screen ) { + PRInt32 x, y, width, height; + screen->GetRect ( &x, &y, &width, &height ); + + aRect.y = NSToIntRound(y * mDevUnitsToAppUnits); + aRect.x = NSToIntRound(x * mDevUnitsToAppUnits); + aRect.width = NSToIntRound(width * mDevUnitsToAppUnits); + aRect.height = NSToIntRound(height * mDevUnitsToAppUnits); + } + else { + NS_WARNING ( "No screen for this surface. How odd" ); + aRect.x = aRect.y = aRect.width = aRect.height = 0; + } + } + + return NS_OK; + +} // GetDeviceTopLeft + + +/** --------------------------------------------------- + * See documentation in nsIDeviceContext.h + */ +NS_IMETHODIMP nsDeviceContextMac::GetClientRect(nsRect &aRect) +{ + if( mSpec ) { + // we have a printer device + aRect.x = aRect.y = 0; + aRect.width = (mPageRect.right-mPageRect.left)*mDevUnitsToAppUnits; + aRect.height = (mPageRect.bottom-mPageRect.top)*mDevUnitsToAppUnits; + } + else { + // we have a screen device. find the screen that the window is on and // return its dimensions. nsCOMPtr screen; FindScreenForSurface ( getter_AddRefs(screen) ); if ( screen ) { PRInt32 x, y, width, height; - screen->GetAvailTop ( &y ); - screen->GetAvailLeft ( &x ); - screen->GetAvailWidth ( &width ); - screen->GetAvailHeight ( &height ); + screen->GetAvailRect ( &x, &y, &width, &height ); aRect.y = NSToIntRound(y * mDevUnitsToAppUnits); aRect.x = NSToIntRound(x * mDevUnitsToAppUnits); @@ -573,10 +605,7 @@ NS_IMETHODIMP nsDeviceContextMac::GetClientRect(nsRect &aRect) } else { NS_WARNING ( "No screen for this surface. How odd" ); - aRect.x = 0; - aRect.y = 0; - aRect.width = 0; - aRect.height = 0; + aRect.x = aRect.y = aRect.width = aRect.height = 0; } } diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.h b/mozilla/gfx/src/mac/nsDeviceContextMac.h index e7ee76cf4f4..6c007b3efb2 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.h +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.h @@ -52,7 +52,6 @@ public: void SetDrawingSurface(nsDrawingSurface aSurface) { mSurface = aSurface; } NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface); - NS_IMETHOD CheckFontExistence(const nsString& aFontName); NS_IMETHOD CreateILColorSpace(IL_ColorSpace*& aColorSpace); NS_IMETHODIMP GetILColorSpace(IL_ColorSpace*& aColorSpace); @@ -60,6 +59,7 @@ public: NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel); NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); + NS_IMETHOD GetRect(nsRect &aRect); NS_IMETHOD GetClientRect(nsRect &aRect); NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, diff --git a/mozilla/gfx/src/mac/nsScreenMac.cpp b/mozilla/gfx/src/mac/nsScreenMac.cpp index 8f048397005..fbd8cd46ec4 100644 --- a/mozilla/gfx/src/mac/nsScreenMac.cpp +++ b/mozilla/gfx/src/mac/nsScreenMac.cpp @@ -47,22 +47,34 @@ nsScreenMac :: ~nsScreenMac() NS_IMPL_ISUPPORTS(nsScreenMac, NS_GET_IID(nsIScreen)) -NS_IMETHODIMP -nsScreenMac :: GetWidth(PRInt32 *aWidth) +NS_IMETHODIMP +nsScreenMac :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { - *aWidth = (**mScreen).gdRect.right - (**mScreen).gdRect.left; + *outLeft = (**mScreen).gdRect.left; + *outTop = (**mScreen).gdRect.top; + *outWidth = (**mScreen).gdRect.right - (**mScreen).gdRect.left; + *outHeight = (**mScreen).gdRect.bottom - (**mScreen).gdRect.top; + return NS_OK; -} // GetWidth +} // GetRect NS_IMETHODIMP -nsScreenMac :: GetHeight(PRInt32 *aHeight) +nsScreenMac :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { - *aHeight = (**mScreen).gdRect.bottom - (**mScreen).gdRect.top; - return NS_OK; + Rect adjustedRect; + SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect ); + + *outLeft = adjustedRect.left; + *outTop = adjustedRect.top; + *outWidth = adjustedRect.right - adjustedRect.left; + *outHeight = adjustedRect.bottom - adjustedRect.top; + + return NS_OK; + +} // GetRect -} // GetHeight NS_IMETHODIMP @@ -83,47 +95,6 @@ nsScreenMac :: GetColorDepth(PRInt32 *aColorDepth) } // GetColorDepth -NS_IMETHODIMP -nsScreenMac :: GetAvailWidth(PRInt32 *aAvailWidth) -{ - GetWidth(aAvailWidth); - return NS_OK; - -} // GetAvailWidth - - -NS_IMETHODIMP -nsScreenMac :: GetAvailHeight(PRInt32 *aAvailHeight) -{ - Rect adjustedRect; - SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect ); - *aAvailHeight = adjustedRect.bottom - adjustedRect.top; - - return NS_OK; - -} // GetAvailHeight - - -NS_IMETHODIMP -nsScreenMac :: GetAvailLeft(PRInt32 *aAvailLeft) -{ - *aAvailLeft = (**mScreen).gdRect.left; - return NS_OK; - -} // GetAvailLeft - - -NS_IMETHODIMP -nsScreenMac :: GetAvailTop(PRInt32 *aAvailTop) -{ - Rect adjustedRect; - SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect ); - *aAvailTop = adjustedRect.top; - - return NS_OK; - -} // GetAvailTop - // // SubtractMenuBar diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp index ec935a64222..dc5375925b4 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp @@ -271,7 +271,7 @@ NS_IMETHODIMP nsDeviceContextPS::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRI /** --------------------------------------------------- * See documentation in nsIDeviceContext.h */ -NS_IMETHODIMP nsDeviceContextPS::GetClientRect(nsRect &aRect) +NS_IMETHODIMP nsDeviceContextPS::GetRect(nsRect &aRect) { PRInt32 width, height; nsresult rv; @@ -283,6 +283,14 @@ NS_IMETHODIMP nsDeviceContextPS::GetClientRect(nsRect &aRect) return rv; } +/** --------------------------------------------------- + * See documentation in nsIDeviceContext.h + */ +NS_IMETHODIMP nsDeviceContextPS::GetClientRect(nsRect &aRect) +{ + return GetRect(aRect); +} + /** --------------------------------------------------- * See documentation in nsIDeviceContext.h * @update 12/21/98 dwc diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.h b/mozilla/gfx/src/ps/nsDeviceContextPS.h index b210952576a..341b59dce84 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.h +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.h @@ -69,6 +69,7 @@ public: NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); NS_IMETHOD GetClientRect(nsRect &aRect); + NS_IMETHOD GetRect(nsRect &aRect); NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext); NS_IMETHOD GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const; diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp index 18efcca738e..bea0eb98672 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp @@ -174,10 +174,7 @@ nsDeviceContextWin :: ComputeClientRectUsingScreen ( nsRect* outRect ) FindScreen ( getter_AddRefs(screen) ); if ( screen ) { PRInt32 x, y, width, height; - screen->GetAvailTop ( &y ); - screen->GetAvailLeft ( &x ); - screen->GetAvailWidth ( &width ); - screen->GetAvailHeight ( &height ); + screen->GetAvailRect ( &x, &y, &width, &height ); // convert to device units outRect->y = NSToIntRound(y * mDevUnitsToAppUnits); @@ -206,13 +203,12 @@ nsDeviceContextWin :: ComputeFullAreaUsingScreen ( nsRect* outRect ) nsCOMPtr screen; FindScreen ( getter_AddRefs(screen) ); if ( screen ) { - PRInt32 width, height; - screen->GetWidth ( &width ); - screen->GetHeight ( &height ); + PRInt32 x, y, width, height; + screen->GetRect ( &x, &y, &width, &height ); // convert to device units - outRect->y = 0; - outRect->x = 0; + outRect->y = NSToIntRound(y * mDevUnitsToAppUnits); + outRect->x = NSToIntRound(x * mDevUnitsToAppUnits); outRect->width = NSToIntRound(width * mDevUnitsToAppUnits); outRect->height = NSToIntRound(height * mDevUnitsToAppUnits); @@ -701,6 +697,23 @@ NS_IMETHODIMP nsDeviceContextWin :: GetDeviceSurfaceDimensions(PRInt32 &aWidth, } +NS_IMETHODIMP nsDeviceContextWin :: GetRect(nsRect &aRect) +{ + if ( mSpec ) + { + // we have a printer device + aRect.x = 0; + aRect.y = 0; + aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits); + aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits); + } + else + ComputeFullAreaUsingScreen ( &aRect ); + + return NS_OK; +} + + NS_IMETHODIMP nsDeviceContextWin :: GetClientRect(nsRect &aRect) { if ( mSpec ) diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.h b/mozilla/gfx/src/windows/nsDeviceContextWin.h index 4d2ad845e68..0e0c3f72253 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.h +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.h @@ -63,7 +63,7 @@ public: NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel); NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); - + NS_IMETHOD GetRect(nsRect &aRect); NS_IMETHOD GetClientRect(nsRect &aRect); NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, diff --git a/mozilla/gfx/src/windows/nsScreenWin.cpp b/mozilla/gfx/src/windows/nsScreenWin.cpp index 3718d92b152..0b2e50df0cf 100644 --- a/mozilla/gfx/src/windows/nsScreenWin.cpp +++ b/mozilla/gfx/src/windows/nsScreenWin.cpp @@ -82,8 +82,8 @@ nsScreenWin :: ~nsScreenWin() NS_IMPL_ISUPPORTS(nsScreenWin, NS_GET_IID(nsIScreen)) -NS_IMETHODIMP -nsScreenWin :: GetWidth(PRInt32 *aWidth) +NS_IMETHODIMP +nsScreenWin :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { BOOL success = FALSE; #if _MSC_VER >= 1200 @@ -92,21 +92,27 @@ nsScreenWin :: GetWidth(PRInt32 *aWidth) MONITORINFO info; info.cbSize = sizeof(MONITORINFO); success = (*proc)( (HMONITOR)mScreen, &info ); - if ( success ) - *aWidth = info.rcMonitor.right - info.rcMonitor.left; + if ( success ) { + *outLeft = info.rcMonitor.left; + *outTop = info.rcMonitor.top; + *outWidth = info.rcMonitor.right - info.rcMonitor.left; + *outHeight = info.rcMonitor.bottom - info.rcMonitor.top; + } } #endif - - if (!success) - *aWidth = ::GetDeviceCaps(mContext, HORZRES); + if (!success) { + *outTop = *outLeft = 0; + *outWidth = ::GetDeviceCaps(mContext, HORZRES); + *outHeight = ::GetDeviceCaps(mContext, VERTRES); + } return NS_OK; -} // GetWidth +} // GetRect -NS_IMETHODIMP -nsScreenWin :: GetHeight(PRInt32 *aHeight) +NS_IMETHODIMP +nsScreenWin :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { BOOL success = FALSE; #if _MSC_VER >= 1200 @@ -115,15 +121,27 @@ nsScreenWin :: GetHeight(PRInt32 *aHeight) MONITORINFO info; info.cbSize = sizeof(MONITORINFO); success = (*proc)( (HMONITOR)mScreen, &info ); - if ( success ) - *aHeight = info.rcMonitor.bottom - info.rcMonitor.top; + if ( success ) { + *outLeft = info.rcWork.left; + *outTop = info.rcWork.top; + *outWidth = info.rcWork.right - info.rcWork.left; + *outHeight = info.rcWork.bottom - info.rcWork.top; + } } #endif - if (!success) - *aHeight = ::GetDeviceCaps(mContext, VERTRES); - return NS_OK; + if (!success) { + RECT workArea; + ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0); + *outLeft = workArea.left; + *outTop = workArea.top; + *outWidth = workArea.right - workArea.left; + *outHeight = workArea.bottom - workArea.top; + } + + return NS_OK; + +} // GetAvailRect -} // GetHeight NS_IMETHODIMP @@ -144,98 +162,3 @@ nsScreenWin :: GetColorDepth(PRInt32 *aColorDepth) } // GetColorDepth -NS_IMETHODIMP -nsScreenWin :: GetAvailWidth(PRInt32 *aAvailWidth) -{ - BOOL success = FALSE; -#if _MSC_VER >= 1200 - if ( mScreen && mHasMultiMonitorAPIs ) { - GetMonitorInfoProc proc = (GetMonitorInfoProc)mGetMonitorInfoProc; - MONITORINFO info; - info.cbSize = sizeof(MONITORINFO); - success = (*proc)( (HMONITOR)mScreen, &info ); - if ( success ) - *aAvailWidth = info.rcWork.right - info.rcWork.left; - } -#endif - if (!success) { - RECT workArea; - ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0); - *aAvailWidth = workArea.right - workArea.left; - } - return NS_OK; - -} // GetAvailWidth - - -NS_IMETHODIMP -nsScreenWin :: GetAvailHeight(PRInt32 *aAvailHeight) -{ - BOOL success = FALSE; -#if _MSC_VER >= 1200 - if ( mScreen && mHasMultiMonitorAPIs ) { - GetMonitorInfoProc proc = (GetMonitorInfoProc)mGetMonitorInfoProc; - MONITORINFO info; - info.cbSize = sizeof(MONITORINFO); - success = (*proc)( (HMONITOR)mScreen, &info ); - if ( success ) - *aAvailHeight = info.rcWork.bottom - info.rcWork.top; - } -#endif - if (!success) { - RECT workArea; - ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0); - *aAvailHeight = workArea.bottom - workArea.top; - } - return NS_OK; - -} // GetAvailHeight - - -NS_IMETHODIMP -nsScreenWin :: GetAvailLeft(PRInt32 *aAvailLeft) -{ - BOOL success = FALSE; -#if _MSC_VER >= 1200 - if ( mScreen && mHasMultiMonitorAPIs ) { - GetMonitorInfoProc proc = (GetMonitorInfoProc)mGetMonitorInfoProc; - MONITORINFO info; - info.cbSize = sizeof(MONITORINFO); - success = (*proc)( (HMONITOR)mScreen, &info ); - if ( success ) - *aAvailLeft = info.rcWork.left; - } -#endif - if (!success) { - RECT workArea; - ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0); - *aAvailLeft = workArea.left; - } - return NS_OK; - -} // GetAvailLeft - - -NS_IMETHODIMP -nsScreenWin :: GetAvailTop(PRInt32 *aAvailTop) -{ - BOOL success = FALSE; -#if _MSC_VER >= 1200 - if ( mScreen && mHasMultiMonitorAPIs ) { - GetMonitorInfoProc proc = (GetMonitorInfoProc)mGetMonitorInfoProc; - MONITORINFO info; - info.cbSize = sizeof(MONITORINFO); - success = (*proc)( (HMONITOR)mScreen, &info ); - if ( success ) - *aAvailTop = info.rcWork.top; - } -#endif - if (!success) { - RECT workArea; - ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0); - *aAvailTop = workArea.top; - } - return NS_OK; - -} // GetAvailTop - diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 035ea8bcb77..c3b39487c23 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -537,28 +537,27 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext, AdjustPositionForAnchorAlign ( &xpos, &ypos, parentRect, aPopupAnchor, aPopupAlign, &readjustAboveBelow ); } + // Compute info about the screen dimensions. Because of multiple monitor systems, + // the left or top sides of the screen may be in negative space (main monitor is on the + // right, etc). We need to be sure to do the right thing. nsCOMPtr window(do_QueryInterface(scriptGlobalObject)); nsCOMPtr screen; window->GetScreen(getter_AddRefs(screen)); - PRInt32 screenWidth; - PRInt32 screenHeight; + PRInt32 screenWidth = 0, screenHeight = 0; + PRInt32 screenLeft = 0, screenTop = 0; + PRInt32 screenRight = 0, screenBottom = 0; if ( mMenuCanOverlapOSBar ) { + screen->GetLeft(&screenLeft); + screen->GetTop(&screenTop); screen->GetWidth(&screenWidth); screen->GetHeight(&screenHeight); } else { + screen->GetAvailLeft(&screenLeft); + screen->GetAvailTop(&screenTop); screen->GetAvailWidth(&screenWidth); screen->GetAvailHeight(&screenHeight); } - - // Compute info about the screen dimensions. Because of multiple monitor systems, - // the left or top sides of the screen may be in negative space (main monitor is on the - // right, etc). We need to be sure to do the right thing. - PRInt32 screenLeft; - PRInt32 screenTop; - screen->GetAvailLeft(&screenLeft); - screen->GetAvailTop(&screenTop); - PRInt32 screenRight, screenBottom; screenRight = screenLeft + screenWidth; screenBottom = screenTop + screenHeight; diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.cpp b/mozilla/xpfe/appshell/src/nsXULWindow.cpp index 8d4de6978f9..6cc20569bfc 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsXULWindow.cpp @@ -530,12 +530,8 @@ NS_IMETHODIMP nsXULWindow::Center(nsIXULWindow *aRelative, PRBool aScreen, PRBoo if (NS_FAILED(result)) return result; - if (aScreen) { - screen->GetAvailLeft(&left); - screen->GetAvailTop(&top); - screen->GetAvailWidth(&width); - screen->GetAvailHeight(&height); - } + if (aScreen) + screen->GetAvailRect(&left, &top, &width, &height); GetSize(&ourWidth, &ourHeight); SetPosition(left+(width-ourWidth)/2, top+(height-ourHeight)/(aAlert?3:2));