Moving Screen API away from individual attributes for performance reasons (stage 1). Fixes bugs on win32 with xul popups where taskbar is not at bottom of screen.

git-svn-id: svn://10.0.0.236/trunk@66664 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pinkerton%netscape.com 2000-04-21 06:55:13 +00:00
parent eb58f946a3
commit 28e12d5484
16 changed files with 192 additions and 273 deletions

View File

@ -87,19 +87,16 @@ ScreenImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
NS_IMETHODIMP
ScreenImpl::GetTop(PRInt32* aTop)
{
/*
*** for now...
nsCOMPtr<nsIDeviceContext> context ( getter_AddRefs(GetDeviceContext() );
nsCOMPtr<nsIDeviceContext> 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<nsIDeviceContext> context ( getter_AddRefs(GetDeviceContext() );
nsCOMPtr<nsIDeviceContext> 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;
}

View File

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

View File

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

View File

@ -95,10 +95,8 @@ NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
nsCOMPtr<nsIScreen> 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)
{

View File

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

View File

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

View File

@ -523,9 +523,8 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 & outWidth,
nsCOMPtr<nsIScreen> 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<nsIScreen> 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<nsIScreen> 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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<nsIScreen> 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 )

View File

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

View File

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

View File

@ -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<nsIDOMWindow> window(do_QueryInterface(scriptGlobalObject));
nsCOMPtr<nsIDOMScreen> 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;

View File

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