Skip to content

dasImgui, dasGlfw: native input-method composition; GLFW 3.5.1 - #4368

Merged
borisbat merged 5 commits into
masterfrom
bbatkin/text-input-ime
Oct 25, 2026
Merged

borisbat merged 5 commits into
masterfrom
bbatkin/text-input-ime

Conversation

@borisbat

@borisbat borisbat commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change: the desktop GLFW library is now libglfw.3.5 (3.5.1 plus an input-method patch) - bundles naming libglfw.3.4 must update.

Why. CJK input methods did not work in dasImgui on desktop: macOS hid the composition and misplaced the candidate window, the conversion Enter submitted the field, and X11 lost keys under IBus. In the browser, Space never typed.

What changes.

  • dasGlfw builds GLFW 3.5.1 with open glfw pull requests 2130 and 1972 plus two X11 fixes; the binding is regenerated, web-stubbed.
  • dasImgui draws the composition at the caret, places the candidate window, and a click commits it into the field being left.
  • Web shells stop cancelling keys aimed at text fields.
  • dasClangBind builds on macOS; its binder output is host-neutral.

Observable behavior.

  • invisible or misplaced composition -> drawn at the caret, candidates beside it
  • conversion Enter submits -> only confirms
  • Space in a browser text field ignored -> types
  • dasClangBind on macOS fails -> builds, regenerates identically

Where to look. modules/dasImgui/src/native_input.h, the X11 hunks of modules/dasGlfw/patches/glfw-3.5.1-ime.patch, modules/dasImgui/ARCHITECTURE.md#native-composition.

Validation, claims, ledger

Validation

  • The first commit is An unused local whose initializer can raise keeps its initializer #4310's Playwright bump (@playwright/test ^1.64.1), cherry-picked unchanged: ubuntu-latest is 26.04 and Playwright 1.50 has no chromium for it, so the playground e2e lane was red on every PR touching site/.
  • Real input methods, driven by script with real keystrokes: macOS Japanese Romaji and Pinyin ABC (Korean 2-Set by hand); Debian 12 X11 with IBus libpinyin, Mozc and Hangul. Checked preedit, conversion Enter, Backspace/Escape inside the composition, Tab, click commit, and that the first key after a focus change converts.
  • modules/dasImgui/tests/test_text_input_example.das 5/5 on macOS and Linux, headless and windowed; modules/dasGlfw/tests 16/16; browser suite (modules/dasImgui/tests/run_browser_tests.cjs, Chrome + WebKit) 11/11 on web libraries built from this tree.
  • Negative controls: owner-change cancel, key settle, real-input cancel, focused-block underline, the right-edge clamp and the field font (windowed) each turn a test red when broken.
  • check_clangbind_fresh passes on macOS (Homebrew LLVM 22.1.5), and bind_glfw.das reproduces the committed GLFW binding.
  • preflight --full on macOS: the fast tier was red on line length only; after the wraps, lint, format and the docs gates were re-run targeted, and the lanes it had skipped ran once each: tests-cpp, tests-interp, tests-jit, tests-aot (full test_aot) and imgui all green.
  • Known-red, environmental: docs/sphinx-html fails to import sphinx_sitemap from Homebrew's Sphinx before reading any page; the docs generator gates (das2rst, imgui2rst, uncategorized, untracked) pass.

Claims - stated, not tested

  • The overlay uses the field's font: a test proves it windowed; headless, the example's font is also the atlas's first font, so the fallback cannot be told apart.
  • X11 paths (the click hold, the two patch edits), the real preedit callback, and the Vulkan/Other init wrappers are not reachable headless; verified by the manual sessions above. Windows is not verified.
  • The binder's size_t alias spelling and resolved-prefix strip: verified by regenerating on macOS and comparing; CI runs the self-binder check only on mingw.
  • The web IME stubs and the dasLLAMA / site shell guards have no test; the default shell's guard is covered by the browser suite's Space step.

Not done

  • The scroll-key guard stays copied in five shells: the default daspkg shell must be self-contained, and the site's copy is a deliberate second guard for cards deployed before this change.
  • Defects the auditors found in eleven REVIEW checklists themselves (wording, automation candidates, anchors) are left for a separate cleanup pass; none changed a verdict here.
  • dasClangBind still cannot stay enabled beside dasLLVM: libclang brings a second LLVM and the wasm cross-compile crashes; the skill says to turn it off after regenerating.

