From a28fb84e287a77318be04632be891677924f864c Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Sat, 8 Jan 2000 04:28:29 +0000 Subject: [PATCH] new method MoveToGlobalPoint. part of bug 23395. --- widget/src/mac/nsMacWindow.cpp | 29 +++++++++++++++++++++++++++++ widget/src/mac/nsMacWindow.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/widget/src/mac/nsMacWindow.cpp b/widget/src/mac/nsMacWindow.cpp index 017a89c1d5a8..b4f81a86b489 100644 --- a/widget/src/mac/nsMacWindow.cpp +++ b/widget/src/mac/nsMacWindow.cpp @@ -652,6 +652,35 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY) return NS_OK; } +//------------------------------------------------------------------------- +// +// Resize this window to a point given in global (screen) coordinates. This +// differs from simple Move(): that method makes JavaScript place windows +// like other browsers: it puts the top-left corner of the outer edge of the +// window border at the given coordinates, offset from the menubar. +// MoveToGlobalPoint expects the top-left corner of the portrect, which +// is inside the border, and is not offset by the menubar height. +// +//------------------------------------------------------------------------- +void nsMacWindow::MoveToGlobalPoint(PRInt32 aX, PRInt32 aY) +{ +#if TARGET_CARBON + Rect screenRect; + ::GetRegionBounds(::GetGrayRgn(), &screenRect); +#else + Rect screenRect = (**::GetGrayRgn()).rgnBBox; +#endif + + if (mIsDialog) { + aX -= kDialogMarginWidth; + aY -= kDialogTitleBarHeight; + } else { + aX -= kWindowMarginWidth; + aY -= kWindowTitleBarHeight; + } + Move(aX - screenRect.left, aY - screenRect.top); +} + //------------------------------------------------------------------------- // // Resize this window diff --git a/widget/src/mac/nsMacWindow.h b/widget/src/mac/nsMacWindow.h index 79bcab74e576..476cd9c08f28 100644 --- a/widget/src/mac/nsMacWindow.h +++ b/widget/src/mac/nsMacWindow.h @@ -97,6 +97,8 @@ public: NS_IMETHOD ResetInputState(); NS_IMETHOD PasswordFieldInit(); + void MoveToGlobalPoint(PRInt32 aX, PRInt32 aY); + protected: pascal static OSErr DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr theWindow,