8213292: Input freezes after MacOS key-selector (press&hold) usage on macOS Mojave
Reviewed-by: serb
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m Thu Nov 08 17:10:47 2018 +0100
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m Wed Nov 14 13:52:33 2018 -0800
@@ -34,6 +34,7 @@
#import "OSVersion.h"
#import "ThreadUtilities.h"
+#import <Carbon/Carbon.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
@interface AWTView()
@@ -281,11 +282,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 {
+ // Abandon input to reset IM and unblock input after canceling
+ // input accented symbols
+
+ 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 +999,11 @@
}
}
fPAHNeedsToSelect = NO;
+
+ // Abandon input to reset IM and unblock input after entering accented
+ // symbols
+
+ [self abandonInput];
}
- (void) doCommandBySelector:(SEL)aSelector