← Back to Pull requests

IME candidate windows follow the canvas caret #3127

Open
LetMeSleep8h opened this pull request with 90 lines diff across 2 files
View on GitHub
LetMeSleep8h LetMeSleep8h commented on Oct 26, 2026 16:40 UTC
Author

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

  • Canvas implements InputMethodRequests (verified with the real gradle build: compileJava passes) and calls enableInputMethods(true) in its constructor — it is now an active client.

  • getTextLocation returns the current caret's on-screen bounds: caret bounds live in canvas coordinates, so they go through getLocationOnScreen() translation. When no label is being edited it returns null, keeping the passive fallback.

  • The caret reference is supplied by TextTool through Canvas.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.getTextBounds explicitly 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.

    Diff: 90 lines (+89 / -1) across 2 files Reviewer: maehne Review duration: 56403m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.38) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 90 lines diff across 2 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 5 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    87%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.270
    Real PR Conversation Timeline
    15 items
    maehne maehne requested changes on Oct 26, 2026 16:55 UTC
    Changes Requested Reviewer

    Please, clean up this PR! The javac.20261027_000???.args files should not be necessary.

    maehne maehne commented on code on Oct 26, 2026 16:57 UTC
    Code Review
    javac.20261027_000043.args:1

    Delete this file from PR!

    maehne maehne commented on code on Oct 26, 2026 16:57 UTC
    Code Review
    javac.20261027_000055.args:1

    Delete this file from PR!

    maehne maehne commented on code on Oct 26, 2026 16:57 UTC
    Code Review
    javac.20261027_000108.args:1

    Delete this file from PR!

    maehne maehne commented on code on Oct 26, 2026 16:57 UTC
    Code Review
    javac.20261027_000132.args:1

    Delete this file from PR!

    maehne maehne commented on code on Oct 26, 2026 16:58 UTC
    Code Review
    javac.20261027_000158.args:1

    Delete this file from PR!

    maehne maehne commented on code on Oct 26, 2026 16:58 UTC
    Code Review
    javac.20261027_000234.args:1

    Delete this file from PR!

    maehne maehne commented on code on Oct 26, 2026 16:58 UTC
    Code Review
    javac.20261027_000245.args:1

    Delete this file from PR!

    maehne maehne requested changes on Oct 26, 2026 16:59 UTC
    Changes Requested Reviewer

    After cleaning up this PR from the unnecessary files, squash all commits and force push to clean also the history.

    maehne maehne commented on code on Nov 14, 2026 22:48 UTC
    Code Review
    src/main/java/com/cburch/logisim/tools/TextTool.java:1
    @@ -80,6 +80,14 @@ public void editingCanceled(CaretEvent e) {
           caretCreatingText = false;
           caret = null;
           caretCanvas = null;
    +        if (caretCanvasSupplierCanvas != null) {
    +          caretCanvasSupplierCanvas.setImeCaretBounds(null);
    +          caretCanvasSupplierCanvas = null;
    +        }
    +        if (caretCanvasSupplierCanvas != null) {
    +          caretCanvasSupplierCanvas.setImeCaretBounds(null);
    +          caretCanvasSupplierCanvas = null;
    +        }

    Delete duplicated code section.

    maehne maehne commented on code on Nov 14, 2026 22:49 UTC
    Code Review
    src/main/java/com/cburch/logisim/tools/TextTool.java:1
    @@ -80,6 +80,14 @@ public void editingCanceled(CaretEvent e) {
           caretCreatingText = false;
           caret = null;
           caretCanvas = null;
    +        if (caretCanvasSupplierCanvas != null) {
    +          caretCanvasSupplierCanvas.setImeCaretBounds(null);
    +          caretCanvasSupplierCanvas = null;
    +        }

    Fix indentation.

    maehne maehne commented on code on Nov 14, 2026 22:49 UTC
    Code Review
    src/main/java/com/cburch/logisim/tools/TextTool.java:1
    @@ -133,6 +141,10 @@ public void editingStopped(CaretEvent e) {
           caretCreatingText = false;
           caret = null;
           caretCanvas = null;
    +        if (caretCanvasSupplierCanvas != null) {
    +          caretCanvasSupplierCanvas.setImeCaretBounds(null);
    +          caretCanvasSupplierCanvas = null;
    +        }

    Fix indentation.

    maehne maehne commented on code on Nov 14, 2026 22:55 UTC
    Code Review
    src/main/java/com/cburch/logisim/tools/TextTool.java:1
    @@ -335,6 +348,8 @@ public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
     
         if (caret != null) {
           caretCanvas = canvas;
    +        caretCanvasSupplierCanvas = canvas;

    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?

    maehne maehne requested changes on Nov 14, 2026 22:57 UTC
    Changes Requested Reviewer

    @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?

    Reviewers
    Assignees
    LetMeSleep8h LetMeSleep8h
    Labels
    risk: low confidence: 87.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.4% (MEDIUM) · Higher = larger blast radius
    38.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 87.1% · Lower = rushed or shallow review
    87.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.0% · Safe to merge
    5.0%