[jdk8u-dev] RFR: 8330561: [Windows][8u] IME candidate window wrong position
Kazuhisa Takakuri
ktakakuri at openjdk.org
Mon May 27 09:10:07 UTC 2024
On Thu, 18 Apr 2024 08:48:09 GMT, Kazuhisa Takakuri <ktakakuri at openjdk.org> wrote:
> This fix includes a fix for JDK-8189687 in JDK9.
> JDK-8189687 contains two fixes to AwtComponent:: OpenCandidateWindow
>
> 1. Fix to make OpenCandidateWindow reference the correct Window
> Fix OpenCandidateWindow to reference the proxy window that has focus when getting "HWND."
>
>
> --- a/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
> +++ b/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
> @@ -3880,19 +3880,21 @@ void AwtComponent::OpenCandidateWindow(int x, int y)
> {
> UINT bits = 1;
> POINT p = {0, 0}; // upper left corner of the client area
> - HWND hWnd = GetHWnd();
> + HWND hWnd = ImmGetHWnd();
> if (!::IsWindowVisible(hWnd)) {
> return;
> }
>
>
>
> 2. Scaling fixes to enhance JDK-8073320
> OpenJDK9 has supported HiDPI Graphics since JEP 263 (JDK-8055212). This fix is one of its enhancements: when OpenCandidateWindow opens an IME conversion candidate, it corrects the coordinates for the device.
>
>
> --- a/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
> +++ b/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
> @@ -3880,19 +3880,21 @@ void AwtComponent::OpenCandidateWindow(int x, int y)
> HWND hTop = GetTopLevelParentForWindow(hWnd);
> ::ClientToScreen(hTop, &p);
> + int sx = ScaleUpX(x) - p.x;
> + int sy = ScaleUpY(y) - p.y;
> if (!m_bitsCandType) {
> - SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
> + SetCandidateWindow(m_bitsCandType, sx, sy);
> return;
> }
> for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
> if ( m_bitsCandType & bits )
> - SetCandidateWindow(iCandType, x - p.x, y - p.y);
> + SetCandidateWindow(iCandType, sx, sy);
> }
> }
>
>
> In attatchmented test which reproduces the issue problem, the Panel containing the TextField is a child component, so it refers to the wrong window to get the position coordinate of the candidate window.
> Therefore, the candidate window will appear in the correct position with the "1" fix.
> Note that OpenJDK8 does not implement JEP 263, so the "2" fix is not included in this pull request.
Could someone please review this fix?
This is a problem in the Japanese environment and I am very troubled by this issue.
-------------
PR Comment: https://git.openjdk.org/jdk8u-dev/pull/483#issuecomment-2133017778
More information about the jdk8u-dev
mailing list