Bug 422888 Cannot change the inputting mode by shortcut keys of AquaSKK without non-needed char inputting r=josh, sr=vlad, b1.9=josh

This commit is contained in:
masayuki@d-toybox.com 2008-03-30 02:17:50 -07:00
Родитель febc417c9a
Коммит f73bffde43
1 изменённых файлов: 31 добавлений и 8 удалений

Просмотреть файл

@ -3810,6 +3810,20 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode)
}
static PRBool IsNormalCharInputtingEvent(const nsKeyEvent& aEvent)
{
// this is not character inputting event, simply.
if (!aEvent.isChar || !aEvent.charCode)
return PR_FALSE;
// if this is unicode char inputting event, we don't need to check
// ctrl/alt/command keys
if (aEvent.charCode > 0x7F)
return PR_TRUE;
// ASCII chars should be inputted without ctrl/alt/command keys
return !aEvent.isControl && !aEvent.isAlt && !aEvent.isMeta;
}
// Basic conversion for cocoa to gecko events, common to all conversions.
// Note that it is OK for inEvent to be nil.
- (void) convertGenericCocoaEvent:(NSEvent*)inEvent toGeckoEvent:(nsInputEvent*)outGeckoEvent
@ -4459,8 +4473,11 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode)
// We don't do it if this came from performKeyEquivalent because
// interpretKeyEvents isn't set up to handle those key combinations.
PRBool wasComposing = nsTSMManager::IsComposing();
if (!isKeyEquiv && nsTSMManager::IsIMEEnabled())
PRBool interpretKeyEventsCalled = PR_FALSE;
if (!isKeyEquiv && nsTSMManager::IsIMEEnabled()) {
[super interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
interpretKeyEventsCalled = PR_TRUE;
}
if (!mGeckoChild)
return (mKeyDownHandled || mKeyPressHandled);;
@ -4468,6 +4485,11 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode)
if (!mKeyPressSent && nonDeadKeyPress && !wasComposing && !nsTSMManager::IsComposing()) {
nsKeyEvent geckoEvent(PR_TRUE, NS_KEY_PRESS, nsnull);
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&geckoEvent];
// If we called interpretKeyEvents and this isn't normal character input
// then IME probably ate the event for some reason. We do not want to
// send a key press event in that case.
if (!(interpretKeyEventsCalled && IsNormalCharInputtingEvent(geckoEvent))) {
if (mKeyDownHandled)
geckoEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
@ -4478,6 +4500,7 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode)
mKeyPressHandled = mGeckoChild->DispatchWindowEvent(geckoEvent);
}
}
// Note: mGeckoChild might have become null here. Don't count on it from here on.