[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Re: RFR: 8090267: JFXPanel Input Problem
From:       Martin Fox <mfox () openjdk ! org>
Date:       2023-12-29 18:56:53
Message-ID: ImEuAeezX_QD93ecUbM2sxl_jqEPl5rdWJSOFmFNXhI=.d94f3ff6-f463-4ad5-a7a8-cbb9cfb1fa8b () github ! com
[Download RAW message or body]

On Tue, 4 Jul 2023 05:54:54 GMT, Prasanta Sadhukhan <psadhukhan@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
> 
> ![image](https://github.com/openjdk/jfx/assets/43534309/65833d59-528e-4087-9992-9f86b8b8c47f)
>  
> 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
> ![image](https://github.com/openjdk/jfx/assets/43534309/ec3d8343-9295-4950-885b-f9983b9b017a)
> 

It turns out this PR didn't introduce new problems, it just exposed existing ones. \
The AWT EventQueue thread is calling into the InputMethodRequests at the same time as \
the JavaFX thread is updating and drawing the text field. If the timing is right (or \
wrong) both threads can trigger glyph layout in the same Text object at the same \
time. The result is the sort of erratic behavior seen here.

I've entered [JDK-8322784](https://bugs.openjdk.org/browse/JDK-8322784).

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1169#issuecomment-1872276763


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic