diff --git a/embedding/minimo/wince/Makefile.in b/embedding/minimo/wince/Makefile.in index b953d4513975..44c467b4ce9a 100755 --- a/embedding/minimo/wince/Makefile.in +++ b/embedding/minimo/wince/Makefile.in @@ -41,6 +41,7 @@ PROGRAM = minimo$(BIN_SUFFIX) MODULE = minimo REQUIRES = xpcom \ + appshell \ string \ embed_base \ webbrwsr \ @@ -65,9 +66,11 @@ REQUIRES = xpcom \ CPPSRCS = \ winEmbed.cpp \ - WebBrowserChrome.cpp \ WindowCreator.cpp \ - $(NULL) + SplashScreen.cpp \ + $(NULL) + +RCINCLUDE = SplashScreen.rc EXTRA_DSO_LIBS = embed_base_s profdirserviceprovider_s diff --git a/embedding/minimo/wince/MinimoPrivate.h b/embedding/minimo/wince/MinimoPrivate.h index 842af88e75e7..e4ceb3719549 100755 --- a/embedding/minimo/wince/MinimoPrivate.h +++ b/embedding/minimo/wince/MinimoPrivate.h @@ -1,15 +1,51 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Minimo. + * + * The Initial Developer of the Original Code is + * Doug Turner . + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #ifndef MINIMO_PRIVATE_H #define MINIMO_PRIVATE_H -#include - // C RunTime Header Files +#include #include #include #include -#include // Win32 header files +#ifndef WINCE +#include #include #include #include @@ -17,40 +53,50 @@ #include #include #include +#include "resource.h" +#endif // Mozilla header files -#include "nsEmbedAPI.h" -#include "nsIClipboardCommands.h" -#include "nsXPIDLString.h" -#include "nsIWebBrowserPersist.h" -#include "nsIWebBrowserFocus.h" -#include "nsIWindowWatcher.h" -#include "nsIObserverService.h" -#include "nsIObserver.h" -#include "nsIURI.h" -#include "plstr.h" -#include "nsIInterfaceRequestor.h" -#include "nsIEventQueueService.h" - +#include "nsAppDirectoryServiceDefs.h" +#include "nsAppShellCID.h" #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" -#include "nsProfileDirServiceProvider.h" -#include "nsAppDirectoryServiceDefs.h" - +#include "nsEmbedAPI.h" #include "nsEmbedCID.h" -#include "nsIPromptService.h" -#include "nsIDOMWindow.h" +#include "nsIAppShell.h" +#include "nsIAppShellService.h" +#include "nsIAppStartupNotifier.h" +#include "nsIClipboardCommands.h" #include "nsIComponentRegistrar.h" - +#include "nsIDOMWindow.h" +#include "nsIEventQueueService.h" +#include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" +#include "nsIObserver.h" +#include "nsIObserverService.h" #include "nsIPrefBranch.h" #include "nsIPrefService.h" - +#include "nsIPromptService.h" +#include "nsITimelineService.h" +#include "nsIURI.h" +#include "nsIWebBrowserChrome.h" +#include "nsIWebBrowserFocus.h" +#include "nsIWebBrowserPersist.h" #include "nsIWidget.h" +#include "nsIWindowCreator.h" +#include "nsIWindowCreator2.h" +#include "nsIWindowWatcher.h" +#include "nsIXULWindow.h" +#include "nsProfileDirServiceProvider.h" +#include "nsWidgetsCID.h" +#include "nsXPIDLString.h" +#include "plstr.h" // Local header files -#include "WebBrowserChrome.h" #include "WindowCreator.h" +#include "resource.h" -nsresult ResizeEmbedding(nsIWebBrowserChrome* chrome); +void CreateSplashScreen(); +void KillSplashScreen(); #endif // MINIMO_PRIVATE_H diff --git a/embedding/minimo/wince/SplashScreen.cpp b/embedding/minimo/wince/SplashScreen.cpp new file mode 100755 index 000000000000..097a020e9616 --- /dev/null +++ b/embedding/minimo/wince/SplashScreen.cpp @@ -0,0 +1,120 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Minimo. + * + * The Initial Developer of the Original Code is + * Doug Turner . + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "MinimoPrivate.h" + +static HWND gSplashScreenDialog = NULL; + +BOOL CALLBACK +SplashScreenDialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ) +{ + if ( msg == WM_INITDIALOG ) + { + SetWindowText(dlg, "Minimo"); + + gSplashScreenDialog = dlg; + + HWND bitmapControl = GetDlgItem( dlg, IDC_SPLASHBMP ); + if ( bitmapControl ) + { + HBITMAP hbitmap = (HBITMAP)SendMessage( bitmapControl, + STM_GETIMAGE, + IMAGE_BITMAP, + 0 ); + if ( hbitmap ) + { + BITMAP bitmap; + if ( GetObject( hbitmap, sizeof bitmap, &bitmap ) ) + { + SetWindowPos( dlg, + NULL, + GetSystemMetrics(SM_CXSCREEN)/2 - bitmap.bmWidth/2, + GetSystemMetrics(SM_CYSCREEN)/2 - bitmap.bmHeight/2, + bitmap.bmWidth, + bitmap.bmHeight, + SWP_NOZORDER ); + ShowWindow( dlg, SW_SHOW ); + } + } + } + return 1; + } + else if (msg == WM_CLOSE) + { + NS_TIMELINE_MARK_FUNCTION("SplashScreenDialogProc Close"); + + EndDialog(dlg, 0); + gSplashScreenDialog = NULL; + } + return 0; +} + +DWORD WINAPI SplashScreenThreadProc(LPVOID notused) +{ + DialogBoxParamW( GetModuleHandle( 0 ), + MAKEINTRESOURCE( IDD_SPLASHSCREEN ), + HWND_DESKTOP, + (DLGPROC)SplashScreenDialogProc, + NULL ); + + return 0; +} + +void KillSplashScreen() +{ + NS_TIMELINE_MARK_FUNCTION("KillSplashScreen"); + + if (gSplashScreenDialog) + { + EndDialog((HWND)gSplashScreenDialog, 0); + gSplashScreenDialog = NULL; + } +} + +void CreateSplashScreen() +{ + NS_TIMELINE_MARK_FUNCTION("CreateSplashScreen"); + + DWORD threadID; + HANDLE handle = CreateThread( 0, + 0, + (LPTHREAD_START_ROUTINE)SplashScreenThreadProc, + 0, + 0, + &threadID ); + CloseHandle(handle); +} + diff --git a/embedding/minimo/wince/SplashScreen.rc b/embedding/minimo/wince/SplashScreen.rc new file mode 100755 index 000000000000..daa69d37a5cf --- /dev/null +++ b/embedding/minimo/wince/SplashScreen.rc @@ -0,0 +1,13 @@ + +#include "resource.h" +#include "newres.h" + +IDD_SPLASHSCREEN DIALOG DISCARDABLE 0, 0, 31, 27 +STYLE DS_MODALFRAME | WS_POPUP +FONT 8, "System" +BEGIN + CONTROL 104,IDC_SPLASHBMP,"Static",SS_BITMAP,7,7,15,13 +END + + +IDB_BITMAP1 BITMAP DISCARDABLE "splashscreen.bmp" diff --git a/embedding/minimo/wince/WebBrowserChrome.cpp b/embedding/minimo/wince/WebBrowserChrome.cpp deleted file mode 100755 index 6d762afbf16d..000000000000 --- a/embedding/minimo/wince/WebBrowserChrome.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: Mozilla-sample-code 1.0 - * - * Copyright (c) 2002 Netscape Communications Corporation and - * other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this Mozilla sample software and associated documentation files - * (the "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -// Mozilla Includes -#include "nsIGenericFactory.h" -#include "nsIComponentManager.h" -#include "nsString.h" -#include "nsXPIDLString.h" -#include "nsIURI.h" -#include "nsIWebProgress.h" -#include "nsIDocShellTreeItem.h" -#include "nsIDOMWindow.h" -#include "nsIInterfaceRequestor.h" -#include "nsIRequest.h" -#include "nsCWebBrowser.h" -#include "nsIProfileChangeStatus.h" -#include "nsPIDOMWindow.h" -#include "nsIDOMEventReceiver.h" -#include "nsIDOMNSEvent.h" -#include "nsIDOMEventTarget.h" -#include "nsIContent.h" -#include "nsIWidget.h" -#include "WebBrowserChrome.h" -#include "nsIWebBrowserSetup.h" - -WebBrowserChrome::WebBrowserChrome() -{ - mNativeWindow = nsnull; -} - -WebBrowserChrome::~WebBrowserChrome() -{ - if (mNativeWindow) - DestroyWindow((HWND)mNativeWindow); -} - -nsresult WebBrowserChrome::CreateBrowser(PRInt32 aX, PRInt32 aY, - PRInt32 aCX, PRInt32 aCY, - nsIWebBrowser **aBrowser) -{ - NS_ENSURE_ARG_POINTER(aBrowser); - *aBrowser = nsnull; - - mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID); - - if (!mWebBrowser) - return NS_ERROR_FAILURE; - - - // Configure what the web browser can and cannot do - nsCOMPtr webBrowserAsSetup(do_QueryInterface(mWebBrowser)); - - webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS, PR_TRUE); - webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER, PR_TRUE); - - - (void)mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this)); - - nsCOMPtr browserBaseWindow = do_QueryInterface(mWebBrowser); - mNativeWindow = WebBrowserChromeUI::CreateNativeWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this)); - - if (!mNativeWindow) - return NS_ERROR_FAILURE; - - browserBaseWindow->InitWindow( mNativeWindow, nsnull, aX, aY, aCX, aCY); - browserBaseWindow->Create(); - - nsCOMPtr mozWidget; - browserBaseWindow->GetMainWidget(getter_AddRefs(mozWidget)); - mNativeMozWindow = mozWidget->GetNativeData(NS_NATIVE_WINDOW); - - if (mWebBrowser) - { - *aBrowser = mWebBrowser; - NS_ADDREF(*aBrowser); - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -//***************************************************************************** -// WebBrowserChrome::nsISupports -//***************************************************************************** - -NS_IMPL_ADDREF(WebBrowserChrome) -NS_IMPL_RELEASE(WebBrowserChrome) - -NS_INTERFACE_MAP_BEGIN(WebBrowserChrome) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome) - NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) - NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome) - NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow) -NS_INTERFACE_MAP_END - -//***************************************************************************** -// WebBrowserChrome::nsIInterfaceRequestor -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr) -{ - NS_ENSURE_ARG_POINTER(aInstancePtr); - - *aInstancePtr = 0; - if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) - { - if (mWebBrowser) - { - return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr); - } - return NS_ERROR_NOT_INITIALIZED; - } - return QueryInterface(aIID, aInstancePtr); -} - -//***************************************************************************** -// WebBrowserChrome::nsIWebBrowserChrome -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::SetStatus(PRUint32 aType, const PRUnichar* aStatus) -{ - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser) -{ - NS_ENSURE_ARG_POINTER(aWebBrowser); - *aWebBrowser = mWebBrowser; - NS_IF_ADDREF(*aWebBrowser); - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser) -{ - mWebBrowser = aWebBrowser; - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::GetChromeFlags(PRUint32* aChromeMask) -{ - *aChromeMask = mChromeFlags; - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::SetChromeFlags(PRUint32 aChromeMask) -{ - mChromeFlags = aChromeMask; - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow(void) -{ - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - - GetWebBrowser(getter_AddRefs(webBrowser)); - - webNavigation = do_QueryInterface(webBrowser); - if (webNavigation) - webNavigation->Stop(nsIWebNavigation::STOP_ALL); - - ExitModalEventLoop(NS_OK); - - // First the browser - nsCOMPtr browserAsWin = do_QueryInterface(webBrowser); - if (browserAsWin) - browserAsWin->Destroy(); - - // Now the chrome - mWebBrowser = nsnull; - - if (mNativeWindow) - { - DestroyWindow((HWND)mNativeWindow); - mNativeWindow = nsnull; - } - - WebBrowserChromeUI::Destroy(this); - return NS_OK; -} - - -// IN: The desired browser client area dimensions. -NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aWidth, PRInt32 aHeight) -{ - SetWindowPos((HWND)mNativeWindow, NULL, 0, 0, aWidth, aHeight, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); - return NS_OK; -} - - -NS_IMETHODIMP WebBrowserChrome::ShowAsModal(void) -{ - mContinueModalLoop = PR_TRUE; - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::IsWindowModal(PRBool *_retval) -{ - *_retval = mContinueModalLoop; - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::ExitModalEventLoop(nsresult aStatus) -{ - mContinueModalLoop = PR_FALSE; - return NS_OK; -} - -//***************************************************************************** -// WebBrowserChrome::nsIWebBrowserChromeFocus -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::FocusNextElement() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP WebBrowserChrome::FocusPrevElement() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -//***************************************************************************** -// WebBrowserChrome::nsIEmbeddingSiteWindow -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY) -{ - nsCOMPtr browserBaseWindow = do_QueryInterface(mWebBrowser); - - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION && (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) - { - MoveWindow((HWND)mNativeWindow, aX, aY, aCX, aCY, PR_TRUE); - return NS_OK; - } - else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) - { - RECT rect; - GetWindowRect((HWND)mNativeWindow, &rect); - MoveWindow((HWND)mNativeWindow, aX, aY, rect.right-rect.left, rect.bottom-rect.top, TRUE); - return NS_OK; - } - else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | - nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) { - RECT rect; - GetWindowRect((HWND)mNativeWindow, &rect); - MoveWindow((HWND)mNativeWindow, rect.left, rect.top, aCX, aCY, TRUE); - return NS_OK; - } - return NS_ERROR_INVALID_ARG; -} - -NS_IMETHODIMP WebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY) -{ - nsCOMPtr browserBaseWindow = do_QueryInterface(mWebBrowser); - - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION && - (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | - nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) { - return browserBaseWindow->GetPositionAndSize(aX, aY, aCX, aCY); - } - else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) { - return browserBaseWindow->GetPosition(aX, aY); - } - else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | - nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) { - return browserBaseWindow->GetSize(aCX, aCY); - } - return NS_ERROR_INVALID_ARG; -} - -/* void setFocus (); */ -NS_IMETHODIMP WebBrowserChrome::SetFocus() -{ - ::SetFocus((HWND)mNativeWindow); - return NS_OK; -} - -/* attribute wstring title; */ -NS_IMETHODIMP WebBrowserChrome::GetTitle(PRUnichar * *aTitle) -{ - NS_ENSURE_ARG_POINTER(aTitle); - - *aTitle = nsnull; - - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP WebBrowserChrome::SetTitle(const PRUnichar * aTitle) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* attribute boolean visibility; */ -NS_IMETHODIMP WebBrowserChrome::GetVisibility(PRBool * aVisibility) -{ - NS_ENSURE_ARG_POINTER(aVisibility); - *aVisibility = PR_TRUE; - return NS_OK; -} -NS_IMETHODIMP WebBrowserChrome::SetVisibility(PRBool aVisibility) -{ - return NS_OK; -} - -/* attribute nativeSiteWindow siteWindow */ -NS_IMETHODIMP WebBrowserChrome::GetSiteWindow(void * *aSiteWindow) -{ - NS_ENSURE_ARG_POINTER(aSiteWindow); - - *aSiteWindow = mNativeWindow; - return NS_OK; -} diff --git a/embedding/minimo/wince/WebBrowserChrome.h b/embedding/minimo/wince/WebBrowserChrome.h deleted file mode 100755 index 244c8d0e3f77..000000000000 --- a/embedding/minimo/wince/WebBrowserChrome.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: Mozilla-sample-code 1.0 - * - * Copyright (c) 2002 Netscape Communications Corporation and - * other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this Mozilla sample software and associated documentation files - * (the "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __WebBrowserChrome__ -#define __WebBrowserChrome__ - -#include "nsCOMPtr.h" -#include "nsString.h" -#include "nsIWebBrowserChrome.h" -#include "nsIWebBrowserChromeFocus.h" - -#include "nsIBaseWindow.h" -#include "nsIEmbeddingSiteWindow.h" -#include "nsIWebNavigation.h" -#include "nsIInterfaceRequestor.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsIWebBrowser.h" -#include "nsIObserver.h" -#include "nsWeakReference.h" -#include "nsISHistoryListener.h" -#include "nsIContextMenuListener.h" -#include "nsITooltipListener.h" - -class WebBrowserChromeUI -{ -public: - static nativeWindow CreateNativeWindow(nsIWebBrowserChrome* chrome); - static void Destroy(nsIWebBrowserChrome* chrome); -}; - -class WebBrowserChrome : public nsIWebBrowserChrome, - public nsIWebBrowserChromeFocus, - public nsIEmbeddingSiteWindow, - public nsIInterfaceRequestor, - public nsSupportsWeakReference -{ -public: - WebBrowserChrome(); - virtual ~WebBrowserChrome(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIWEBBROWSERCHROME - NS_DECL_NSIWEBBROWSERCHROMEFOCUS - NS_DECL_NSIEMBEDDINGSITEWINDOW - NS_DECL_NSIINTERFACEREQUESTOR - - nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nsIWebBrowser **aBrowser); - -protected: - - nativeWindow mNativeWindow; - nativeWindow mNativeMozWindow; - - PRUint32 mChromeFlags; - PRBool mContinueModalLoop; - - nsCOMPtr mWebBrowser; -}; - -#endif /* __WebBrowserChrome__ */ diff --git a/embedding/minimo/wince/WindowCreator.cpp b/embedding/minimo/wince/WindowCreator.cpp index 85f1b0cb85f8..45f6451ab288 100755 --- a/embedding/minimo/wince/WindowCreator.cpp +++ b/embedding/minimo/wince/WindowCreator.cpp @@ -1,110 +1,115 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** - * Version: Mozilla-sample-code 1.0 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * Copyright (c) 2002 Netscape Communications Corporation and - * other contributors + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this Mozilla sample software and associated documentation files - * (the "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. + * The Original Code is Minimo. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * The Initial Developer of the Original Code is + * Doug Turner . + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. * * Contributor(s): * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * * ***** END LICENSE BLOCK ***** */ -#include "WindowCreator.h" + #include "MinimoPrivate.h" -WindowCreator::WindowCreator() +NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); + +WindowCreator::WindowCreator(nsIAppShell* aAppShell) { + mAppShell = aAppShell; } WindowCreator::~WindowCreator() { } -NS_IMPL_ISUPPORTS1(WindowCreator, nsIWindowCreator) - -nsresult ResizeEmbedding(nsIWebBrowserChrome* chrome) -{ - if (!chrome) - return NS_ERROR_FAILURE; - - nsCOMPtr embeddingSite = do_QueryInterface(chrome); - HWND hWnd; - embeddingSite->GetSiteWindow((void **) & hWnd); - - if (!hWnd) - return NS_ERROR_NULL_POINTER; - - RECT rect; - GetClientRect(hWnd, &rect); - - // Make sure the browser is visible and sized - nsCOMPtr webBrowser; - chrome->GetWebBrowser(getter_AddRefs(webBrowser)); - nsCOMPtr webBrowserAsWin = do_QueryInterface(webBrowser); - if (webBrowserAsWin) - { - webBrowserAsWin->SetPositionAndSize(rect.left, - rect.top, - rect.right - rect.left, - rect.bottom - rect.top, - PR_TRUE); - webBrowserAsWin->SetVisibility(PR_TRUE); - } - - return NS_OK; -} - +NS_IMPL_ISUPPORTS2(WindowCreator, nsIWindowCreator, nsIWindowCreator2) NS_IMETHODIMP WindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent, PRUint32 aChromeFlags, - nsIWebBrowserChrome **aNewWindow) + nsIWebBrowserChrome **_retval) { - NS_ENSURE_ARG_POINTER(aNewWindow); - - WebBrowserChrome * chrome = new WebBrowserChrome(); - if (!chrome) - return NS_ERROR_FAILURE; - - // now an extra addref; the window owns itself (to be released by - // WebBrowserChromeUI::Destroy) - NS_ADDREF(chrome); - - chrome->SetChromeFlags(aChromeFlags); - - // Insert the browser - nsCOMPtr newBrowser; - chrome->CreateBrowser(-1, -1, -1, -1, getter_AddRefs(newBrowser)); - - if (!newBrowser) - { - NS_RELEASE(chrome); - return NS_ERROR_FAILURE; - } - - // and an addref on the way out. - NS_ADDREF(chrome); - *aNewWindow = NS_STATIC_CAST(nsIWebBrowserChrome*, chrome); - - ResizeEmbedding(chrome); - - return NS_OK; + PRBool cancel; + return CreateChromeWindow2(aParent, aChromeFlags, 0, 0, &cancel, _retval); +} + +NS_IMETHODIMP +WindowCreator::CreateChromeWindow2(nsIWebBrowserChrome *aParent, + PRUint32 aChromeFlags, + PRUint32 aContextFlags, + nsIURI *aURI, + PRBool *aCancel, + nsIWebBrowserChrome **aNewWindow) +{ + *aCancel = PR_FALSE; + + if (!mAppShell) + return NS_ERROR_NOT_INITIALIZED; + + nsCOMPtr newWindow; + +#ifndef WINCE + //modality is screwy on windows ce. + if (aParent) { + nsCOMPtr xulParent(do_GetInterface(aParent)); + NS_ASSERTION(xulParent, "window created using non-XUL parent. that's unexpected, but may work."); + + if (xulParent) + xulParent->CreateNewWindow(aChromeFlags, mAppShell, getter_AddRefs(newWindow)); + + // And if it fails, don't try again without a parent. It could fail + // intentionally (bug 115969). + } + else +#endif + { + nsCOMPtr appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); + if (!appShell) + return NS_ERROR_FAILURE; + + nsCOMPtr xulParent(do_GetInterface(aParent)); + + appShell->CreateTopLevelWindow(xulParent, + 0, + aChromeFlags, + 240, //XXXXXX + 320 - 24 /* 24 is the height of the menubar */, + mAppShell, + getter_AddRefs(newWindow)); + } + + // if anybody gave us anything to work with, use it + if (newWindow) { + newWindow->SetContextFlags(aContextFlags); + nsCOMPtr thing(do_QueryInterface(newWindow)); + if (thing) + CallGetInterface(thing.get(), aNewWindow); + } + + return *aNewWindow ? NS_OK : NS_ERROR_FAILURE; } diff --git a/embedding/minimo/wince/WindowCreator.h b/embedding/minimo/wince/WindowCreator.h index b4c0181dda37..e5a20f0619eb 100755 --- a/embedding/minimo/wince/WindowCreator.h +++ b/embedding/minimo/wince/WindowCreator.h @@ -1,47 +1,56 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** - * Version: Mozilla-sample-code 1.0 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * Copyright (c) 2002 Netscape Communications Corporation and - * other contributors + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this Mozilla sample software and associated documentation files - * (the "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. + * The Original Code is Minimo. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * The Initial Developer of the Original Code is + * Doug Turner . + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. * * Contributor(s): * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * * ***** END LICENSE BLOCK ***** */ #ifndef __WindowCreator_h_ #define __WindowCreator_h_ -#include "nsIWindowCreator.h" +#include "MinimoPrivate.h" -class WindowCreator : - public nsIWindowCreator +class WindowCreator : public nsIWindowCreator2 { public: - WindowCreator(); + WindowCreator(nsIAppShell* aAppShell); virtual ~WindowCreator(); NS_DECL_ISUPPORTS NS_DECL_NSIWINDOWCREATOR + NS_DECL_NSIWINDOWCREATOR2 + + nsCOMPtr mAppShell; + }; #endif diff --git a/embedding/minimo/wince/minimo-link-comps b/embedding/minimo/wince/minimo-link-comps index 8491f90ca058..fa5303160ab1 100755 --- a/embedding/minimo/wince/minimo-link-comps +++ b/embedding/minimo/wince/minimo-link-comps @@ -22,10 +22,6 @@ mork xmlextra t8iix websrvcs -popuplite snav gkplugin softkey -pipboot -pipnss -pippki diff --git a/embedding/minimo/wince/minimo-link-names b/embedding/minimo/wince/minimo-link-names index 99b189c1c3ef..29039fca34ee 100755 --- a/embedding/minimo/wince/minimo-link-names +++ b/embedding/minimo/wince/minimo-link-names @@ -22,10 +22,6 @@ nsMorkModule nsXMLExtrasModule TransformiixModule nsWebServicesModule -popuplite SpatialNavigationModule nsPluginModule SoftKeyBoardModule -BOOT -NSS -PKI diff --git a/embedding/minimo/wince/mozconfig/ppc2003arm b/embedding/minimo/wince/mozconfig/ppc2003arm index d604d0c44b0d..7a490d61a8da 100755 --- a/embedding/minimo/wince/mozconfig/ppc2003arm +++ b/embedding/minimo/wince/mozconfig/ppc2003arm @@ -68,13 +68,10 @@ ac_add_options --enable-image-decoders=png,gif,jpeg # code generation options (optimize for size) ac_add_options --enable-strip ac_add_options --disable-debug - -#ac_add_options --disable-optimize -#ac_add_options --enable-debug - -#ac_add_options --enable-optimize=-Os +ac_add_options --enable-optimize # enable static build ac_add_options --disable-shared ac_add_options --enable-static +# ac_add_options --enable-timeline diff --git a/embedding/minimo/wince/newres.h b/embedding/minimo/wince/newres.h new file mode 100755 index 000000000000..8289ebe2d12f --- /dev/null +++ b/embedding/minimo/wince/newres.h @@ -0,0 +1,41 @@ +#ifndef __NEWRES_H__ +#define __NEWRES_H__ + +#if !defined(UNDER_CE) +#define UNDER_CE _WIN32_WCE +#endif + +#if defined(_WIN32_WCE) + #if !defined(WCEOLE_ENABLE_DIALOGEX) + #define DIALOGEX DIALOG DISCARDABLE + #endif + #include + #define SHMENUBAR RCDATA + #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300) + #include + #define AFXCE_IDR_SCRATCH_SHMENU 28700 + #else + #define I_IMAGENONE (-2) + #define NOMENU 0xFFFF + #define IDS_SHNEW 1 + + #define IDM_SHAREDNEW 10 + #define IDM_SHAREDNEWDEFAULT 11 + #endif // _WIN32_WCE_PSPC + #define AFXCE_IDD_SAVEMODIFIEDDLG 28701 +#endif // _WIN32_WCE + +#ifdef RC_INVOKED +#ifndef _INC_WINDOWS +#define _INC_WINDOWS + #include "winuser.h" // extract from windows header + #include "winver.h" +#endif +#endif + +#ifdef IDC_STATIC +#undef IDC_STATIC +#endif +#define IDC_STATIC (-1) + +#endif //__NEWRES_H__ diff --git a/embedding/minimo/wince/package.sh b/embedding/minimo/wince/package.sh index ec844084998a..45d2494c5553 100755 --- a/embedding/minimo/wince/package.sh +++ b/embedding/minimo/wince/package.sh @@ -20,7 +20,6 @@ cp -a bin/nspr4.dll wince cp -a bin/plc4.dll wince cp -a bin/plds4.dll wince cp -a bin/xpcom.dll wince -cp -a bin/xpcom_compat.dll wince cp -a bin/xpcom_core.dll wince cp -a bin/nss3.dll wince @@ -32,26 +31,22 @@ cp -a bin/ssl3.dll wince mkdir -p wince/chrome cp -a bin/chrome/classic.jar wince/chrome -cp -a bin/chrome/comm.jar wince/chrome cp -a bin/chrome/en-US.jar wince/chrome -cp -a bin/chrome/en-win.jar wince/chrome cp -a bin/chrome/installed-chrome.txt wince/chrome cp -a bin/chrome/minimo.jar wince/chrome -cp -a bin/chrome/modern.jar wince/chrome cp -a bin/chrome/toolkit.jar wince/chrome -cp -a bin/chrome/US.jar wince/chrome cp -a bin/chrome/pippki.jar wince/chrome cp -a bin/chrome/pipnss.jar wince/chrome mkdir -p wince/components -cp -a bin/components/nsDictionary.js wince/components + cp -a bin/components/nsHelperAppDlg.js wince/components -cp -a bin/components/nsInterfaceInfoToIDL.js wince/components cp -a bin/components/nsProgressDialog.js wince/components -cp -a bin/components/nsProxyAutoConfig.js wince/components + +cp -a bin/components/nsDictionary.js wince/components +cp -a bin/components/nsInterfaceInfoToIDL.js wince/components cp -a bin/components/nsXmlRpcClient.js wince/components -cp -a bin/components/xulappinfo.js wince/components cp -a bin/components/snav.dll wince/components @@ -74,6 +69,26 @@ echo Linking XPT files. host/bin/host_xpt_link wince/components/all.xpt bin/components/*.xpt +echo Chewing on chrome + +cd wince/chrome + +unzip classic.jar +rm -rf classic.jar +rm -rf skin/classic/communicator +rm -rf skin/classic/editor +rm -rf skin/classic/messenger +rm -rf skin/classic/navigator +zip -r classic.jar skin +rm -rf skin + +unzip en-US.jar +rm -rf en-US.jar +rm -rf locale/en-US/communicator +rm -rf locale/en-US/navigator +zip -r en-US.jar locale +rm -rf locale + echo Copying over customized files popd diff --git a/embedding/minimo/wince/resource.h b/embedding/minimo/wince/resource.h index d1062f3d8019..aceff79f7456 100755 --- a/embedding/minimo/wince/resource.h +++ b/embedding/minimo/wince/resource.h @@ -1,119 +1,41 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by winEmbed.rc -// -#define IDC_MYICON 2 -#define IDD_HEADSUP_DISPLAY 101 -#define IDD_WINEMBED_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDS_APP_TITLE 103 -#define IDM_ABOUT 104 -#define MOZ_OpenURI 104 -#define MOZ_GetURI 104 -#define IDM_EXIT 105 -#define IDS_HELLO 106 -#define IDI_WINEMBED 107 -#define IDS_ABOUT 107 -#define IDI_SMALL 108 -#define IDS_ABOUT_TITLE 108 -#define IDC_WINEMBED 109 -#define IDS_HIST_BACK 109 -#define IDS_HIST_FORWARD 110 -#define IDS_HIST_RELOAD_NORMAL 111 -#define IDS_HIST_RELOAD_BYPASSPROXY 112 -#define IDS_HIST_RELOAD_BYPASSCACHE 113 -#define IDS_HIST_ADDURL 114 -#define IDS_HIST_RELOAD_BYPASSPROXYANDCACHE 115 -#define IDS_HIST_PURGE 116 -#define IDS_HIST_GOTO 117 -#define IDS_HIST_URL 118 -#define IDR_MAINFRAME 128 -#define IDD_BROWSER 130 -#define IDD_BROWSER_NC 131 -#define IDD_CHOOSEPROFILE 132 -#define IDD_STATUS_DISPLAY 132 -#define IDR_MENUBAR1 133 -#define IDD_SPLASH_SCREEN 134 -#define IDR_MENUBAR2 135 -#define IDD_PAGE_INFO 135 -#define IDI_ICON1 136 -#define IDD_NAVIGATION 136 -#define IDD_UTILITIES 137 -#define IDM_POPUPMENU 138 -#define IDB_SPLASH 140 -#define IDM_MINIMO_A 500 -#define IDM_MINIMO_B 501 -#define MOZ_EDIT_URI 1001 -#define IDC_GO 1003 -#define IDC_BROWSER 1004 -#define IDC_ADDRESS 1005 -#define IDC_BROWSER2 1005 -#define IDC_STOP 1006 -#define IDC_STATUS 1007 -#define IDC_BACK 1008 -#define IDC_FORWARD 1009 -#define IDC_PROGRESS 1010 -#define IDC_RELOAD 1011 -#define IDC_PROFILELIST 1011 -#define IDC_FUNCTIONS 1012 -#define IDC_Hide 1013 -#define IDC_SLASH_IMAGE 1015 -#define IDC_BUTTON1 1019 -#define IDC_TitleString 1023 -#define IDC_URLString 1024 -#define IDC_SecurityString 1025 -#define IDC_SizeString 1026 -#define IDC_EncodingString 1027 -#define IDC_INCREASE_FONT 1028 -#define IDC_SPIN1 1030 -#define IDC_TAB2 1032 -#define MOZ_Open 32771 -#define MOZ_Print 32772 -#define MOZ_NewBrowser 32773 -#define MOZ_NewEditor 32774 -#define MOZ_Save 32775 -#define MOZ_Cut 32776 -#define MOZ_Copy 32777 -#define MOZ_Paste 32778 -#define MOZ_Delete 32779 -#define MOZ_SelectAll 32780 -#define MOZ_SelectNone 32781 -#define MOZ_GoBack 32782 -#define MOZ_GoForward 32783 -#define MOZ_About 32784 -#define ID_DEBUG_THISSPACEFORRENT 32786 -#define MOZ_SwitchProfile 32787 -#define ID_FILE 32788 -#define IDS_CAP_FILE 32790 -#define ID_FILE_OPEN 32791 -#define ID_EDIT 32792 -#define IDS_CAP_EDIT 32794 -#define IDS_CAP_MENUITEM32796 32797 -#define ID_TOOLS 32798 -#define ID_HELP 32799 -#define IDS_CAP_HELP 32801 -#define ID_FILE_QUIT 32806 -#define ID_ABOUT 32807 -#define IDS_CAP_MENUITEM32811 32812 -#define ID_A 32813 -#define IDS_CAP_A 32815 -#define ID_A_A 32816 -#define ID_A_B 32817 -#define IDS_CAP_C 32819 -#define ID_C_C 32820 -#define IDS_CAP_POPUPMENU 32822 -#define IDS_MINIMO_A 40001 -#define IDS_MINIMO_B 40002 +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Minimo. + * + * The Initial Developer of the Original Code is + * Doug Turner . + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -#define IDC_STATIC -1 -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 144 -#define _APS_NEXT_COMMAND_VALUE 32823 -#define _APS_NEXT_CONTROL_VALUE 1033 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif +#define IDD_SPLASHSCREEN 101 +#define IDB_BITMAP1 104 +#define IDC_SPLASHBMP 1001 + diff --git a/embedding/minimo/wince/splashscreen.bmp b/embedding/minimo/wince/splashscreen.bmp new file mode 100755 index 000000000000..11f51712c10b Binary files /dev/null and b/embedding/minimo/wince/splashscreen.bmp differ diff --git a/embedding/minimo/wince/winEmbed.cpp b/embedding/minimo/wince/winEmbed.cpp index 9756e4fe64ce..678e129e7be3 100755 --- a/embedding/minimo/wince/winEmbed.cpp +++ b/embedding/minimo/wince/winEmbed.cpp @@ -1,32 +1,36 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** - * Version: Mozilla-sample-code 1.0 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * Copyright (c) 2002 Netscape Communications Corporation and - * other contributors + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this Mozilla sample software and associated documentation files - * (the "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. + * The Original Code is Minimo. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * The Initial Developer of the Original Code is + * Doug Turner . + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Doug Turner - * Adam Lock + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ @@ -39,17 +43,99 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count); #endif // Global variables -static PRBool gRunCondition = PR_TRUE; -static UINT gBrowserCount = 0; -static UINT_PTR gEventTimer = 0; - -#define PLEVENT_TIMEOUT 500 +const static char* start_url = "chrome://minimo/content/minimo.xul"; +//const static char* start_url = "http://www.meer.net/~dougt/test.html"; +//const static char* start_url = "resource://gre/res/start.html"; static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); +static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); +class ApplicationObserver: public nsIObserver +{ +public: + ApplicationObserver(nsIAppShell* aAppShell); + ~ApplicationObserver(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER + + nsCOMPtr mAppShell; + int mWindowCount; +}; + + +ApplicationObserver::ApplicationObserver(nsIAppShell* aAppShell) +{ + mAppShell = aAppShell; + mWindowCount = 0; + + nsCOMPtr os = do_GetService("@mozilla.org/observer-service;1"); + + + os->AddObserver(this, "nsIEventQueueActivated", PR_FALSE); + os->AddObserver(this, "nsIEventQueueDestroyed", PR_FALSE); + + os->AddObserver(this, "xul-window-registered", PR_FALSE); + os->AddObserver(this, "xul-window-destroyed", PR_FALSE); + os->AddObserver(this, "xul-window-visible", PR_FALSE); +} + +ApplicationObserver::~ApplicationObserver() +{ +} + +NS_IMPL_ISUPPORTS1(ApplicationObserver, nsIObserver) + +NS_IMETHODIMP +ApplicationObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) +{ + if (!strcmp(aTopic, "nsIEventQueueActivated")) + { + nsCOMPtr eq(do_QueryInterface(aSubject)); + if (eq) + { + PRBool isNative = PR_TRUE; + // we only add native event queues to the appshell + eq->IsQueueNative(&isNative); + if (isNative) + mAppShell->ListenToEventQueue(eq, PR_TRUE); + } + } + else if (!strcmp(aTopic, "nsIEventQueueDestroyed")) + { + nsCOMPtr eq(do_QueryInterface(aSubject)); + if (eq) + { + PRBool isNative = PR_TRUE; + // we only remove native event queues from the appshell + eq->IsQueueNative(&isNative); + if (isNative) + mAppShell->ListenToEventQueue(eq, PR_FALSE); + } + } + else if (!strcmp(aTopic, "xul-window-visible")) + { + KillSplashScreen(); + } + + else if (!strcmp(aTopic, "xul-window-registered")) + { + mWindowCount++; + } + else if (!strcmp(aTopic, "xul-window-destroyed")) + { + mWindowCount--; + if (mWindowCount == 0) + mAppShell->Exit(); + } + + return NS_OK; +} nsresult StartupProfile() { + NS_TIMELINE_MARK_FUNCTION("Profile Startup"); + nsCOMPtr appDataDir; nsresult rv = NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR, getter_AddRefs(appDataDir)); if (NS_FAILED(rv)) @@ -78,126 +164,8 @@ void SetPreferences() nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); if (!prefBranch) return; -} -LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) -{ - nsIWebBrowserChrome *chrome = (nsIWebBrowserChrome *) GetWindowLong(hWnd, GWL_USERDATA); - nsCOMPtr webBrowser; - if (chrome) - chrome->GetWebBrowser(getter_AddRefs(webBrowser)); - - switch (Msg) - { - - case WM_SYSCOMMAND: - if (wParam == SC_CLOSE) - { - WebBrowserChromeUI::Destroy(chrome); - return TRUE; - } - break; - - case WM_ACTIVATE: - { - nsCOMPtr focus(do_GetInterface(webBrowser)); - - switch (wParam) - { - case WA_ACTIVE: - gEventTimer = SetTimer(hWnd, 1, PLEVENT_TIMEOUT, NULL); - if (focus) - focus->Activate(); - break; - - case WA_INACTIVE: - KillTimer(hWnd, gEventTimer); - gEventTimer = NULL; - - if (focus) - focus->Deactivate(); - } - } - return 0; - - case WM_CLOSE: - chrome->DestroyBrowserWindow(); - return 0; - - case WM_DESTROY: - if (gBrowserCount == 0) - gRunCondition = PR_FALSE; - return 0; - - case WM_TIMER: - { - PRBool eventAvail; - - nsCOMPtr eventQ; - nsCOMPtr eqs = do_GetService(kEventQueueServiceCID); - if (!eqs) - return 0; - - eqs->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ)); - - if (!eventQ) - return 0; - - eventQ->PendingEvents(&eventAvail); - - if (eventAvail) - eventQ->ProcessPendingEvents(); - - // reset the timer - if (gEventTimer) - gEventTimer = SetTimer(hWnd, 1, 500, NULL); - } - return 0; - - case WM_SIZE: - { - ResizeEmbedding(chrome); - return 0; - } - default: - return DefWindowProc(hWnd, Msg, wParam, lParam); - } - - - return -1; // default handles all! -} - - -void RegisterMainWindowClass() -{ - WNDCLASS wc; - - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = (WNDPROC) MainWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = GetModuleHandle(NULL); - wc.hIcon = NULL; - wc.hCursor = 0; - wc.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH); - wc.lpszMenuName = 0; - wc.lpszClassName = "Minimo Main Window"; - - RegisterClass(&wc); - -} - -PRUint32 RunEventLoop(PRBool &aRunCondition) -{ - MSG msg; - while (aRunCondition ) - { - ::GetMessage(&msg, NULL, 0, 0); - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - - return msg.wParam; + prefBranch->SetBoolPref("snav.keyCode.modifier", 0); } PRBool CheckForProcess() @@ -237,95 +205,56 @@ PRBool CheckForProcess() return TRUE; } - int main(int argc, char *argv[]) { if (!CheckForProcess()) return 0; + CreateSplashScreen(); + #ifdef _BUILD_STATIC_BIN // Initialize XPCOM's module info table NSGetStaticModuleInfo = app_getModuleInfo; #endif - - // Init Embedding APIs NS_InitEmbedding(nsnull, nsnull); - // Choose the new profile if (NS_FAILED(StartupProfile())) - { - NS_TermEmbedding(); return 1; - } - RegisterMainWindowClass(); - SetPreferences(); - WindowCreator *creatorCallback = new WindowCreator(); + NS_TIMELINE_ENTER("appStartup"); + nsCOMPtr appShell = do_CreateInstance(kAppShellCID); + appShell->Create(nsnull, nsnull); + + ApplicationObserver *appObserver = new ApplicationObserver(appShell); + if (!appObserver) + return 1; + NS_ADDREF(appObserver); + + WindowCreator *creatorCallback = new WindowCreator(appShell); if (!creatorCallback) return 1; - const static char* start_url = "chrome://minimo/content/minimo.xul"; - //const static char* start_url = "http://www.meer.net/~dougt/test.html"; - - nsCOMPtr newWindow; nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); - - wwatch->SetWindowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)); - wwatch->OpenWindow(nsnull, start_url, "_blank", "chrome,dialog=no,all", nsnull, getter_AddRefs(newWindow)); - - RunEventLoop(gRunCondition); + wwatch->SetWindowCreator(creatorCallback); - // Null things out before going away. - - newWindow = nsnull; + nsCOMPtr newWindow; + wwatch->OpenWindow(nsnull, start_url, "_blank", "chrome,dialog=no,all", nsnull, getter_AddRefs(newWindow)); + + appShell->Run(); + + appShell = nsnull; wwatch = nsnull; + newWindow = nsnull; + + delete appObserver; + delete creatorCallback; // Close down Embedding APIs NS_TermEmbedding(); return NS_OK; } - -nativeWindow -WebBrowserChromeUI::CreateNativeWindow(nsIWebBrowserChrome* chrome) -{ - HWND mainWindow = CreateWindow("Minimo Main Window", - "Minimo", - WS_VISIBLE, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - NULL, - NULL, - GetModuleHandle(NULL), - NULL); - - SetWindowLong(mainWindow, GWL_USERDATA, (LONG)chrome); // save the browser LONG_PTR. - - PostMessage(mainWindow, WM_ACTIVATE, WA_ACTIVE, 0); - - SHFullScreen(mainWindow, SHFS_HIDETASKBAR); - SHFullScreen(mainWindow, SHFS_HIDESIPBUTTON); - - ::ShowWindow(mainWindow, SW_SHOW); - - gBrowserCount++; - - return mainWindow; -} - -void -WebBrowserChromeUI::Destroy(nsIWebBrowserChrome* chrome) -{ - if (--gBrowserCount == 0) - { - // Quit when there are no more browser objects - PostQuitMessage(0); - } -} -