From c746ea5e3633a537f374b8430a03b5928abd9639 Mon Sep 17 00:00:00 2001 From: "lordpixel%mac.com" Date: Thu, 26 Sep 2002 03:38:06 +0000 Subject: [PATCH] Fix for bug 90823 Relaunching or clicking Dock icon should display last minimized window or create new window r=sdagley, sr=smfr --- xpfe/appshell/public/nsINativeAppSupport.idl | 1 + xpfe/bootstrap/nsAppRunner.cpp | 66 +++++++++++-------- xpfe/bootstrap/nsNativeAppSupportBase.cpp | 6 ++ .../startup/public/nsINativeAppSupport.idl | 1 + 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/xpfe/appshell/public/nsINativeAppSupport.idl b/xpfe/appshell/public/nsINativeAppSupport.idl index c0446fa2c658..9f198a7b2c05 100644 --- a/xpfe/appshell/public/nsINativeAppSupport.idl +++ b/xpfe/appshell/public/nsINativeAppSupport.idl @@ -188,4 +188,5 @@ interface nsINativeAppSupport : nsISupports { void startServerMode(); void onLastWindowClosing(); + void ReOpen(); }; diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 4512ef81783d..9473add20773 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -341,7 +341,7 @@ static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); /*********************************************/ // Default implemenations for nativeAppSupport // If your platform implements these functions if def out this code. -#if !defined (XP_MAC) && !defined(MOZ_WIDGET_COCOA) && !defined(MOZ_WIDGET_PHOTON) && !defined( XP_PC ) && !defined( XP_BEOS ) && !defined(MOZ_WIDGET_GTK) +#if !defined(MOZ_WIDGET_COCOA) && !defined(MOZ_WIDGET_PHOTON) && !defined( XP_PC ) && !defined( XP_BEOS ) && !defined(MOZ_WIDGET_GTK) nsresult NS_CreateSplashScreen(nsISplashScreen **aResult) { @@ -375,7 +375,8 @@ PRBool NS_CanRun() // then rely on nsINativeAppSupport and its use of // nsISplashScreen will be removed. // -#if !defined( XP_PC ) && !defined(MOZ_WIDGET_GTK) + +#if !defined( XP_PC ) && !defined( XP_BEOS ) && !defined(MOZ_WIDGET_GTK) && !defined(XP_MAC) nsresult NS_CreateNativeAppSupport(nsINativeAppSupport **aResult) { @@ -1289,6 +1290,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) { nsresult rv; NS_TIMELINE_ENTER("main1"); + nsCOMPtr nativeAppOwner(nativeApp); //---------------------------------------------------------------- // First we need to check if a previous installation occured and @@ -1334,10 +1336,11 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) nsCOMPtr obsService(do_GetService("@mozilla.org/observer-service;1")); if (obsService) { - nsCOMPtr splashScreenObserver(do_QueryInterface(nativeApp)); + nsCOMPtr splashScreenObserver(do_QueryInterface(nativeAppOwner)); if (splashScreenObserver) { obsService->AddObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID, PR_FALSE); + obsService->AddObserver(splashScreenObserver, "startup_user_notifcations", PR_FALSE); } } @@ -1357,16 +1360,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) #endif - // remove the nativeApp as an XPCOM autoreg observer - if (obsService) - { - nsCOMPtr splashScreenObserver(do_QueryInterface(nativeApp)); - if (splashScreenObserver) - { - obsService->RemoveObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID); - } - } - NS_TIMELINE_ENTER("startupNotifier"); // Start up the core services: @@ -1412,21 +1405,24 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) /* if we couldn't get the nsIAppShellService service, then we should hide the splash screen and return */ - if (NS_FAILED(rv)) { + if (NS_FAILED(rv)) + { // See if platform supports nsINativeAppSupport. - nsCOMPtr nativeAppSupport(do_QueryInterface(nativeApp)); - if (nativeAppSupport) { + nsCOMPtr nativeAppSupport(do_QueryInterface(nativeAppOwner)); + if (nativeAppSupport) + { // Use that interface to remove splash screen. nativeAppSupport->HideSplashScreen(); - } else { + } + else + { // See if platform supports nsISplashScreen, instead. - nsCOMPtr splashScreen(do_QueryInterface(nativeApp)); - if (splashScreen) { + nsCOMPtr splashScreen(do_QueryInterface(nativeAppOwner)); + if (splashScreen) + { splashScreen->Hide(); } } - // Release argument object. - NS_IF_RELEASE(nativeApp); return rv; } @@ -1435,14 +1431,10 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) NS_TIMELINE_ENTER("appShell->Initialize"); // Create the Application Shell instance... - rv = appShell->Initialize(cmdLineArgs, nativeApp); + rv = appShell->Initialize(cmdLineArgs, nativeAppOwner); NS_TIMELINE_LEAVE("appShell->Initialize"); - // We are done with the native app (or splash screen) object here; - // the app shell owns it now. - NS_IF_RELEASE(nativeApp); - NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appshell"); if (NS_FAILED(rv)) return rv; @@ -1482,6 +1474,13 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) NS_WARNING("failed to process command line"); return rv; } + + if (obsService) + { + nsAutoString userMessage; userMessage.AssignWithConversion("Creating first window..."); + obsService->NotifyObservers(nsnull, "startup_user_notifcations", userMessage.get()); + } + // Make sure there exists at least 1 window. NS_TIMELINE_ENTER("Ensure1Window"); @@ -1503,6 +1502,21 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) remoteService->Startup(); #endif /* MOZ_ENABLE_XREMOTE */ + // remove the nativeApp as an XPCOM autoreg observer + if (obsService) + { + nsCOMPtr splashScreenObserver(do_QueryInterface(nativeAppOwner)); + if (splashScreenObserver) + { + obsService->RemoveObserver(splashScreenObserver, NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID); + obsService->RemoveObserver(splashScreenObserver, "startup_user_notifcations"); + } + } + + // We are done with the native app (or splash screen) object here; + // the app shell owns it now. + nativeAppOwner = nsnull; + // Start main event loop NS_TIMELINE_ENTER("appShell->Run"); rv = appShell->Run(); diff --git a/xpfe/bootstrap/nsNativeAppSupportBase.cpp b/xpfe/bootstrap/nsNativeAppSupportBase.cpp index 13f0d016c395..a5e4aea3fb8d 100644 --- a/xpfe/bootstrap/nsNativeAppSupportBase.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportBase.cpp @@ -72,6 +72,12 @@ nsNativeAppSupportBase::Quit() { return NS_OK; } +NS_IMETHODIMP +nsNativeAppSupportBase::ReOpen() +{ + return NS_OK; +} + // Show splash screen if implementation has one. NS_IMETHODIMP nsNativeAppSupportBase::ShowSplashScreen() { diff --git a/xpfe/components/startup/public/nsINativeAppSupport.idl b/xpfe/components/startup/public/nsINativeAppSupport.idl index c0446fa2c658..9f198a7b2c05 100644 --- a/xpfe/components/startup/public/nsINativeAppSupport.idl +++ b/xpfe/components/startup/public/nsINativeAppSupport.idl @@ -188,4 +188,5 @@ interface nsINativeAppSupport : nsISupports { void startServerMode(); void onLastWindowClosing(); + void ReOpen(); };