From b22831318576d374366cad3ea4d958039f85f18c Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Thu, 26 Aug 2010 23:44:01 -0500 Subject: [PATCH] Bug 575195 - Send size mode events to dom from web shell window, and insure new windows open on top of full screen windows normally. r=neil. --- xpfe/appshell/src/nsAppShellService.cpp | 45 +++++++++++++++++++++++++++++++++ xpfe/appshell/src/nsWebShellWindow.cpp | 9 +++++++ xpfe/appshell/src/nsXULWindow.cpp | 4 ++- xpfe/appshell/src/nsXULWindow.h | 2 ++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index dc4cbd4375..5c680b5afd 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -288,6 +288,43 @@ nsAppShellService::CalculateWindowZLevel(nsIXULWindow *aParent, } /* + * Checks to see if any existing window is currently in fullscreen mode. + */ +static PRBool +CheckForFullscreenWindow() +{ + nsCOMPtr wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); + if (!wm) + return PR_FALSE; + + nsCOMPtr windowList; + wm->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowList)); + if (!windowList) + return PR_FALSE; + + for (;;) { + PRBool more = PR_FALSE; + windowList->HasMoreElements(&more); + if (!more) + return PR_FALSE; + + nsCOMPtr supportsWindow; + windowList->GetNext(getter_AddRefs(supportsWindow)); + nsCOMPtr baseWin(do_QueryInterface(supportsWindow)); + if (baseWin) { + PRInt32 sizeMode; + nsCOMPtr widget; + baseWin->GetMainWidget(getter_AddRefs(widget)); + if (widget && NS_SUCCEEDED(widget->GetSizeMode(&sizeMode)) && + sizeMode == nsSizeMode_Fullscreen) { + return PR_TRUE; + } + } + } + return PR_FALSE; +} + +/* * Just do the window-making part of CreateTopLevelWindow */ nsresult @@ -310,6 +347,14 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, nsRefPtr window = new nsWebShellWindow(aChromeMask); NS_ENSURE_TRUE(window, NS_ERROR_OUT_OF_MEMORY); +#ifdef XP_WIN + // If the parent is currently fullscreen, tell the child to ignore persisted + // full screen states. This way new browser windows open on top of fullscreen + // windows normally. + if (window && CheckForFullscreenWindow()) + window->IgnoreXULSizeMode(PR_TRUE); +#endif + nsWidgetInitData widgetInitData; if (aIsHiddenWindow) diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 1f877e05d4..7edc2cfbcb 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -375,6 +375,15 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent) eventWindow->SetPersistenceTimer(PAD_MISC); result = nsEventStatus_eConsumeDoDefault; + // min, max, and normal are all the same to apps, but for + // fullscreen we need to let them know so they can update + // their ui. + if (modeEvent->mSizeMode == nsSizeMode_Fullscreen) { + nsCOMPtr ourWindow = do_GetInterface(docShell); + if (ourWindow) + ourWindow->SetFullScreen(PR_TRUE); + } + // Note the current implementation of SetSizeMode just stores // the new state; it doesn't actually resize. So here we store // the state and pass the event on to the OS. The day is coming diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index fb648f039e..b0f4691633 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -154,6 +154,7 @@ nsXULWindow::nsXULWindow(PRUint32 aChromeFlags) mPersistentAttributesDirty(0), mPersistentAttributesMask(0), mChromeFlags(aChromeFlags), + mIgnoreXULSizeMode(PR_FALSE), // best guess till we have a widget mAppPerDev(nsPresContext::AppUnitsPerCSSPixel()) { @@ -1219,7 +1220,8 @@ PRBool nsXULWindow::LoadMiscPersistentAttributesFromXUL() if (stateString.Equals(SIZEMODE_MINIMIZED)) sizeMode = nsSizeMode_Minimized; */ - if (stateString.Equals(SIZEMODE_MAXIMIZED) || stateString.Equals(SIZEMODE_FULLSCREEN)) { + if (!mIgnoreXULSizeMode && + (stateString.Equals(SIZEMODE_MAXIMIZED) || stateString.Equals(SIZEMODE_FULLSCREEN))) { /* Honor request to maximize only if the window is sizable. An unsizable, unmaximizable, yet maximized window confuses Windows OS and is something of a travesty, anyway. */ diff --git a/xpfe/appshell/src/nsXULWindow.h b/xpfe/appshell/src/nsXULWindow.h index 8084aadd84..9d690c0d93 100644 --- a/xpfe/appshell/src/nsXULWindow.h +++ b/xpfe/appshell/src/nsXULWindow.h @@ -96,6 +96,7 @@ public: void LockUntilChromeLoad() { mLockedUntilChromeLoad = PR_TRUE; } PRBool IsLocked() const { return mLockedUntilChromeLoad; } + void IgnoreXULSizeMode(PRBool aEnable) { mIgnoreXULSizeMode = aEnable; } protected: enum persistentAttributes { @@ -172,6 +173,7 @@ protected: PRPackedBool mIgnoreXULSize; PRPackedBool mIgnoreXULPosition; PRPackedBool mChromeFlagsFrozen; + PRPackedBool mIgnoreXULSizeMode; PRUint32 mContextFlags; PRUint32 mBlurSuppressionLevel; PRUint32 mPersistentAttributesDirty; // persistentAttributes -- 2.11.4.GIT