Skip to content

merge: sync upstream PR #349 panel wheel routing - #55

Merged
xiaoyumuxi merged 50 commits into
Lithe-IDEA:mainfrom
xiaoyumuxi:fix/integrate-pr349-wheel-review
Nov 22, 2026
Merged

xiaoyumuxi merged 50 commits into
Lithe-IDEA:mainfrom
xiaoyumuxi:fix/integrate-pr349-wheel-review

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 22, 2026 •

Copy link
Copy Markdown

关联上游 PR

改动类型

  • fix
  • feat
  • docs
  • release

改动内容

把上游 PR vivaui#349 的面板滚轮路由修复同步到 Lithe Viva fork main:Popover、Dialog、AlertDialog、modal Drawer 内的滚轮事件会停留在面板内;non-modal Drawer 只在内容区域内拦截;Table、TextArea 和横向 List 继续使用面板内路由;ScrollAt 保留宿主回调所有权。

同时把修复移植到 fork 当前基线的 base 引擎,并解决与 fork 现有改动的冲突:保留 fork 的树 Disclosure、滚动条样式和 Tooltip 定制,保留上游的 TooltipDelay、SelectedColor、Dock 测试更新和最新组件 API。合并后同步运行 componentgen,确保安装器模板与 components 源文件一致。

验证

  • go test ./ui ./base ./components ./app ./gfx -count=1 -timeout=180s
  • go test ./cmd/viva -run '^Test(InstalledRecipesMatchReferenceSource|GeneratedRecipesAreCurrent)$' -count=1 -timeout=90s
  • go test ./ui ./base -run 'Test(.*(Wheel|ScrollAt|Sideways|Drawer|RowWidth)|ScrollingAllocatesNothingOnceWarm)' -count=1 -timeout=150s
  • go vet ./base ./ui ./components ./app ./gfx
  • GOOS=windows GOARCH=amd64 go build ./...
  • GOOS=windows GOARCH=arm64 go build ./...
  • git diff --check lithe/main..HEAD

上游 PR vivaui#349 的真实 CI 结果:滚轮相关测试、lint、cross-vet、Windows 和 Web 检查通过;Linux/Darwin 安装器模板和 Darwin 体积检查失败。模板失败在上游基线 9ad1e9d7 的 CI 中已经存在,体积失败也在相邻上游 main 提交中同样复现(hello darwin/arm64 为 4,376,802 B,限制 3,840,000 B),与本次滚轮改动无关。本 fork 合并提交已在本地重新生成模板并通过对应检查。

本 fork PR 的 benchmark job 在原始运行和一次 rerun 中都只报告 BenchmarkPainterLabelledPage:原始运行 1k 为 70,800 ns/op、基线中位数 49,023 ns/op;rerun 为 106,114 ns/op、基线中位数 76,647 ns/op。这个比较使用 fork main 的旧基线 ecc66fc5,而候选提交同时同步了上游从 9ad1e9d7 到 0a34cdec 的提交(其中包含 app 语义树和页面重绘优化),所以不是 vivaui#349 的滚轮代码路径回归。上游 PR vivaui#349 在当前上游基线上的 benchmark job 已通过;本地同机对照中,fork 基线与候选的 1k 结果约为 41.0 µs 与 46.6 µs,低于 20% 门槛,候选与当前上游 main 的 1k/4k 结果也基本一致。size job 是仓库已有的非阻塞告警,当前 Darwin/arm64 hello 为 4,376,802 B,限制为 3,840,000 B。

功能矩阵

平台 状态 说明
macOS ✅ 面板滚轮路由;上游 macOS 原生检查与本地包测试通过
Windows ✅ 面板滚轮路由;amd64/arm64 交叉构建通过
Linux ✅ 面板滚轮路由;本地包测试、vet 和模板检查通过
Web ✅ 共享 Go 路由逻辑;上游 Web 检查通过

统一日志系统

本改动没有新增日志或用户可见文案。

Ezreal-byte and others added 30 commits November 21, 2026 15:59
The text shader now carries the label's shape in a fourth float4, so the
constant buffer is 80 bytes instead of 64. The test still asserted the old
size and failed the Windows material gate.
The dominant-channel check passed a near-black or desaturated center, and
the size expectation copied the implementation's /2 formula. Expose the
points rule beside viva_application_update_icon and require the dominant
channel to stand out.
Keep reusable text rasterization in Viva instead of quantizing Motty layout.

