Repository navigation
feat: 拖拽原语 drag_scale 世界缩放补偿(ZUI 关键路径) - #2
Merged
Merged
Conversation
offsetLeft/Top 是布局(世界)坐标,不受容器 CSS transform 影响,
clientX/Y 是屏幕像素——容器带 zoom 缩放时不按比例补偿会拖拽漂移
(zoom=2 跑双倍距离),松手回写把误差烤进 payload。
- L1 setup_drag 加可选 drag_scale: prop(Numeric 或 callable,
mousedown 时取值一次、手势期冻结),屏幕位移 ÷ scale 再进
compute_geom 与 live 样式跟随
- 数学核心提出为纯 CRuby Beryl::DragGeometry.compute(F5),
回归测试 test/drag_geometry_test.rb:scale=1 与既有行为逐点一致 +
Z1 验收五档(0.25/0.5/1/2/4)补偿等价
- WindowFrame/wm.frame 经 drag_scale: prop 透传标题栏与八向手柄
- drag_clamp 视口边界仍是屏幕像素口径,仅 scale=1 语义精确(已注明)
下游:emerald-zui(ZUI 扩展仓)Z1 关键路径,wm.frame(:id, drag_scale: -> { cam.get[:zoom] })。
This was referenced Sep 15, 2026
ShiningRay
added this pull request to stack #6
September 15, 2026 23:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Emerald OS 的 ZUI 视口扩展(emerald-zui 仓,PLAN §3.5)需要:世界层容器带 CSS transform 缩放(相机 zoom)时,窗口拖拽/缩放的手感与光标一致。
问题:
offsetLeft/Top是布局(世界)坐标,不受容器 CSS transform 影响,而clientX/Y是屏幕像素——zoom ≠ 1 时按原公式拖拽会漂移(zoom=2 窗口跑双倍距离),且松手回写把误差烤进 payload,纯消费侧无法干净修复。改动
setup_drag加可选drag_scale:prop:Numeric 或 callable(如-> { cam.get[:zoom] }),mousedown 时取值一次、手势期冻结(与 sx/sy 同语义);屏幕指针位移 ÷ scale 再进compute_geom与 live 样式跟随;moved阈值仍按屏幕口径判定Beryl::DragGeometry.compute(support.rb,F5 纪律,setup_drag 原数学逐点搬移),CRuby 可直接回归测试WindowFrame/wm.frame经drag_scale:prop 透传标题栏与八向缩放手柄(opts 直通既有,零侵入)drag_scale(nil)行为与 main 完全一致(scale → 1.0,.compact 丢弃 nil)测试
test/drag_geometry_test.rb(新增,11 例):scale=1 时移动/clamp/八向缩放/最小尺寸锚定与既有行为逐点一致;drag_scale 补偿锁 zoom=2 减半、zoom=0.5 加倍、缩放手柄补偿、Z1 验收五档 0.25/0.5/1/2/4 等价性、nil → 1.0window_test.rb:WindowFrame prop 契约 +wm.frameopts 透传(callable 形态)bundle exec rake双门禁绿:94 runs / 435 assertions / 0 failures + Opal 编译验收通过已知边界(不阻塞)
drag_clamp的视口边界仍是屏幕像素口径,仅 scale=1(经典桌面)语义精确;ZUI 无限画布本来传viewport: nil、不用 drag_clamp。已在 PLAN.md 踩坑记录注明。下游用法(emerald-zui)
文档同步
beryl
docs/PLAN.md:L1 原语表加drag_scale+ 踩坑记录新增「世界缩放下的拖拽漂移」条目。🤖 本 PR 由 Z0 里程碑并行开发流程提交(相机/外壳在 emerald-zui 侧另行落地)。