Mac applicationDockMenu delegate method not called after process restart. Patch by Steven Michaud. r=josh r=bsmedberg
authorjoshmoz@gmail.com
Wed, 16 May 2007 19:10:19 -0700
changeset 1549 8933e23c8ac94479fe4542b9c800504b8bb87b18
parent 1548 56b7ac0c1b0f2a348aa5d3815eba48296a0763f8
child 1550 b27fb672c55b9b762c12563dce430e2f0a8f1f92
push idunknown
push userunknown
push dateunknown
reviewersjosh, bsmedberg
milestone1.9a5pre
Mac applicationDockMenu delegate method not called after process restart. Patch by Steven Michaud. r=josh r=bsmedberg
toolkit/xre/MacApplicationDelegate.h
toolkit/xre/MacApplicationDelegate.mm
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/MacApplicationDelegate.h
+++ b/toolkit/xre/MacApplicationDelegate.h
@@ -37,11 +37,12 @@
  * ***** END LICENSE BLOCK ***** */
 
 // This file defines the interface between Cocoa-specific Obj-C++ and generic C++,
 // so it itself cannot have any Obj-C bits in it.
 
 #ifndef __MacApplicationDelegate_h__
 #define __MacApplicationDelegate_h__
 
+void EnsureUseCocoaDockAPI(void);
 void SetupMacApplicationDelegate(void);
 
 #endif
--- a/toolkit/xre/MacApplicationDelegate.mm
+++ b/toolkit/xre/MacApplicationDelegate.mm
@@ -58,16 +58,24 @@
 @interface MacApplicationDelegate : NSObject
 {
 }
 
 @end
 
 // Something to call from non-objective code.
 
+// This is needed, on relaunch, to force the OS to use the "Cocoa Dock API"
+// instead of the "Carbon Dock API".  For more info see bmo bug 377166.
+void
+EnsureUseCocoaDockAPI()
+{
+  [NSApplication sharedApplication];
+}
+
 void
 SetupMacApplicationDelegate()
 {
   // Create the delegate. This should be around for the lifetime of the app.
   MacApplicationDelegate *delegate = [[MacApplicationDelegate alloc] init];
   [[NSApplication sharedApplication] setDelegate:delegate];
 }
 
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -45,18 +45,16 @@
 #define XPCOM_TRANSLATE_NSGM_ENTRY_POINT 1
 
 #include "nsAppRunner.h"
 #include "nsUpdateDriver.h"
 #include "nsBuildID.h"
 
 #ifdef XP_MACOSX
 #include "MacLaunchHelper.h"
-#endif
-#ifdef MOZ_WIDGET_COCOA
 #include "MacApplicationDelegate.h"
 #endif
 
 #ifdef XP_OS2
 #include "private/pprthred.h"
 #endif
 #include "prmem.h"
 #include "prnetdb.h"
@@ -2337,16 +2335,21 @@ XRE_main(int argc, char* argv[], const n
     
     rv = CallQueryInterface(greDir, &appData.xreDirectory);
     if (NS_FAILED(rv))
       return 2;
   }
 
 #ifdef XP_MACOSX
   if (PR_GetEnv("MOZ_LAUNCHED_CHILD")) {
+    // This is needed, on relaunch, to force the OS to use the "Cocoa Dock
+    // API".  Otherwise the call to ReceiveNextEvent() below will make it
+    // use the "Carbon Dock API".  For more info see bmo bug 377166.
+    EnsureUseCocoaDockAPI();
+
     // When the app relaunches, the original process exits.  This causes
     // the dock tile to stop bouncing, lose the "running" triangle, and
     // if the tile does not permanently reside in the Dock, even disappear.
     // This can be confusing to the user, who is expecting the app to launch.
     // Calling ReceiveNextEvent without requesting any event is enough to
     // cause a dock tile for the child process to appear.
     const EventTypeSpec kFakeEventList[] = { { INT_MAX, INT_MAX } };
     EventRef event;