diff --git a/jdk/src/macosx/native/sun/awt/AWTView.h b/jdk/src/macosx/native/sun/awt/AWTView.h index 1ba06fefb62..7db360857d9 100644 --- a/jdk/src/macosx/native/sun/awt/AWTView.h +++ b/jdk/src/macosx/native/sun/awt/AWTView.h @@ -38,6 +38,9 @@ // TODO: NSMenu *contextualMenu; + // Keyboard layout + NSString *kbdLayout; + // dnd support (see AppKit/NSDragging.h, NSDraggingSource/Destination): CDragSource *_dragSource; CDropTarget *_dropTarget; diff --git a/jdk/src/macosx/native/sun/awt/AWTView.m b/jdk/src/macosx/native/sun/awt/AWTView.m index 29dd6410eaf..9a0357e16a1 100644 --- a/jdk/src/macosx/native/sun/awt/AWTView.m +++ b/jdk/src/macosx/native/sun/awt/AWTView.m @@ -40,6 +40,9 @@ #import "OSVersion.h" #import "CGLLayer.h" +// Constant for keyman layouts +#define KEYMAN_LAYOUT "keyman" + @interface AWTView() @property (retain) CDropTarget *_dropTarget; @property (retain) CDragSource *_dragSource; @@ -284,7 +287,7 @@ - (void) scrollWheel: (NSEvent*) event { - (void) keyDown: (NSEvent *)event { fProcessingKeystroke = YES; - fKeyEventsNeeded = YES; + fKeyEventsNeeded = ![(NSString *)kbdLayout containsString:@KEYMAN_LAYOUT]; // Allow TSM to look at the event and potentially send back NSTextInputClient messages. [self interpretKeyEvents:[NSArray arrayWithObject:event]]; @@ -966,7 +969,8 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange NSUInteger utf8Length = [aString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; BOOL aStringIsComplex = NO; if ((utf16Length > 2) || - ((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:[aString characterAtIndex:0]])) { + ((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:[aString characterAtIndex:0]]) || + [(NSString *)kbdLayout containsString:@KEYMAN_LAYOUT]) { aStringIsComplex = YES; } @@ -1001,6 +1005,15 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange } +- (void)keyboardInputSourceChanged:(NSNotification *)notification +{ +#ifdef IM_DEBUG + NSLog(@"keyboardInputSourceChangeNotification received"); +#endif + NSTextInputContext *curContxt = [NSTextInputContext currentInputContext]; + kbdLayout = curContxt.selectedKeyboardInputSource; +} + - (void) doCommandBySelector:(SEL)aSelector { #ifdef IM_DEBUG @@ -1326,6 +1339,13 @@ - (void)setInputMethod:(jobject)inputMethod fInputMethodLOCKABLE = JNFNewGlobalRef(env, inputMethod); else fInputMethodLOCKABLE = NULL; + + NSTextInputContext *curContxt = [NSTextInputContext currentInputContext]; + kbdLayout = curContxt.selectedKeyboardInputSource; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(keyboardInputSourceChanged:) + name:NSTextInputContextKeyboardSelectionDidChangeNotification + object:nil]; } - (void)abandonInput