jdk8u-dev icon indicating copy to clipboard operation
jdk8u-dev copied to clipboard

8330561: [Windows][8u] IME candidate window wrong position

Open ktakakuri opened this issue 1 year ago • 9 comments

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;
     }

  1. 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.


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] JDK-8330561 needs maintainer approval

Issue

  • JDK-8330561: [Windows][8u] IME candidate window wrong position (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk8u-dev.git pull/483/head:pull/483
$ git checkout pull/483

Update a local copy of the PR:
$ git checkout pull/483
$ git pull https://git.openjdk.org/jdk8u-dev.git pull/483/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 483

View PR using the GUI difftool:
$ git pr show -t 483

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk8u-dev/pull/483.diff

Webrev

Link to Webrev Comment

ktakakuri avatar Apr 18 '24 08:04 ktakakuri

:wave: Welcome back ktakakuri! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Apr 18 '24 08:04 bridgekeeper[bot]

❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.

openjdk[bot] avatar Apr 18 '24 08:04 openjdk[bot]

Webrevs

mlbridge[bot] avatar Apr 18 '24 08:04 mlbridge[bot]

The following jtreg test failed on Windows x64/x86: security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java#certignarootca. This is a test on certificates and is not related to the awt affected by this fix. Therefore, this error is not a defect caused by this fix. Some error occurred on Linux and Mac, but since this is a WIndows-only fix, it is irrelevant.

ktakakuri avatar Apr 24 '24 13:04 ktakakuri

@ktakakuri This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar May 22 '24 13:05 bridgekeeper[bot]

Could someone please review this fix? This is a problem in the Japanese environment and I am very troubled by this issue.

ktakakuri avatar May 27 '24 09:05 ktakakuri

Could anyone please review this fix?

ktakakuri avatar Jun 23 '24 23:06 ktakakuri

@phohensee I would like to ask for your review of this code about the AWT library. I've been struggling to find a reviewer for over two months. When running our GUI applications, this bug can interfere with our work, so I want to definitely integrate the fix into jdk8. I know you are busy, but I would appreciate it if you could check this.

ktakakuri avatar Jul 03 '24 05:07 ktakakuri

@ktakakuri This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Jul 31 '24 05:07 bridgekeeper[bot]

OK. I created a new issue because JDK-8189687 primarily reports a problem in Hi-DPI and the fix assumes JEP263 which supports Hi-DPI. If it is better to backport ignoring JEP 263 as you said, I will create new pull request.

ktakakuri avatar Aug 20 '24 07:08 ktakakuri

Thanks. I think it'll be easier to get approval if the request is just a backport.

phohensee avatar Aug 20 '24 15:08 phohensee

Thank you. I have created a backport. #564

ktakakuri avatar Aug 21 '24 00:08 ktakakuri

Thanks. I've reviewed https://github.com/openjdk/jdk8u-dev/pull/564.

phohensee avatar Aug 21 '24 18:08 phohensee