Skip to content

Commit

Permalink
Bug 429954 - Windows that open already maximized will un-maximize to …
Browse files Browse the repository at this point in the history
…a teeny-tiny window in upper left.

Disallow zooming of windows that already have the zoomed size but have never been zoomed, because otherwise bad things happen to the window size. Moreover, reflect the window's zoom state in its size mode as nsSizeMode_Maximized.

r=josh

--HG--
extra : rebase_source : 46b161efcc60cefc9d9eb019d48f595c26eed6af
  • Loading branch information
mstange committed Aug 12, 2009
1 parent 8654554 commit 9966c9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions widget/src/cocoa/nsCocoaWindow.h
Expand Up @@ -103,6 +103,7 @@ typedef struct _nsCocoaWindowList {
// NS_DEACTIVATE to Gecko for toplevel widgets. Starts out
// PR_FALSE.
PRBool mToplevelActiveState;
BOOL mHasEverBeenZoomed;
}
+ (void)paintMenubarForWindow:(NSWindow*)aWindow;
- (id)initWithGeckoWindow:(nsCocoaWindow*)geckoWind;
Expand Down Expand Up @@ -238,8 +239,7 @@ class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
virtual void SetShowsToolbarButton(PRBool aShow);
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, PRBool aActive);

// dispatch an NS_SIZEMODE event on miniaturize or deminiaturize
void DispatchSizeModeEvent(nsSizeMode aSizeMode);
void DispatchSizeModeEvent();

virtual gfxASurface* GetThebesSurface();

Expand Down
21 changes: 17 additions & 4 deletions widget/src/cocoa/nsCocoaWindow.mm
Expand Up @@ -1272,10 +1272,11 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle)
}

void
nsCocoaWindow::DispatchSizeModeEvent(nsSizeMode aSizeMode)
nsCocoaWindow::DispatchSizeModeEvent()
{
nsSizeModeEvent event(PR_TRUE, NS_SIZEMODE, this);
event.mSizeMode = aSizeMode;
event.mSizeMode = [mWindow isMiniaturized] ? nsSizeMode_Minimized :
[mWindow isZoomed] ? nsSizeMode_Maximized : nsSizeMode_Normal;
event.time = PR_IntervalNow();

nsEventStatus status = nsEventStatus_eIgnore;
Expand Down Expand Up @@ -1583,6 +1584,7 @@ - (id)initWithGeckoWindow:(nsCocoaWindow*)geckoWind
[super init];
mGeckoWindow = geckoWind;
mToplevelActiveState = PR_FALSE;
mHasEverBeenZoomed = PR_FALSE;
return self;

NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
Expand All @@ -1600,6 +1602,8 @@ - (void)windowDidResize:(NSNotification *)aNotification
if (!mGeckoWindow || mGeckoWindow->IsResizing())
return;

// Resizing might have changed our zoom state.
mGeckoWindow->DispatchSizeModeEvent();
mGeckoWindow->ReportSizeEvent();
}

Expand Down Expand Up @@ -1700,13 +1704,22 @@ - (void)windowWillMiniaturize:(NSNotification *)aNotification
- (void)windowDidMiniaturize:(NSNotification *)aNotification
{
if (mGeckoWindow)
mGeckoWindow->DispatchSizeModeEvent(nsSizeMode_Minimized);
mGeckoWindow->DispatchSizeModeEvent();
}

- (void)windowDidDeminiaturize:(NSNotification *)aNotification
{
if (mGeckoWindow)
mGeckoWindow->DispatchSizeModeEvent(nsSizeMode_Normal);
mGeckoWindow->DispatchSizeModeEvent();
}

- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)proposedFrame
{
if (!mHasEverBeenZoomed && [window isZoomed])
return NO; // See bug 429954.

mHasEverBeenZoomed = YES;
return YES;
}

- (void)sendFocusEvent:(PRUint32)eventType
Expand Down

0 comments on commit 9966c9d

Please sign in to comment.