# HG changeset patch # User Alexey Ushakov # Date 1541166209 -10800 # Fri Nov 02 16:43:29 2018 +0300 # Node ID f32047c51d5674361a3a8cd2b381df453fd5d0d9 # Parent 56585eb1031428fa7862f48dbc005b7d5d814d66 8213292 Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave Call abandonInput to reset input methods after entering accented symbols diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m @@ -34,6 +34,7 @@ #import "OSVersion.h" #import "ThreadUtilities.h" +#import #import @interface AWTView() @@ -58,6 +59,13 @@ return shouldUsePressAndHold; } +#ifndef kCFCoreFoundationVersionNumber10_13_Max +#define kCFCoreFoundationVersionNumber10_13_Max 1499 +#endif + +#define IS_OSX_GT10_13 (floor(kCFCoreFoundationVersionNumber) > \ + kCFCoreFoundationVersionNumber10_13_Max) + @implementation AWTView @synthesize _dropTarget; @@ -281,11 +289,31 @@ // Allow TSM to look at the event and potentially send back NSTextInputClient messages. [self interpretKeyEvents:[NSArray arrayWithObject:event]]; - if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod] && fInputMethodLOCKABLE) { + if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod] && + fInputMethodLOCKABLE) + { fProcessingKeystroke = NO; if (!fInPressAndHold) { fInPressAndHold = YES; fPAHNeedsToSelect = YES; + } else if (IS_OSX_GT10_13) { + // Abandon input to reset IM and unblock input after canceling + // input accented symbols (macOS 10.14+ only) + + switch([event keyCode]) { + case kVK_Escape: + case kVK_Delete: + case kVK_Return: + case kVK_ForwardDelete: + case kVK_PageUp: + case kVK_PageDown: + case kVK_DownArrow: + case kVK_UpArrow: + case kVK_Home: + case kVK_End: + [self abandonInput]; + break; + } } return; } @@ -978,6 +1006,13 @@ } } fPAHNeedsToSelect = NO; + + // Abandon input to reset IM and unblock input after entering accented + // symbols (macOS 10.14+ only) + + if (IS_OSX_GT10_13) { + [self abandonInput]; + } } - (void) doCommandBySelector:(SEL)aSelector