зеркало из https://github.com/mozilla/pjs.git
notify container of position upon return to user state and softwire window border widths. bug 193295 r=pinkerton,sfraser a=asa
This commit is contained in:
Родитель
287c3c5289
Коммит
cb3479a070
|
@ -90,17 +90,15 @@ long CallSystemWDEF ( short inCode, WindowPtr inWindow, short inMessage, long in
|
||||||
|
|
||||||
#define kWindowPositionSlop 20
|
#define kWindowPositionSlop 20
|
||||||
|
|
||||||
// ¥¥¥ TODO: these should come from the system, not be hard-coded. What if I'm running
|
// These are only initial guesses. Real values are filled in
|
||||||
// an elaborate theme with wide window borders?
|
// after window creation.
|
||||||
const short kWindowTitleBarHeight = 22;
|
const short kWindowTitleBarHeight = 22;
|
||||||
const short kWindowMarginWidth = 6;
|
const short kWindowMarginWidth = 6;
|
||||||
const short kDialogTitleBarHeight = 26;
|
const short kDialogTitleBarHeight = 26;
|
||||||
const short kDialogMarginWidth = 6;
|
const short kDialogMarginWidth = 6;
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
|
|
||||||
pascal OSErr
|
pascal OSErr
|
||||||
nsMacWindow :: DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr theWindow,
|
nsMacWindow :: DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr theWindow,
|
||||||
void *handlerRefCon, DragReference theDrag)
|
void *handlerRefCon, DragReference theDrag)
|
||||||
|
@ -112,7 +110,6 @@ nsMacWindow :: DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr t
|
||||||
if ( !theWindow || !windowEventSink )
|
if ( !theWindow || !windowEventSink )
|
||||||
return dragNotAcceptedErr;
|
return dragNotAcceptedErr;
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
switch ( theMessage ) {
|
switch ( theMessage ) {
|
||||||
|
|
||||||
case kDragTrackingEnterHandler:
|
case kDragTrackingEnterHandler:
|
||||||
|
@ -188,15 +185,14 @@ NS_IMPL_ISUPPORTS_INHERITED4(nsMacWindow, Inherited, nsIEventSink, nsPIWidgetMac
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsMacWindow::nsMacWindow() : Inherited()
|
nsMacWindow::nsMacWindow() : Inherited()
|
||||||
, mWindowMadeHere(PR_FALSE)
|
, mWindowMadeHere(PR_FALSE)
|
||||||
, mIsDialog(PR_FALSE)
|
|
||||||
, mIsSheet(PR_FALSE)
|
, mIsSheet(PR_FALSE)
|
||||||
, mIgnoreDeactivate(PR_FALSE)
|
, mIgnoreDeactivate(PR_FALSE)
|
||||||
, mMacEventHandler(nsnull)
|
|
||||||
, mAcceptsActivation(PR_TRUE)
|
, mAcceptsActivation(PR_TRUE)
|
||||||
, mIsActive(PR_FALSE)
|
, mIsActive(PR_FALSE)
|
||||||
, mZoomOnShow(PR_FALSE)
|
, mZoomOnShow(PR_FALSE)
|
||||||
, mZooming(PR_FALSE)
|
, mZooming(PR_FALSE)
|
||||||
, mResizeIsFromUs(PR_FALSE)
|
, mResizeIsFromUs(PR_FALSE)
|
||||||
|
, mMacEventHandler(nsnull)
|
||||||
#if !TARGET_CARBON
|
#if !TARGET_CARBON
|
||||||
, mPhantomScrollbar(nsnull)
|
, mPhantomScrollbar(nsnull)
|
||||||
, mPhantomScrollbarData(nsnull)
|
, mPhantomScrollbarData(nsnull)
|
||||||
|
@ -208,6 +204,8 @@ nsMacWindow::nsMacWindow() : Inherited()
|
||||||
// create handlers for drag&drop
|
// create handlers for drag&drop
|
||||||
mDragTrackingHandlerUPP = NewDragTrackingHandlerUPP(DragTrackingHandler);
|
mDragTrackingHandlerUPP = NewDragTrackingHandlerUPP(DragTrackingHandler);
|
||||||
mDragReceiveHandlerUPP = NewDragReceiveHandlerUPP(DragReceiveHandler);
|
mDragReceiveHandlerUPP = NewDragReceiveHandlerUPP(DragReceiveHandler);
|
||||||
|
mBoundsOffset.v = kWindowTitleBarHeight; // initial guesses
|
||||||
|
mBoundsOffset.h = kWindowMarginWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,7 +290,7 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent,
|
||||||
mWindowType = eWindowType_dialog;
|
mWindowType = eWindowType_dialog;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mWindowType = (mIsDialog ? eWindowType_dialog : eWindowType_toplevel);
|
mWindowType = eWindowType_toplevel;
|
||||||
|
|
||||||
short wDefProcID = kWindowDocumentProc;
|
short wDefProcID = kWindowDocumentProc;
|
||||||
Boolean goAwayFlag = false;
|
Boolean goAwayFlag = false;
|
||||||
|
@ -469,6 +467,12 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent,
|
||||||
}
|
}
|
||||||
mWindowPtr = ::NewCWindow(nil, &wRect, "\p", false, wDefProcID, (WindowRef)-1, goAwayFlag, (long)nsnull);
|
mWindowPtr = ::NewCWindow(nil, &wRect, "\p", false, wDefProcID, (WindowRef)-1, goAwayFlag, (long)nsnull);
|
||||||
mWindowMadeHere = PR_TRUE;
|
mWindowMadeHere = PR_TRUE;
|
||||||
|
|
||||||
|
Rect content, structure;
|
||||||
|
::GetWindowBounds(mWindowPtr, kWindowStructureRgn, &structure);
|
||||||
|
::GetWindowBounds(mWindowPtr, kWindowContentRgn, &content);
|
||||||
|
mBoundsOffset.v = content.top - structure.top;
|
||||||
|
mBoundsOffset.h = content.left - structure.left;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1107,7 +1111,6 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
|
||||||
StPortSetter setOurPortForLocalToGlobal ( mWindowPtr );
|
StPortSetter setOurPortForLocalToGlobal ( mWindowPtr );
|
||||||
|
|
||||||
if (eWindowType_popup == mWindowType) {
|
if (eWindowType_popup == mWindowType) {
|
||||||
PRInt32 xOffset=0,yOffset=0;
|
|
||||||
nsRect localRect,globalRect;
|
nsRect localRect,globalRect;
|
||||||
|
|
||||||
// convert to screen coordinates
|
// convert to screen coordinates
|
||||||
|
@ -1150,13 +1153,8 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
|
||||||
Rect portBounds;
|
Rect portBounds;
|
||||||
::GetWindowPortBounds(mWindowPtr, &portBounds);
|
::GetWindowPortBounds(mWindowPtr, &portBounds);
|
||||||
|
|
||||||
if (mIsDialog) {
|
aX += mBoundsOffset.h;
|
||||||
aX += kDialogMarginWidth;
|
aY += mBoundsOffset.v;
|
||||||
aY += kDialogTitleBarHeight;
|
|
||||||
} else {
|
|
||||||
aX += kWindowMarginWidth;
|
|
||||||
aY += kWindowTitleBarHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIScreenManager> screenmgr = do_GetService(sScreenManagerContractID);
|
nsCOMPtr<nsIScreenManager> screenmgr = do_GetService(sScreenManagerContractID);
|
||||||
if (screenmgr) {
|
if (screenmgr) {
|
||||||
|
@ -1299,6 +1297,9 @@ nsMacWindow::UserStateForResize()
|
||||||
|
|
||||||
// finally, reset our internal state to match
|
// finally, reset our internal state to match
|
||||||
nsBaseWidget::SetSizeMode(nsSizeMode_Normal);
|
nsBaseWidget::SetSizeMode(nsSizeMode_Normal);
|
||||||
|
// Tell container window we've moved. We stopped reporting move events
|
||||||
|
// when we were in the StandardState.
|
||||||
|
ReportMoveEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1457,14 +1458,7 @@ void nsMacWindow::MoveToGlobalPoint(PRInt32 aX, PRInt32 aY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsDialog) {
|
Move(aX-mBoundsOffset.h, aY-mBoundsOffset.v);
|
||||||
aX -= kDialogMarginWidth;
|
|
||||||
aY -= kDialogTitleBarHeight;
|
|
||||||
} else {
|
|
||||||
aX -= kWindowMarginWidth;
|
|
||||||
aY -= kWindowTitleBarHeight;
|
|
||||||
}
|
|
||||||
Move(aX, aY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -1558,10 +1552,7 @@ NS_IMETHODIMP nsMacWindow::GetScreenBounds(nsRect &aRect) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsDialog)
|
aRect.MoveBy(-mBoundsOffset.h, -mBoundsOffset.v-yAdjust);
|
||||||
aRect.MoveBy(-kDialogMarginWidth, -kDialogTitleBarHeight-yAdjust);
|
|
||||||
else
|
|
||||||
aRect.MoveBy(-kWindowMarginWidth, -kWindowTitleBarHeight-yAdjust);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,6 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRPackedBool mWindowMadeHere; // true if we created the window
|
PRPackedBool mWindowMadeHere; // true if we created the window
|
||||||
PRPackedBool mIsDialog; // true if the window is a dialog
|
|
||||||
PRPackedBool mIsSheet; // true if the window is a sheet (Mac OS X)
|
PRPackedBool mIsSheet; // true if the window is a sheet (Mac OS X)
|
||||||
PRPackedBool mIgnoreDeactivate; // true if this window has a (Mac OS X) sheet opening
|
PRPackedBool mIgnoreDeactivate; // true if this window has a (Mac OS X) sheet opening
|
||||||
PRPackedBool mAcceptsActivation;
|
PRPackedBool mAcceptsActivation;
|
||||||
|
@ -162,6 +161,7 @@ protected:
|
||||||
PRPackedBool mZoomOnShow;
|
PRPackedBool mZoomOnShow;
|
||||||
PRPackedBool mZooming;
|
PRPackedBool mZooming;
|
||||||
PRPackedBool mResizeIsFromUs; // we originated the resize, prevent infinite recursion
|
PRPackedBool mResizeIsFromUs; // we originated the resize, prevent infinite recursion
|
||||||
|
Point mBoundsOffset; // offset from window structure to content
|
||||||
auto_ptr<nsMacEventHandler> mMacEventHandler;
|
auto_ptr<nsMacEventHandler> mMacEventHandler;
|
||||||
nsIWidget *mOffsetParent;
|
nsIWidget *mOffsetParent;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче