Bug 484488 - MakeFullWindow support for windows mobile. r=olli.pettay, sr=vlad

This commit is contained in:
Doug Turner
2009-07-08 09:13:13 -07:00
parent fa6c0842b6
commit 201671556d
13 changed files with 99 additions and 85 deletions
@@ -2582,6 +2582,7 @@ SessionStoreService.prototype = {
_getWindowDimension: function sss_getWindowDimension(aWindow, aAttribute) {
if (aAttribute == "sizemode") {
switch (aWindow.windowState) {
case aWindow.STATE_FULLSCREEN:
case aWindow.STATE_MAXIMIZED:
return "maximized";
case aWindow.STATE_MINIMIZED:
+4 -49
View File
@@ -149,7 +149,6 @@
#include "nsIContentViewer.h"
#include "nsDOMClassInfo.h"
#include "nsIJSNativeInitializer.h"
#include "nsIFullScreen.h"
#include "nsIScriptError.h"
#include "nsIScriptEventManager.h" // For GetInterface()
#include "nsIConsoleService.h"
@@ -2114,29 +2113,6 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
langCtx->ClearScope(mScriptGlobals[NS_STID_INDEX(lang_id)], PR_TRUE);
}
// if we are closing the window while in full screen mode, be sure
// to restore os chrome
if (mFullScreen) {
// only restore OS chrome if the closing window was active
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
nsCOMPtr<nsIDOMWindow> activeWindow;
fm->GetActiveWindow(getter_AddRefs(activeWindow));
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
if (rootWin == activeWindow) {
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen)
fullScreen->ShowAllOSChrome();
}
}
}
ClearControllers();
mChromeEventHandler = nsnull; // force release now
@@ -3836,8 +3812,6 @@ nsGlobalWindow::SetFullScreen(PRBool aFullScreen)
// dispatch a "fullscreen" DOM event so that XUL apps can
// respond visually if we are kicked into full screen mode
if (!DispatchCustomEvent("fullscreen")) {
// event handlers can prevent us from going into full-screen mode
return NS_OK;
}
@@ -6592,20 +6566,6 @@ nsGlobalWindow::GetLocation(nsIDOMLocation ** aLocation)
void
nsGlobalWindow::ActivateOrDeactivate(PRBool aActivate)
{
// if the window is deactivated while in full screen mode,
// restore OS chrome, and hide it again upon re-activation
nsGlobalWindow* outer = GetOuterWindowInternal();
if (outer && outer->mFullScreen) {
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen) {
if (aActivate)
fullScreen->HideAllOSChrome();
else
fullScreen->ShowAllOSChrome();
}
}
// Set / unset the "active" attribute on the documentElement
// of the top level window
nsCOMPtr<nsIWidget> mainWidget = GetMainWidget();
@@ -8801,6 +8761,9 @@ nsGlobalChromeWindow::GetWindowState(PRUint16* aWindowState)
case nsSizeMode_Maximized:
*aWindowState = nsIDOMChromeWindow::STATE_MAXIMIZED;
break;
case nsSizeMode_Fullscreen:
*aWindowState = nsIDOMChromeWindow::STATE_FULLSCREEN;
break;
case nsSizeMode_Normal:
*aWindowState = nsIDOMChromeWindow::STATE_NORMAL;
break;
@@ -8831,16 +8794,8 @@ nsGlobalChromeWindow::Minimize()
nsCOMPtr<nsIWidget> widget = GetMainWidget();
nsresult rv = NS_OK;
if (widget) {
// minimize doesn't send deactivate events on windows,
// so we need to forcefully restore the os chrome
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen)
fullScreen->ShowAllOSChrome();
if (widget)
rv = widget->SetSizeMode(nsSizeMode_Minimized);
}
return rv;
}
+2 -1
View File
@@ -40,12 +40,13 @@
interface nsIBrowserDOMWindow;
[scriptable, uuid(77a20f5a-68ad-41d3-97ac-6ff721512908)]
[scriptable, uuid(09A5E148-2A77-4739-9DD9-3D552F5390EE)]
interface nsIDOMChromeWindow : nsISupports
{
const unsigned short STATE_MAXIMIZED = 1;
const unsigned short STATE_MINIMIZED = 2;
const unsigned short STATE_NORMAL = 3;
const unsigned short STATE_FULLSCREEN = 4;
readonly attribute unsigned short windowState;
+6 -1
View File
@@ -44,7 +44,12 @@ relativesrcdir = dom/tests/mochitest/chrome
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = test_domstorage.xul \
_TEST_FILES = \
test_fullscreen.xul \
fullscreen.xul \
test_fullscreen_preventdefault.xul \
fullscreen_preventdefault.xul \
test_domstorage.xul \
domstorage_global.xul \
domstorage_global.js \
test_focus.xul \
@@ -17,9 +17,16 @@ SimpleTest.waitForExplicitFinish();
newwindow = window.open("fullscreen.xul", "_blank","chrome,resizable=yes");
function done(fullScreen)
function done()
{
ok(fullScreen, "window.fullScreen is true.");
// because we are cancelling the fullscreen event, it
// takes a bit for the fullScreen property to be set
setTimeout("complete()", 0);
}
function complete()
{
ok(newwindow.fullScreen, "window.fullScreen is true.");
newwindow.close();
SimpleTest.finish();
}
-1
View File
@@ -97,7 +97,6 @@ XPIDLSRCS = \
nsIRollupListener.idl \
nsIBaseWindow.idl \
nsIBidiKeyboard.idl \
nsIFullScreen.idl \
nsIScreen.idl \
nsIScreenManager.idl \
nsIPrintSession.idl \
+2 -1
View File
@@ -63,7 +63,8 @@ enum nsEventStatus {
enum nsSizeMode {
nsSizeMode_Normal = 0,
nsSizeMode_Minimized,
nsSizeMode_Maximized
nsSizeMode_Maximized,
nsSizeMode_Fullscreen
};
class nsEvent;
+39 -2
View File
@@ -1140,12 +1140,22 @@ NS_METHOD nsWindow::Show(PRBool bState)
if (!wasVisible && mWindowType == eWindowType_toplevel) {
switch (mSizeMode) {
#ifdef WINCE
case nsSizeMode_Fullscreen:
::SetForegroundWindow(mWnd);
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
MakeFullScreen(TRUE);
break;
case nsSizeMode_Maximized :
::SetForegroundWindow(mWnd);
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
// use default for nsSizeMode_Minimized on Windows CE
#else
case nsSizeMode_Fullscreen:
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
case nsSizeMode_Maximized :
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
@@ -1497,6 +1507,10 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) {
int mode;
switch (aMode) {
case nsSizeMode_Fullscreen :
mode = SW_MAXIMIZE;
break;
case nsSizeMode_Maximized :
mode = SW_MAXIMIZE;
break;
@@ -2303,6 +2317,27 @@ NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous)
return NS_OK;
}
NS_IMETHODIMP
nsWindow::MakeFullScreen(PRBool aFullScreen)
{
#if WINCE
RECT rc;
if (aFullScreen) {
SetForegroundWindow(mWnd);
SHFullScreen(mWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
else {
SHFullScreen(mWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE);
}
MoveWindow(mWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
return NS_OK;
#else
return nsBaseWidget::MakeFullScreen(aFullScreen);
#endif
}
/**************************************************************
*
* SECTION: nsIWidget::Update
@@ -4124,6 +4159,8 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
#else
*aRetValue = 0;
#endif
if (mSizeMode == nsSizeMode_Fullscreen)
MakeFullScreen(TRUE);
}
}
break;
@@ -4283,7 +4320,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
else
event.mSizeMode = nsSizeMode_Normal;
#else
event.mSizeMode = nsSizeMode_Normal;
event.mSizeMode = mSizeMode;
#endif
InitEvent(event);
@@ -6456,4 +6493,4 @@ DWORD ChildWindow::WindowStyle()
style |= WS_CHILD; // WS_POPUP and WS_CHILD are mutually exclusive.
VERIFY_WINDOW_STYLE(style);
return style;
}
}
+2 -1
View File
@@ -140,6 +140,7 @@ public:
NS_IMETHOD SetCursor(imgIContainer* aCursor,
PRUint32 aHotspotX, PRUint32 aHotspotY);
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
NS_IMETHOD Validate();
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
@@ -519,4 +520,4 @@ protected:
virtual DWORD WindowStyle();
};
#endif // Window_h__
#endif // Window_h__
+4 -2
View File
@@ -343,7 +343,8 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode)
// on windows mobile, dialogs and top level windows are full screen
// This is partly due to the lack of a GetWindowPlacement.
if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel) {
aMode = nsSizeMode_Maximized;
if (aMode == nsSizeMode_Normal)
aMode = nsSizeMode_Maximized;
}
#endif
@@ -353,6 +354,7 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode)
int mode;
switch (aMode) {
case nsSizeMode_Fullscreen :
case nsSizeMode_Maximized :
mode = SW_MAXIMIZE;
break;
@@ -461,4 +463,4 @@ PRBool nsWindow::OnHotKey(WPARAM wParam, LPARAM lParam)
break;
}
return PR_FALSE;
}
}
+5 -14
View File
@@ -41,7 +41,6 @@
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsWidgetsCID.h"
#include "nsIFullScreen.h"
#include "nsServiceManagerUtils.h"
#include "nsIScreenManager.h"
#include "nsAppDirectoryServiceDefs.h"
@@ -442,8 +441,11 @@ NS_IMETHODIMP nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseWidget::SetSizeMode(PRInt32 aMode) {
if (aMode == nsSizeMode_Normal || aMode == nsSizeMode_Minimized ||
aMode == nsSizeMode_Maximized) {
if (aMode == nsSizeMode_Normal ||
aMode == nsSizeMode_Minimized ||
aMode == nsSizeMode_Maximized ||
aMode == nsSizeMode_Fullscreen) {
mSizeMode = (nsSizeMode) aMode;
return NS_OK;
@@ -588,8 +590,6 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
{
HideWindowChrome(aFullScreen);
nsCOMPtr<nsIFullScreen> fullScreen = do_GetService("@mozilla.org/browser/fullscreen;1");
if (aFullScreen) {
if (!mOriginalBounds)
mOriginalBounds = new nsIntRect();
@@ -607,12 +607,7 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
if (screen) {
PRInt32 left, top, width, height;
if (NS_SUCCEEDED(screen->GetRect(&left, &top, &width, &height))) {
SetSizeMode(nsSizeMode_Normal);
Resize(left, top, width, height, PR_TRUE);
// Hide all of the OS chrome
if (fullScreen)
fullScreen->HideAllOSChrome();
}
}
}
@@ -620,10 +615,6 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
} else if (mOriginalBounds) {
Resize(mOriginalBounds->x, mOriginalBounds->y, mOriginalBounds->width,
mOriginalBounds->height, PR_TRUE);
// Show all of the OS chrome
if (fullScreen)
fullScreen->ShowAllOSChrome();
}
return NS_OK;
+2 -1
View File
@@ -347,7 +347,8 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
// normal browser windows. here we just drop a raised window
// to the normal zlevel if it's maximized. we make no provision
// for automatically re-raising it when restored.
if (modeEvent->mSizeMode == nsSizeMode_Maximized) {
if (modeEvent->mSizeMode == nsSizeMode_Maximized ||
modeEvent->mSizeMode == nsSizeMode_Fullscreen) {
PRUint32 zLevel;
eventWindow->GetZLevel(&zLevel);
if (zLevel > nsIXULWindow::normalZ)
+23 -10
View File
@@ -95,9 +95,10 @@
#include "nsWebShellWindow.h" // get rid of this one, too...
#define SIZEMODE_NORMAL NS_LITERAL_STRING("normal")
#define SIZEMODE_MAXIMIZED NS_LITERAL_STRING("maximized")
#define SIZEMODE_MINIMIZED NS_LITERAL_STRING("minimized")
#define SIZEMODE_NORMAL NS_LITERAL_STRING("normal")
#define SIZEMODE_MAXIMIZED NS_LITERAL_STRING("maximized")
#define SIZEMODE_MINIMIZED NS_LITERAL_STRING("minimized")
#define SIZEMODE_FULLSCREEN NS_LITERAL_STRING("fullscreen")
#define WINDOWTYPE_ATTRIBUTE NS_LITERAL_STRING("windowtype")
@@ -255,7 +256,7 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel)
PRInt32 sizeMode;
if (mWindow) {
mWindow->GetSizeMode(&sizeMode);
if (sizeMode == nsSizeMode_Maximized)
if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen)
return NS_ERROR_FAILURE;
}
}
@@ -274,7 +275,6 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel)
PersistentAttributesDirty(PAD_MISC);
SavePersistentAttributes();
// finally, send a notification DOM event
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIDocumentViewer> dv(do_QueryInterface(cv));
@@ -299,7 +299,6 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel)
}
}
}
return NS_OK;
}
@@ -1202,17 +1201,29 @@ PRBool nsXULWindow::LoadMiscPersistentAttributesFromXUL()
if (stateString.Equals(SIZEMODE_MINIMIZED))
sizeMode = nsSizeMode_Minimized;
*/
if (stateString.Equals(SIZEMODE_MAXIMIZED)) {
if (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. */
if (mChromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
mIntrinsicallySized = PR_FALSE;
sizeMode = nsSizeMode_Maximized;
if (stateString.Equals(SIZEMODE_MAXIMIZED))
sizeMode = nsSizeMode_Maximized;
else
sizeMode = nsSizeMode_Fullscreen;
}
}
// the widget had better be able to deal with not becoming visible yet
mWindow->SetSizeMode(sizeMode);
if (sizeMode == nsSizeMode_Fullscreen) {
nsCOMPtr<nsIDOMWindowInternal> ourWindow;
GetWindowDOMWindow(getter_AddRefs(ourWindow));
ourWindow->SetFullScreen(PR_TRUE);
}
else
mWindow->SetSizeMode(sizeMode);
gotState = PR_TRUE;
}
@@ -1522,6 +1533,8 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
persistString.Find("sizemode") >= 0) {
if (sizeMode == nsSizeMode_Maximized)
sizeString.Assign(SIZEMODE_MAXIMIZED);
else if (sizeMode == nsSizeMode_Fullscreen)
sizeString.Assign(SIZEMODE_FULLSCREEN);
else
sizeString.Assign(SIZEMODE_NORMAL);
docShellElement->SetAttribute(MODE_ATTRIBUTE, sizeString);