Skip to content

Commit 8b9a009

Browse files
committed
JBR-4638 Regression: Unable to enter emoji in editor via Emoji & Symbols on macOS
1 parent 37e9566 commit 8b9a009

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

Diff for: src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java

+19-20
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public void removeNotify() {
271271
nativeEndComposition(getNativeViewPtr(fAwtFocussedComponentPeer));
272272
}
273273

274+
fAwtFocussedComponent = null;
274275
fAwtFocussedComponentPeer = null;
275276
}
276277

@@ -281,34 +282,32 @@ public void removeNotify() {
281282
* to talk to when responding to key events.
282283
*/
283284
protected void setAWTFocussedComponent(Component component) {
284-
LWComponentPeer<?, ?> peer = null;
285-
long modelPtr = 0;
286-
CInputMethod imInstance = this;
287-
288-
// component will be null when we are told there's no focused component.
289-
// When that happens we need to notify the native architecture to stop generating IMEs
290-
if (component == null) {
291-
peer = fAwtFocussedComponentPeer;
292-
imInstance = null;
293-
} else {
294-
peer = getNearestNativePeer(component);
285+
if (component == null || component == fAwtFocussedComponent) {
286+
// Sometimes input happens for the natively unfocused window
287+
// (e.g. in case of system emoji picker),
288+
// so we don't reset last focused component on focus lost.
289+
return;
290+
}
291+
292+
if (fAwtFocussedComponentPeer != null) {
293+
long modelPtr = getNativeViewPtr(fAwtFocussedComponentPeer);
294+
nativeNotifyPeer(modelPtr, null);
295+
}
296+
297+
fAwtFocussedComponent = component;
298+
fAwtFocussedComponentPeer = getNearestNativePeer(component);
299+
300+
if (fAwtFocussedComponentPeer != null) {
301+
long modelPtr = getNativeViewPtr(fAwtFocussedComponentPeer);
295302

303+
CInputMethod imInstance = this;
296304
// If we have a passive client, don't pass input method events to it.
297305
if (component.getInputMethodRequests() == null) {
298306
imInstance = null;
299307
}
300-
}
301308

302-
if (peer != null) {
303-
modelPtr = getNativeViewPtr(peer);
304-
305-
// modelPtr refers to the ControlModel that either got or lost focus.
306309
nativeNotifyPeer(modelPtr, imInstance);
307310
}
308-
309-
// Track the focused component and its nearest peer.
310-
fAwtFocussedComponent = component;
311-
fAwtFocussedComponentPeer = getNearestNativePeer(component);
312311
}
313312

314313
/**

0 commit comments

Comments
 (0)