diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 06416b05872..5a74cee7071 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -3979,7 +3979,7 @@ static PRBool IsNormalCharInputtingEvent(const nsKeyEvent& aEvent) kbType, 0, &deadKeyState, 1, &len, chars); if (noErr == err && len > 0) shiftedCmdChar = chars[0]; - } else if (handle = (char**)::GetScriptManagerVariable(smKCHRCache)) { + } else if ((handle = (char**)::GetScriptManagerVariable(smKCHRCache))) { UInt32 state = 0; UInt32 keyCode = [aKeyEvent keyCode]; unshiftedChar = ::KeyTranslate(handle, keyCode, &state) & charCodeMask; @@ -4851,10 +4851,22 @@ static BOOL keyUpAlreadySentKeyDown = NO; // Perform native menu UI feedback even if we stop the event from propagating to it normally. // Recall that the menu system won't actually execute any commands for keyboard command invocations. - // By checking the class for the main menu we ensure that we don't do any of this for embedders. + // + // If this is a plugin, we do actually perform the action on keyboard commands. See bug 428047. + // If the action on plugins here changes the first responder, don't continue. NSMenu* mainMenu = [NSApp mainMenu]; - if ([mainMenu isKindOfClass:[GeckoNSMenu class]]) - [(GeckoNSMenu*)mainMenu performMenuUserInterfaceEffectsForEvent:theEvent]; + if (mIsPluginView) { + if ([mainMenu isKindOfClass:[GeckoNSMenu class]]) + [(GeckoNSMenu*)mainMenu actOnKeyEquivalent:theEvent]; + else + [mainMenu performKeyEquivalent:theEvent]; + if ([[self window] firstResponder] != self) + return YES; + } + else { + if ([mainMenu isKindOfClass:[GeckoNSMenu class]]) + [(GeckoNSMenu*)mainMenu performMenuUserInterfaceEffectsForEvent:theEvent]; + } // don't handle this if certain modifiers are down - those should // be sent as normal key up/down events and cocoa will do so automatically diff --git a/widget/src/cocoa/nsMenuBarX.h b/widget/src/cocoa/nsMenuBarX.h index ead4be0bbb2..c2cffe0fff5 100644 --- a/widget/src/cocoa/nsMenuBarX.h +++ b/widget/src/cocoa/nsMenuBarX.h @@ -77,6 +77,7 @@ namespace MenuHelpersX { } - (BOOL)performKeyEquivalent:(NSEvent *)theEvent; +- (void)actOnKeyEquivalent:(NSEvent *)theEvent; - (void)performMenuUserInterfaceEffectsForEvent:(NSEvent*)theEvent; @end diff --git a/widget/src/cocoa/nsMenuBarX.mm b/widget/src/cocoa/nsMenuBarX.mm index 673b5604c5d..489a3ce9b32 100644 --- a/widget/src/cocoa/nsMenuBarX.mm +++ b/widget/src/cocoa/nsMenuBarX.mm @@ -949,8 +949,10 @@ NSMenuItem* MenuHelpersX::GetStandardEditMenuItem() // is nil, it is not on the stack. The non-nil value is the object that put it // on the stack first. static GeckoNSMenu* gPerformKeyEquivOnStack = nil; -// When this variable is set to YES, don't do special command processing. -static BOOL gMenuEffectsOnly = NO; +// If this is YES, act on key equivs. +static BOOL gActOnKeyEquiv = NO; +// When this variable is set to NO, don't do special command processing. +static BOOL gActOnSpecialCommands = YES; @implementation GeckoNSMenu @@ -976,11 +978,19 @@ static BOOL gMenuEffectsOnly = NO; } +-(void)actOnKeyEquivalent:(NSEvent *)theEvent +{ + gActOnKeyEquiv = YES; + [self performKeyEquivalent:theEvent]; + gActOnKeyEquiv = NO; +} + + - (void)performMenuUserInterfaceEffectsForEvent:(NSEvent*)theEvent { - gMenuEffectsOnly = YES; + gActOnSpecialCommands = NO; [self performKeyEquivalent:theEvent]; - gMenuEffectsOnly = NO; + gActOnSpecialCommands = YES; } @end @@ -1006,7 +1016,7 @@ static BOOL gMenuEffectsOnly = NO; // We want to avoid processing app-global commands when we are asked to // perform native menu effects only. This avoids sending events twice, // which can lead to major problems. - if (!gMenuEffectsOnly) { + if (gActOnSpecialCommands) { // Do special processing if this is for an app-global command. if (tag == eCommand_ID_About) { nsIContent* mostSpecificContent = sAboutItemContent; @@ -1042,7 +1052,7 @@ static BOOL gMenuEffectsOnly = NO; // is no main window then the hidden window menu bar is up, even // if that isn't true for some reason we better play it safe if // there is no main window. - if (gPerformKeyEquivOnStack && [NSApp mainWindow]) + if (gPerformKeyEquivOnStack && !gActOnKeyEquiv && [NSApp mainWindow]) return; // given the commandID, look it up in our hashtable and dispatch to