IME candidate windows follow the canvas caret #3127
Please, clean up this PR! The javac.20261027_000???.args files should not be necessary.
Delete this file from PR!
Delete this file from PR!
Delete this file from PR!
Delete this file from PR!
Delete this file from PR!
Delete this file from PR!
Delete this file from PR!
After cleaning up this PR from the unnecessary files, squash all commits and force push to clean also the history.
Delete duplicated code section.
Fix indentation.
Fix indentation.
I get the impression that caretCanvas and caretCanvasSupplierCanvas point to the same object. Or am I mistaken? If not, why not using caretCanvas directly in the added code sections to this file?
@LetMeSleep8h: Thanks for the PR, but it does not seem to be mature yet. Please address my review comments.
@yunforge: Could you please give this PR a try once the review comments were addressed?
maehne
LetMeSleep8h
Fixes #3126.
The canvas text editor was an input-method passive client: the canvas component never implemented
java.awt.im.InputMethodRequests, so the JDK could only report the client-window bounds to the IME and CJK candidate/preedit windows parked at the window's bottom-left while composing labels, pin names and tunnel names.The fix
CanvasimplementsInputMethodRequests(verified with the real gradle build:compileJavapasses) and callsenableInputMethods(true)in its constructor — it is now an active client.getTextLocationreturns the current caret's on-screen bounds: caret bounds live in canvas coordinates, so they go throughgetLocationOnScreen()translation. When no label is being edited it returnsnull, keeping the passive fallback.TextToolthroughCanvas.setImeCaretBounds(Supplier<Bounds>), registered wherever a caret is created and cleared on every path that ends editing, so a stale supplier can never pin the IME to a dead caret.AbstractCaret.getBounds(null)is safe:GraphicsUtil.getTextBoundsexplicitly guards a null graphics and returns a zero-width rectangle, so the supplier needs no paint context.Happy to test on Linux/fcitx5 — the issue reporter offered the same, and the change is IME-agnostic on the Java side.