зеркало из https://github.com/mozilla/pjs.git
stop reentrant window zooming and switch to user state after sizing. bug 125711 r=pinkerton,scc a=asa
This commit is contained in:
Родитель
152d82faf2
Коммит
4319c44f5f
|
@ -193,11 +193,12 @@ nsMacWindow::nsMacWindow() : Inherited()
|
||||||
, mAcceptsActivation(PR_TRUE)
|
, mAcceptsActivation(PR_TRUE)
|
||||||
, mIsActive(PR_FALSE)
|
, mIsActive(PR_FALSE)
|
||||||
, mZoomOnShow(PR_FALSE)
|
, mZoomOnShow(PR_FALSE)
|
||||||
|
, mZooming(PR_FALSE)
|
||||||
|
, mResizeIsFromUs(PR_FALSE)
|
||||||
#if !TARGET_CARBON
|
#if !TARGET_CARBON
|
||||||
, mPhantomScrollbar(nsnull)
|
, mPhantomScrollbar(nsnull)
|
||||||
, mPhantomScrollbarData(nsnull)
|
, mPhantomScrollbarData(nsnull)
|
||||||
#endif
|
#endif
|
||||||
, mResizeIsFromUs(PR_FALSE)
|
|
||||||
{
|
{
|
||||||
mMacEventHandler.reset(new nsMacEventHandler(this));
|
mMacEventHandler.reset(new nsMacEventHandler(this));
|
||||||
WIDGET_SET_CLASSNAME("nsMacWindow");
|
WIDGET_SET_CLASSNAME("nsMacWindow");
|
||||||
|
@ -1188,8 +1189,14 @@ NS_METHOD nsMacWindow::SetSizeMode(PRInt32 aMode)
|
||||||
if (aMode == nsSizeMode_Minimized) // unlikely on the Mac
|
if (aMode == nsSizeMode_Minimized) // unlikely on the Mac
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
|
// resize during zoom may attempt to unzoom us. here's where we put a stop to that.
|
||||||
|
if (mZooming)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
// already done? it's bad to rezoom a window, so do nothing
|
// already done? it's bad to rezoom a window, so do nothing
|
||||||
rv = nsBaseWidget::GetSizeMode(¤tMode);
|
rv = nsBaseWidget::GetSizeMode(¤tMode);
|
||||||
|
if (currentMode == nsSizeMode_Normal && !mVisible && mZoomOnShow)
|
||||||
|
currentMode = nsSizeMode_Maximized;
|
||||||
if (NS_SUCCEEDED(rv) && currentMode == aMode)
|
if (NS_SUCCEEDED(rv) && currentMode == aMode)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
|
@ -1197,10 +1204,10 @@ NS_METHOD nsMacWindow::SetSizeMode(PRInt32 aMode)
|
||||||
/* zooming on the Mac doesn't seem to work until the window is visible.
|
/* zooming on the Mac doesn't seem to work until the window is visible.
|
||||||
the rest of the app is structured to zoom before the window is visible
|
the rest of the app is structured to zoom before the window is visible
|
||||||
to avoid flashing. here's where we defeat that. */
|
to avoid flashing. here's where we defeat that. */
|
||||||
if (aMode == nsSizeMode_Maximized)
|
mZoomOnShow = aMode == nsSizeMode_Maximized;
|
||||||
mZoomOnShow = PR_TRUE;
|
|
||||||
} else {
|
} else {
|
||||||
Rect macRect;
|
Rect macRect;
|
||||||
|
mZooming = PR_TRUE;
|
||||||
rv = nsBaseWidget::SetSizeMode(aMode);
|
rv = nsBaseWidget::SetSizeMode(aMode);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
if (aMode == nsSizeMode_Maximized) {
|
if (aMode == nsSizeMode_Maximized) {
|
||||||
|
@ -1211,12 +1218,47 @@ NS_METHOD nsMacWindow::SetSizeMode(PRInt32 aMode)
|
||||||
::GetWindowPortBounds(mWindowPtr, &macRect);
|
::GetWindowPortBounds(mWindowPtr, &macRect);
|
||||||
Resize(macRect.right - macRect.left, macRect.bottom - macRect.top, PR_FALSE);
|
Resize(macRect.right - macRect.left, macRect.bottom - macRect.top, PR_FALSE);
|
||||||
}
|
}
|
||||||
|
mZooming = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// we're resizing. if we happen to be zoomed ("standard" state),
|
||||||
|
// switch to the user state without changing the window size.
|
||||||
|
void
|
||||||
|
nsMacWindow::UserStateForResize()
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
PRInt32 currentMode;
|
||||||
|
|
||||||
|
// but not if we're currently zooming
|
||||||
|
if (mZooming)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// nothing to do if we're already in the user state
|
||||||
|
rv = nsBaseWidget::GetSizeMode(¤tMode);
|
||||||
|
if (NS_SUCCEEDED(rv) && currentMode == nsSizeMode_Normal)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// we've just finished sizing, so make our current size our user state,
|
||||||
|
// and switch to the user state
|
||||||
|
StPortSetter portState(mWindowPtr);
|
||||||
|
StOriginSetter originState(mWindowPtr);
|
||||||
|
Rect bounds;
|
||||||
|
|
||||||
|
::GetWindowPortBounds(mWindowPtr, &bounds);
|
||||||
|
::LocalToGlobal((Point *)&bounds.top);
|
||||||
|
::LocalToGlobal((Point *)&bounds.bottom);
|
||||||
|
::SetWindowUserState(mWindowPtr, &bounds);
|
||||||
|
::ZoomWindow(mWindowPtr, inZoomIn, false);
|
||||||
|
|
||||||
|
// finally, reset our internal state to match
|
||||||
|
nsBaseWidget::SetSizeMode(nsSizeMode_Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// CalculateAndSetZoomedSize
|
// CalculateAndSetZoomedSize
|
||||||
//
|
//
|
||||||
|
|
|
@ -117,7 +117,9 @@ public:
|
||||||
NS_IMETHOD GetScreenBounds(nsRect &aRect);
|
NS_IMETHOD GetScreenBounds(nsRect &aRect);
|
||||||
virtual PRBool OnPaint(nsPaintEvent &event);
|
virtual PRBool OnPaint(nsPaintEvent &event);
|
||||||
|
|
||||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||||
|
|
||||||
|
void UserStateForResize();
|
||||||
|
|
||||||
// nsIKBStateControl interface
|
// nsIKBStateControl interface
|
||||||
NS_IMETHOD ResetInputState();
|
NS_IMETHOD ResetInputState();
|
||||||
|
@ -148,16 +150,17 @@ protected:
|
||||||
EventRef inEvent, void* userData ) ;
|
EventRef inEvent, void* userData ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRBool mWindowMadeHere; // true if we created the window
|
PRPackedBool mWindowMadeHere; // true if we created the window
|
||||||
PRBool mIsDialog; // true if the window is a dialog
|
PRPackedBool mIsDialog; // true if the window is a dialog
|
||||||
PRBool mIsSheet; // true if the window is a sheet (Mac OS X)
|
PRPackedBool mIsSheet; // true if the window is a sheet (Mac OS X)
|
||||||
PRBool 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
|
||||||
auto_ptr<nsMacEventHandler> mMacEventHandler;
|
PRPackedBool mAcceptsActivation;
|
||||||
|
PRPackedBool mIsActive;
|
||||||
|
PRPackedBool mZoomOnShow;
|
||||||
|
PRPackedBool mZooming;
|
||||||
|
PRPackedBool mResizeIsFromUs; // we originated the resize, prevent infinite recursion
|
||||||
|
auto_ptr<nsMacEventHandler> mMacEventHandler;
|
||||||
nsIWidget *mOffsetParent;
|
nsIWidget *mOffsetParent;
|
||||||
PRBool mAcceptsActivation;
|
|
||||||
PRBool mIsActive;
|
|
||||||
PRBool mZoomOnShow;
|
|
||||||
PRBool mResizeIsFromUs; // we originated the resize, prevent infinite recursion
|
|
||||||
|
|
||||||
#if !TARGET_CARBON
|
#if !TARGET_CARBON
|
||||||
ControlHandle mPhantomScrollbar; // a native scrollbar for the scrollwheel
|
ControlHandle mPhantomScrollbar; // a native scrollbar for the scrollwheel
|
||||||
|
|
Загрузка…
Ссылка в новой задаче