RFR: 8090267: JFXPanel Input Problem
Martin Fox
duke at openjdk.org
Mon Aug 21 20:55:32 UTC 2023
On Mon, 21 Aug 2023 16:19:55 GMT, Andy Goryachev <angorya at 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
>> 
>
> could we try this on another window 11 box?
I tried this on my Windows 11 setup. I can reproduce all of the problems @andy-goryachev-oracle was seeing but the behavior is erratic so I'm having difficulty coming up with a precise set of steps.
You might try this:
- set keyboard to Japanese, half-width alphanumeric
- launch the test app
- click in the TextField to establish focus (focus is not working as expected for me)
- type two 'a' characters
- switch to Hirigana
- type 'a'
On my system the input sequence displays doubled aaあaaあ. At this point the TextField is confused, if I commit and start moving the cursor around it treats the final あaaあ sequence as one character. Various bad behavior follows.
I can also get into a state where exceptions are being thrown but haven't figured out precisely how. Seems to happen most when I switch to Hiragana and start typing quickly...
Without Swing in the picture none of these problems occur.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1169#issuecomment-1687027891
More information about the openjfx-dev
mailing list