From 1a0e429da23bcf46b78ee6403c1ec5cd145e28af Mon Sep 17 00:00:00 2001 From: "sdagley%netscape.com" Date: Tue, 8 Oct 2002 23:09:00 +0000 Subject: [PATCH] #56589 - Add shared menus support (requires version 1.2 of SharedMenus.component) for CFM version of Mozilla for Mac OS X. r=bnesse,sr=sfraser git-svn-id: svn://10.0.0.236/trunk@131488 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/macbuild/widget.xml | 50 +++++++++++++++++++++ mozilla/widget/src/mac/nsMacMessagePump.cpp | 32 +++++++++++++ mozilla/widget/src/mac/nsMenuBarX.cpp | 18 ++++++++ 3 files changed, 100 insertions(+) diff --git a/mozilla/widget/macbuild/widget.xml b/mozilla/widget/macbuild/widget.xml index e02f9b91def..ad614d7c270 100644 --- a/mozilla/widget/macbuild/widget.xml +++ b/mozilla/widget/macbuild/widget.xml @@ -3261,6 +3261,16 @@ FrameworkPathfalse HostFlagsAll + + SearchPath + Path:MacOS Support:(Third Party Support):Carbonized Menu Sharing: + PathFormatMacOS + PathRootCodeWarrior + + Recursivetrue + FrameworkPathfalse + HostFlagsAll + SystemSearchPaths @@ -4444,6 +4454,13 @@ Library Debug + + Name + MenuSharing.c + MacOS + Text + Debug + @@ -4716,6 +4733,11 @@ WidgetSupportDebug.shlb MacOS + + Name + MenuSharing.c + MacOS + @@ -4800,6 +4822,16 @@ FrameworkPathfalse HostFlagsAll + + SearchPath + Path:MacOS Support:(Third Party Support):Carbonized Menu Sharing: + PathFormatMacOS + PathRootCodeWarrior + + Recursivetrue + FrameworkPathfalse + HostFlagsAll + SystemSearchPaths @@ -5983,6 +6015,13 @@ Library Debug + + Name + MenuSharing.c + MacOS + Text + Debug + @@ -6255,6 +6294,11 @@ WidgetSupport.shlb MacOS + + Name + MenuSharing.c + MacOS + @@ -6311,6 +6355,12 @@ nsTSMStrategy.cpp MacOS + + widgetCarbonDebug.shlb + Name + MenuSharing.c + MacOS + Mac Apps diff --git a/mozilla/widget/src/mac/nsMacMessagePump.cpp b/mozilla/widget/src/mac/nsMacMessagePump.cpp index 9de9fb17750..454cc9b9cd8 100644 --- a/mozilla/widget/src/mac/nsMacMessagePump.cpp +++ b/mozilla/widget/src/mac/nsMacMessagePump.cpp @@ -86,6 +86,9 @@ #include "nsISocketTransportService.h" #include "nsIFileTransportService.h" +#if TARGET_CARBON && !XP_MACOSX +#include "MenuSharing.h" +#endif #ifndef topLeft #define topLeft(r) (((Point *) &(r))[0]) @@ -189,6 +192,22 @@ static long ConvertOSMenuResultToPPMenuResult(long menuResult) } #pragma mark - +#if TARGET_CARBON && !XP_MACOSX +#pragma mark MenuSharingToolkitSupport +//================================================================= +static pascal void ErrorDialog (Str255 s) +{ + //ParamText (s, "\p", "\p", "\p"); + //Alert (kMenuSharingAlertID, nil); +} + +//================================================================= +static pascal void EventFilter (EventRecord *ev) +{ + // Hrm, prolly should do _something_ here +} +#pragma mark - +#endif static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); @@ -214,6 +233,11 @@ nsMacMessagePump::nsMacMessagePump(nsToolkit *aToolkit) // startup the watch cursor idle time vbl task nsWatchTask::GetTask().Start(); + +#if TARGET_CARBON && !XP_MACOSX + // added to support Menu Sharing API. Initializes the Menu Sharing API. + InitSharedMenus (ErrorDialog, EventFilter); +#endif } //================================================================= @@ -983,6 +1007,14 @@ void nsMacMessagePump::DoIdle(EventRecord &anEvent) // send mouseMove event static Point lastWhere = {0, 0}; +#if TARGET_CARBON && !XP_MACOSX + if ( nsToolkit::IsAppInForeground() ) + { + // Shared Menu support - note we hardcode first menu ID available as 31000 + CheckSharedMenus(31000); + } +#endif + if (*(long*)&lastWhere == *(long*)&anEvent.where) return; diff --git a/mozilla/widget/src/mac/nsMenuBarX.cpp b/mozilla/widget/src/mac/nsMenuBarX.cpp index 063a480edcf..e0dc8559f64 100644 --- a/mozilla/widget/src/mac/nsMenuBarX.cpp +++ b/mozilla/widget/src/mac/nsMenuBarX.cpp @@ -70,6 +70,10 @@ #include "nsGUIEvent.h" +#if !XP_MACOSX +#include "MenuSharing.h" +#endif + // CIDs #include "nsWidgetsCID.h" static NS_DEFINE_CID(kMenuBarCID, NS_MENUBAR_CID); @@ -351,6 +355,20 @@ nsMenuBarX :: CommandEventHandler ( EventHandlerCallRef inHandlerChain, EventRef break; } +#if !XP_MACOSX + case 'SHMN': + { // Shared menu support + MenuItemIndex index = command.menu.menuItemIndex; + if (index) + { + (void)SharedMenuHit(GetMenuID(command.menu.menuRef), command.menu.menuItemIndex); + ::HiliteMenu(0); + handled = noErr; + } + break; + } +#endif + default: { // given the commandID, look it up in our hashtable and dispatch to