Architecture citations

  • modules/dasImgui/ARCHITECTURE.md#browser-composition-ordering (last line changed): SetTextInputCaret (also records the font), browser_input.h, imgui_text_source_edit.das (two citers) - all still match.
  • #native-composition: native_input.h, module_imgui_app.cpp (inject), dasIMGUI.main.cpp (TextInputFontNote) - match. modules/dasGlfw/ARCHITECTURE.md#ime-patch: native_input.h, modules/dasGlfw/CMakeLists.txt - match.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 17:40
@borisbat
borisbat force-pushed the bbatkin/text-input-ime branch from 4020340 to 334da63 Compare October 25, 2026 17:44
@borisbat

Copy link
Copy Markdown
Collaborator Author

CI note: both playwright (Playground e2e) reds fail in the "Install Playwright" step with Playwright does not support chromium on ubuntu26.04-x64, before any repo code runs. Control: run 40181524800 on branch aleksisch/unused-may-raise failed the same step with the same message today. Not caused by this PR.

The first build (windows, 64, Release) red was this PR's: the GLFW patch checked out with CRLF line endings under autocrlf and git apply rejected every hunk. Fixed by pinning modules/dasGlfw/patches/*.patch to eol=lf in .gitattributes (tip 334da63).

aleksisch and others added 3 commits October 25, 2026 10:46
ubuntu-latest moved to 26.04. The playground lockfile held Playwright
1.60.0, which has no browser builds for that host, so `npx playwright
install --with-deps chromium` stopped with "Playwright does not support
chromium on ubuntu26.04-x64" before any test ran. The lock moves to
1.64.1; the other Playwright suites already lock 1.62.1, the first
release with ubuntu26.04 builds.
The page-level keydown guard that stops Space, the arrows and Home/End
from scrolling the embedding page also cancelled them in the input
bridge's composition textarea, so Space never typed in a browser text
field. The guard now skips input, textarea and contenteditable targets,
in the default shell, the site's frame injection and the dasLLAMA demo
shells. The browser test presses a real Space.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Apple clang enables blocks, so clang-c/Index.h declared block types the
committed binding does not have; the module and bind_clangbind parse
with -fno-blocks. macOS linked a never-set LIBCLANG_LIB and now links
the imported libclang target like the other platforms. The binder
strips the header root in its symlink-resolved form too, and a typedef
whose canonical type spells long keeps its declared spelling (size_t),
so a binding regenerated on macOS matches Windows and Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@borisbat
borisbat force-pushed the bbatkin/text-input-ime branch from 334da63 to 87bcf0a Compare October 25, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It spans native cross-platform IME C++, a patched-GLFW build-system change, and a full binding regeneration, with behavior the author notes is unverified on Windows, so it warrants final human review.

No open issues 🎉

1 file not reviewed
  • site/tests/playground/package-lock.json: Generated file
What changed in this PR

This PR adds native (desktop) input-method (IME/composition) support to dasImgui and upgrades dasGlfw from GLFW 3.4 to a patched GLFW 3.5.1. Previously CJK input methods were broken on desktop (hidden/misplaced composition, conversion-Enter submitting the field, X11 key loss) and Space was swallowed in browser text fields. The change wires the published editor caret into a new C++ IME backend that draws the preedit at the caret, positions the candidate window, and commits composition on click/field-change — mirroring the existing browser bridge.

Changes:

  • New modules/dasImgui/src/native_input.h IME state machine plus module_imgui_app.cpp/dasIMGUI.main.cpp bindings (preedit injection, overlay/caret/font readback, per-field font tracking) and GLFW init wrappers for OpenGL/Vulkan/Other.
  • dasGlfw now builds GLFW 3.5.1 with an IME patch (patches/glfw-3.5.1-ime.patch, applied via git apply under GIT_CEILING_DIRECTORIES), regenerates the binding (new func_6.cpp, host-neutral size_t/resolved-prefix handling in clangbind), and web-stubs the new entry points.
  • Browser shells (5 copies) stop cancelling keys aimed at text fields; widget_bbox is promoted to a public imgui_playwright helper (local copies removed from ~20 record tests) and dasClangBind builds on macOS (-fno-blocks).
