On Tue, 4 Jul 2023 05:54:54 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
> When Japanse (IME on) is inputted to the TextFIeld, which is on JFXPanel, > small window for inputting appears on top-left side of screen > >  > > For swing-interop case, WmImeStartComposition starts composition in native > ImmSetCompositionWindow window as "m_useNativeCompWindow" below is true for FX > https://github.com/openjdk/jdk/blob/514816ed7d7dea1fb13d32b80aef89774bee13d3/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp#L3957 > > m_useNativeCompWindow is true because during > sun.awt.im.InputContext#focusGained() calls activateInputMethod which calls > WInputMethod.activate() which calls haveActiveClient() which checks for > clientComponent.getInputMethodRequests(). > Now, in JFXPanel, getInputMethodRequests() returns null as setEmbeddedScene() > is not called yet. > Since getInputMethodRequests() returns null, haveActiveClient() is false > which calls enableNativeIME() with 1 [thereby native composition window is > enabled] > https://github.com/openjdk/jdk/blob/514816ed7d7dea1fb13d32b80aef89774bee13d3/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java#L316 > > Proposed fix is to ensure there is an active client "initially" so that > enableNativeIME() is called with 0 and no native compostion window is shown. > getInputMethodRequests() is called in setEmbeddedScene() so as to make sure > getInputMethodRequest() is initialised to correct > "InputMethodSupport.InputMethodRequestsAdapter.fxRequests" object and not > NULL. > > AFter fix >  This PR has been outstanding for a long time, please sync with the latest master. When I merged the latest master in my own local branch, I see a number of issues on Windows 11 with Japanese IME: 1. type simple Romaji sequences (arigatou): Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "x" because "location" is null at javafx.graphics/com.sun.javafx.text.PrismTextLayout.getCaretShape(PrismTextLayout.java:379) at javafx.graphics/javafx.scene.text.Text$TextAttribute$11.computeValue(Text.java:1823) at javafx.graphics/javafx.scene.text.Text$TextAttribute$11.computeValue(Text.java:1) at javafx.base/javafx.beans.binding.ObjectBinding.get(ObjectBinding.java:168) at javafx.base/javafx.beans.binding.ObjectExpression.getValue(ObjectExpression.java:49) at javafx.base/javafx.beans.property.ObjectPropertyBase.get(ObjectPropertyBase.java:133) at javafx.controls/javafx.scene.control.skin.TextFieldSkin.lambda$4(TextFieldSkin.java:247) at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:147) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91) at javafx.base/javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:106) at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:113) at javafx.base/javafx.beans.property.ObjectPropertyBase$Listener.invalidated(ObjectPropertyBase.java:234) at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:147) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91) at javafx.base/javafx.beans.binding.ObjectBinding.invalidate(ObjectBinding.java:192) at javafx.graphics/javafx.scene.text.Text.doGeomChanged(Text.java:842) at javafx.graphics/javafx.scene.text.Text$1.doGeomChanged(Text.java:159) at javafx.graphics/com.sun.javafx.scene.shape.TextHelper.geomChangedImpl(TextHelper.java:106) at javafx.graphics/com.sun.javafx.scene.NodeHelper.geomChanged(NodeHelper.java:139) at javafx.graphics/javafx.scene.text.Text.needsTextLayout(Text.java:267) at javafx.graphics/javafx.scene.text.Text.needsFullTextLayout(Text.java:262) at javafx.graphics/javafx.scene.text.Text$3.invalidated(Text.java:463) at javafx.base/javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110) at javafx.base/javafx.beans.property.StringPropertyBase$Listener.invalidated(StringPropertyBase.java:231) at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:147) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91) at javafx.base/javafx.beans.binding.StringBinding.invalidate(StringBinding.java:181) at javafx.base/com.sun.javafx.binding.BindingHelperObserver.invalidated(BindingHelperObserver.java:52) at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:360) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.fireValueChangedEvent(TextInputControl.java:1496) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.markInvalid(TextInputControl.java:1500) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.controlContentHasChanged(TextInputControl.java:1439) at javafx.controls/javafx.scene.control.TextInputControl.lambda$0(TextInputControl.java:176) at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:147) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91) at javafx.controls/javafx.scene.control.TextInputControl$ContentBase.fireValueChangedEvent(TextInputControl.java:149) at javafx.controls/javafx.scene.control.TextField$TextFieldContent.insert(TextField.java:88) at javafx.controls/javafx.scene.control.TextInputControl.replaceText(TextInputControl.java:1301) at javafx.controls/javafx.scene.control.TextInputControl.updateContent(TextInputControl.java:609) at javafx.controls/javafx.scene.control.TextInputControl.replaceText(TextInputControl.java:601) at javafx.controls/javafx.scene.control.TextInputControl.replaceText(TextInputControl.java:560) at javafx.controls/javafx.scene.control.skin.TextInputControlSkin.handleInputMethodEvent(TextInputControlSkin.java:785) at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232) at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189) at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.base/javafx.event.Event.fireEvent(Event.java:198) at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8875) at javafx.graphics/javafx.scene.Scene.processInputMethodEvent(Scene.java:2322) at javafx.graphics/javafx.scene.Scene$ScenePeerListener.inputMethodEvent(Scene.java:2725) at javafx.graphics/com.sun.javafx.tk.quantum.EmbeddedScene.lambda$9(EmbeddedScene.java:332) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at javafx.graphics/com.sun.javafx.tk.quantum.EmbeddedScene.lambda$8(EmbeddedScene.java:330) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$11(PlatformImpl.java:456) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$10(PlatformImpl.java:455) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$4(WinApplication.java:185) at java.base/java.lang.Thread.run(Thread.java:1623) ------------- PR Comment: https://git.openjdk.org/jfx/pull/1169#issuecomment-1682880805