Refs: t8y2/motty#1290
The doc sentence added to CodeEditorDecorations did not reach the
installable recipe that componentgen copies from it.
Each wrapped line measured the whole rest of the paragraph to see whether
it fit, and bisected over all of it for the break, so a paragraph of L
lines cost O(L·N·log N): 16 KiB took 3.9 ms, 100 KiB about 335 ms, paid
again whenever the width changed. fitPrefix now gallops from the line's
start and bisects only the last doubling, which WrapLines and WrapRow
share. 16 KiB now takes 0.24 ms; short texts are unchanged.

Viva-only change; Motty picks it up through the existing wrapping API.
The cache of built cell glyphs held 64 entries and started over when
full, so a braille chart (which shows most of its 256 characters) rebuilt
and reallocated its glyphs on every line: 38 us and 254 allocations for a
line of 128 distinct characters. It is now two generations of a map in
front of which a direct-mapped table, indexed by character and cell width
parity, answers the glyphs a line repeats. The same line takes 17.8 us
with no allocation; a line of a few table characters costs about 5% more.

Viva-only change; it serves Motty's terminal through LabelRuns.
A frame where any instance's stamped layer or clip changed was sent as a
full rebuild, so scrolling a list whose rows clip themselves re-uploaded
the whole page every frame. stampState now returns the range it changed
and the update is widened to cover it, keeping the suffix form backends
require when the count grows or shrinks. Every backend regroups batches
from the full instance list on a partial update, so nothing else changes.
The painter tests now assert that a moved layer is covered by the update
rather than that the update is a rebuild.
sameHits compared hit lists as raw bytes, so a label formatted anew every
frame with the same text counted as a structural change and every repaint
rebuilt the region and semantic mirrors (3.4x slower at 4000 hits). The
lists are now compared by value.
slotPool popped its free list by moving the whole rest of it, so swapping
a 10k-row data set spent most of its time in memmove (5.6 ms for the
turnover alone, now 45 us). The free list is a queue with a head index,
compacted as it is reused, and the slots one sweep releases are taken in
number order, so the names a later paint hands out no longer depend on
map iteration.
- macOS polls the pasteboard only while the application is active and
  compares the change count once when it becomes active again; a
  background or status-area application no longer wakes 4 times a second.
- macOS and Linux hide the native caret and stop its blink timer while
  the window does not have the keyboard, as a native field does, and show
  it again at once when the keyboard returns.
- The Linux Secret Service prompt waits on the bus instead of sleeping
  25 ms between non-blocking reads.

Motty registers OnClipboardChange to forward the clipboard to desktop
sessions; the change reaches them when the user returns to the window,
which is when they can use it. No Motty change is needed.
The catalog gained a Graph component, and the site test requires a Chinese
name for every page.
CheckClipboardPNG now reads the header, so the stand-in bytes stopped
decoding; the test carries a real 1x1 PNG instead.
The page now routes a splitter's keys, so the example no longer wires
OnKey; the guides embed that example.
Keep repeatable user actions distinct from persistent autofocus claims, including event passes and embedded views. This reusable focus boundary supports t8y2/motty#1033 without application-level input workarounds.
MYCF711 and others added 20 commits November 22, 2026 00:33
- A Key or Part given to an element without identity (a Text, an Icon)
  no longer passes on to the next element, where it renamed a container
  and reset its State whenever a list's length changed. A dev build stops
  with a message saying where the Key belongs.
- A button that appears before the focused one takes the focused one's
  number among its kind; the page now tells that from a relabel once the
  whole scope is declared, and the focus follows the button it was on, so
  Enter no longer presses the newcomer.
- Two States of one name and different types in a container are two
  states, instead of one reset to the other's type every paint.

The paired Motty commit drops two Keys its RadioID calls never used.
Invalidator.Post queues an update that runs on the window thread before
OnWake and the repaint it asks for. It accepts updates only while the
window is open, drops the waiting ones when it closes, and refuses past
256, so a slow or closed window holds no backlog. Every entry point that
opens a window (RunCanvas, Application.OpenWindow, the headless Driver,
the web target) attaches it, and ContentWindow.Post now delegates to it
instead of keeping its own queue.

The background guide used OnWake to move a pending result into state,
which cleared the status on every animation frame's wake; it now uses
Post, and the guide's prose says what OnWake is for.

Viva-only; Motty's many hand-written result pumps can move to it next.
The List example used one field as both the ListState and the data; the
Slider and Select Key docs still said to wire them to Config.OnKey, which
a page does itself; and the command example made a new State every paint
against its own rule not to copy one.
- ui.Run takes a PageConfig, as OpenWindow does, so a one-window
  application sets its theme and styles without NewPage, Configure and
  RunCanvas. Callers, guides, docs and the viva new template follow.
- ui re-exports the vocabulary its own API takes: Identity, the event and
  canvas types a Control and a Draw use, font weights, shadow levels, text
  direction and alignment, ButtonVariant with its variants, TableColumn
  with its alignments, and the control looks a recipe returns.
- Box.Variant sets a button's variant chosen at run time. Variants do not
  combine; the overlay guide's Ghost().Destructive() was a solid red
  button and is now a ghost with the Danger color.
- A Table is whole as declared: the page routes it the keys that move its
  selection, a click selects a row as a List's does, TableState.Changed
  reports either, and Headers without Columns share the width. A dev
  build stops a Table with neither, which painted nothing.

The paired Motty commit sets variants with Box.Variant and lets the
keychain table report its own selection.
- ui.AlertDialog takes the *bool it is open on, as Modal does, and reports
  the confirming action; its identities are named from the bool unless the
  spec names them, and the keyboard starts on Cancel.
- PopoverWith takes open before its spec, the order Modal and Drawer use.
- ui.MenuAt opens a menu against a rectangle of the application's own
  surface, flipped and kept in the window as an anchored Menu is.
- A Dialog that names no initial focus gives the keyboard to the first
  control of its body, as Modal does, once its body is declared.
- A FormField's title labels the first control its children declare, as
  an HTML label does, unless For names another; TextFieldID edits a model
  string as well as a Field.

The paired Motty commit moves its callers and replaces the slots it laid
out only to anchor menus with MenuAt.
…the line

- OffsetAt bisected nothing: it measured the caret at every boundary,
  each a prefix as long as the line, so a click on a 10 000-character
  line took 99 ms. Carets grow with the offset on a line read one way, so
  NearestBoundary bisects grapheme boundaries (88 us); a bidirectional
  line resolves once instead of once per boundary. The measurer and
  fixed-pitch paths share it, and stop on cluster boundaries instead of
  between a letter and its combining mark.
- WordRange, LineRange and the painter's rangeIsSpace converted the whole
  value to []rune on every pointer move of a word or line drag (2 ms and
  4 MB for 1 MB of text); they read the string in place (0.3 ms, no
  allocation).

Randomized tests hold both to the results of the old forms.
… place

- The Editor stores runes and cached its String until the next edit,
  which rebuilt it from every rune: typing in a 1 MB document re-encoded
  1 MB per keystroke (9.7 ms for an insert and a delete). An edit now
  records how much of the cached text's head and tail it left alone, and
  String rebuilds only what lies between, once however many edits came
  between two reads (0.25 ms), so an input method's many small edits do
  not cost a copy each.
- text gains ByteOffsetOf, ByteRange, UTF16Offset and RuneIndexAtUTF16,
  which read a string in place. macOS answered every text event by
  building a whole Editor to convert the selection to UTF-16; it, the
  Linux surrounding text, the Windows character position query and the
  copy and cut path use them now, and the surrounding text stays valid
  UTF-8 for the bus.

Viva-only: no API a caller uses changes.
The painter kept a semantic.Tree, its ids and a drained change list in
step with every hit, and a second copy of the accessibility payload to
tell whether it changed. Nothing outside tests read the tree: platforms
receive the flat payload. syncSemantics now updates the payload entry by
entry and reports whether any entry changed, and internal/semantic keeps
only the role enum.

On a page of 4 000 hits a structural repaint takes 412 us instead of
563 us, the first frame 133 us and 0.90 MB instead of 172 us and 1.10 MB,
and each hit retains 984 bytes instead of 1 492.

Viva-only.
SingleSelect, MultiSelect and the hierarchy menu placed their lists with
their own rule (placePopupBelow and an inline copy of it): open above
whenever a 40 px row fit there, even when below had more room. They use
PlaceOverlay now, the rule popovers, menus and submenus follow: flip to
the side with more room. OverlayPlacement.Fit shortens the overlay to the
room on that side, as the positioner's size step does for a list that
scrolls, instead of shifting it back over its trigger.

The paired Motty commit places its three hand-positioned lists with it.
SingleSelect (ui.Combobox) and MultiSelect opened and closed their lists
at once, while Select, Popover and the menus faded and slid them from the
trigger's side. They begin the same presence around the list now, keyed
as a Select's is, so the exit keeps the list's last frame.

Viva-only.
Every frame refills its slices from zero, and a slice cut short keeps
what it held in its array: a page that stopped showing a 1 MB picture
kept it reachable through the frame's Images, the canvas's images, the
frame builder's last images and labels, and the painter's hit lists,
along with CustomLayouts and the strings of rows that were gone. Each of
those lists now records its length at the end of a frame and clears what
the next frame does not reach of it, a cost of what it shrank by, not of
its capacity; the canvas swaps the records with the lists a Memo keeps.
trimFlexCapacity also counts bytes, so 776-byte Extras no longer stay at
4 096 before a page that shrank gives them back.

Viva-only.
comCall was variadic and marked uintptrescapes, so every one of its 284
call sites allocated its argument slice, and every value whose address
a draw passed escaped to the heap: the frame constants, viewport, clear
color and a scissor per batch and per label, and a color and a matrix
per run of text in Direct2D. comCall0 to comCall7 take a fixed number of
arguments, and the values the draw loop and the text target hand over by
address live in the renderer and the target, as the Direct2D clip
already did. The test of the variadic limit goes with it.

Checked on the physical Windows machine: the renderer, Direct2D and text
tests pass; three that fail over SSH fail the same without this change.

Viva-only.
Every window, every clipboard read, every font-settings read and every
global shortcut registration opened libxcb and libc again and bound 58
functions (149 us and 522 allocations measured for the bindings alone),
and every window and offscreen target did the same for libvulkan. Both
tables are now process singletons behind sync.Once, failures included,
and kept for the life of the process as the Pango services already are,
so the close paths no longer dlclose them.

First step of ADR 0093 (Linux process-level resources). Viva-only.
Merge upstream main without rewriting the wheel fix already integrated in the fork. Keep focus-trap filtering shared by View.Wheel and Page.RouteWheel, include AlertDialog, and stop wheel events over a non-modal Drawer only inside its content rectangle. Cover modal drawers and the independent Table, TextArea, and sideways List routes, while preserving ScrollAt fallback ownership.
Follow the latest PopoverWith and AlertDialog bool-based API, document RouteWheel ownership, and keep the wheel scan's fixed lower bound so the common page path stays as cheap as upstream.
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 22, 2026 02:20
@xiaoyumuxi

Copy link
Copy Markdown
Author

性能门禁调查结果:

  • benchmark 原始运行和 rerun 都只报告 BenchmarkPainterLabelledPage,但候选分支同步了 fork main 之后上游的多项 app/base 性能提交;比较基线是旧 fork ecc66fc5,因此这不是 fix(ui): keep panel wheel events off the page underneath vivaui/viva#349 滚轮路由代码路径的独立回归。
  • 上游 fix(ui): keep panel wheel events off the page underneath vivaui/viva#349 当前基线的 benchmark job 已通过;本地 Apple M4 同机对照中,fork 基线与候选的 BenchmarkPainterLabelledPage/1k 约为 41.0 µs 与 46.6 µs,低于门禁的 20% 阈值;候选与当前上游 origin/main 的 1k/4k 结果基本一致。
  • size 是仓库已有的非阻塞告警,Darwin/arm64 hello 在上游相邻提交和本 PR 中均为 4,376,802 B,限制 3,840,000 B。

因此没有为无关性能门禁改阈值、删 benchmark 或修改滚轮实现。

@xiaoyumuxi
xiaoyumuxi merged commit c6f6020 into Lithe-IDEA:main Nov 22, 2026
32 of 38 checks passed
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.

8 participants