Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8195675: Call to insertText with single character from custom Input Method ignored #595

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jdk/src/macosx/native/sun/awt/AWTView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

// TODO: NSMenu *contextualMenu;

// Keyboard layout
NSString *kbdLayout;

// dnd support (see AppKit/NSDragging.h, NSDraggingSource/Destination):
CDragSource *_dragSource;
CDropTarget *_dropTarget;
Expand Down
24 changes: 22 additions & 2 deletions jdk/src/macosx/native/sun/awt/AWTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]];
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down