@@ -951,8 +951,16 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
951951 NSUInteger utf16Length = [useString lengthOfBytesUsingEncoding: NSUTF16StringEncoding];
952952 NSUInteger utf8Length = [useString lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
953953 BOOL aStringIsComplex = NO ;
954+
955+ unichar codePoint = [useString characterAtIndex: 0 ];
956+
957+ #ifdef IM_DEBUG
958+ NSLog (@" insertText kbdlayout %@ " ,(NSString *)kbdLayout);
959+ #endif // IM_DEBUG
960+
954961 if ((utf16Length > 2 ) ||
955- ((utf8Length > 1 ) && [self isCodePointInUnicodeBlockNeedingIMEvent: [useString characterAtIndex: 0 ]])) {
962+ ((utf8Length > 1 ) && [self isCodePointInUnicodeBlockNeedingIMEvent: codePoint]) ||
963+ ((codePoint == 0x5c ) && ([(NSString *)kbdLayout containsString: @" Kotoeri" ]))) {
956964 aStringIsComplex = YES ;
957965 }
958966
@@ -990,6 +998,15 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
990998 [self abandonInput ];
991999}
9921000
1001+ - (void )keyboardInputSourceChanged : (NSNotification *)notification
1002+ {
1003+ #ifdef IM_DEBUG
1004+ NSLog (@" keyboardInputSourceChangeNotification received" );
1005+ #endif
1006+ NSTextInputContext *curContxt = [NSTextInputContext currentInputContext ];
1007+ kbdLayout = curContxt.selectedKeyboardInputSource ;
1008+ }
1009+
9931010- (void ) doCommandBySelector : (SEL )aSelector
9941011{
9951012#ifdef IM_DEBUG
@@ -1315,6 +1332,13 @@ - (void)setInputMethod:(jobject)inputMethod
13151332 fInputMethodLOCKABLE = JNFNewGlobalRef (env, inputMethod);
13161333 else
13171334 fInputMethodLOCKABLE = NULL ;
1335+
1336+ NSTextInputContext *curContxt = [NSTextInputContext currentInputContext ];
1337+ kbdLayout = curContxt.selectedKeyboardInputSource ;
1338+ [[NSNotificationCenter defaultCenter ] addObserver: self
1339+ selector: @selector (keyboardInputSourceChanged: )
1340+ name: NSTextInputContextKeyboardSelectionDidChangeNotification
1341+ object: nil ];
13181342}
13191343
13201344- (void )abandonInput
0 commit comments