File Description
modules/​dasImgui/​src/​native_input.h New desktop IME backend: preedit state, caret rectangle, overlay drawing, click-commit, key-settle focus
modules/​dasImgui/​src/​module_imgui_app.cpp Binds the IME API + init wrappers; AOT prototypes added; attaches/detaches native IME
modules/​dasImgui/​src/​dasIMGUI.main.cpp Records the active field's font via TextInputFontNote/GetTextInputFont
modules/​dasImgui/​src/​imgui_backend_state.h Declares GetTextInputFont
modules/​dasImgui/​widgets/​imgui_playwright.das New public widget_bbox; record tests drop their local copies
modules/​dasImgui/​utils/​imgui2rst.das New "Widget rectangle" doc group for widget_bbox
modules/​dasImgui/​tests/​test_text_input_example.das, text_input_browser.cjs New composition/commit/cancel/clamp coverage; browser Space-types test
modules/​dasImgui/​examples/​features/​text_input/​{main.das,todo.md} ime_state/ime_preedit live command; status/matrix updates
modules/​dasImgui/​{ARCHITECTURE.md,CMakeLists.txt} Native-composition section; 3.5 libname/comments
modules/​dasGlfw/​** (CMakeLists, patch, binding .inc/​.cpp, headers, stubs, .das_package, ARCHITECTURE.md) GLFW 3.5.1 patched build, regenerated binding, web stubs, 3.5 soname
modules/​dasClangBind/​** (CMakeLists, cbind_boost.das, bind_clangbind.das) macOS -fno-blocks build; host-neutral binder output
web/​templates/​wasm_canvas_shell.html, site/​files/​examples.js, examples/​dasLLAMA/​*/​web_shell.html Keep default for keys aimed at text fields
skills/​internal/​clang_bind_build.md macOS libclang + regen/turn-off guidance
examples/​games/​sequence/​ci_smoke_test.sh Bundle native lib bumped to 3.5

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 25, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It combines a desktop GLFW major upgrade, regenerated bindings, and a new native IME subsystem whose macOS/X11/Windows runtime behavior is largely unverifiable here (Windows unverified by the author), warranting human review.

1 open issue
1 file not reviewed
  • site/tests/playground/package-lock.json: Generated file

Review effort: Balanced

Comment thread modules/dasImgui/CMakeLists.txt Outdated
@borisbat
borisbat force-pushed the bbatkin/text-input-ime branch from 87bcf0a to babba4e Compare October 25, 2026 17:55
Copilot AI balanced review requested due to automatic review settings October 25, 2026 17:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It is a large, cross-platform change spanning native C++ IME integration, a GLFW version bump with regenerated bindings and CMake patch logic, whose desktop/X11/macOS behavior is verified only by manual sessions that cannot be reproduced in automated review.

1 open issue
1 resolved since last review
1 file not reviewed
  • site/tests/playground/package-lock.json: Generated file

Review effort: Balanced

Comment thread modules/dasGlfw/src/glfw_emscripten_stubs.c Outdated
borisbat and others added 2 commits October 25, 2026 11:04
GLFW 3.4 keeps macOS composition text to itself, puts the candidate
window at the view corner and reports keys the input method consumed.
The desktop build now downloads 3.5.1 and applies the open glfw pull
requests 2130 (preedit callback, candidate rectangle, text-input focus)
and 1972, narrowed to filtered key presses, with the duplicate-press
timestamp guard removed. The binding is regenerated: the input-method
entry points are bound, stubbed on the web; the library is libglfw.3.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The desktop backend draws the preedit at the caret in the field's font,
publishes the candidate rectangle, holds GLFW text-input focus only
while a field owns text input, released after keys settle, and follows
the field's viewport window. A click mid-composition commits it into
the field it leaves, as the browser bridge does. The text_input example
reports the IME state; its test injects a composition and checks
overlay, caret and commit. imgui_playwright gains widget_bbox, replacing
25 per-script copies in the record drivers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@borisbat
borisbat force-pushed the bbatkin/text-input-ime branch from babba4e to 8294941 Compare October 25, 2026 18:04
Copilot AI balanced review requested due to automatic review settings October 25, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It introduces a large cross-platform native IME subsystem plus a vendored-patch GLFW upgrade whose Windows and real-OS input-method paths are unverified by the author's own ledger, so it needs human sign-off despite no concrete defects being found.

No open issues 🎉

1 resolved since last review
1 file not reviewed
  • site/tests/playground/package-lock.json: Generated file

Review effort: Balanced

@borisbat
borisbat merged commit a651e94 into master Oct 25, 2026
30 checks passed
@borisbat
borisbat deleted the bbatkin/text-input-ime branch October 25, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants