Skip to content

fix: 修复上下红外框触摸屏手掌擦橡皮过大的问题 - #636

Open
fplj-fplj wants to merge 1 commit into
InkCanvasForClass:net10from
fplj-fplj:fix/palm-eraser-top-bottom-ir
Open

fix: 修复上下红外框触摸屏手掌擦橡皮过大的问题#636
fplj-fplj wants to merge 1 commit into
InkCanvasForClass:net10from
fplj-fplj:fix/palm-eraser-top-bottom-ir

Conversation

@fplj-fplj

Copy link
Copy Markdown
Contributor

问题

在具有上下红外框的触摸屏上使用“手掌擦”时,橡皮尺寸巨大,远超实际手掌。

原因

非四边红外路径直接使用接触矩形的 Width 作为手掌擦尺寸。上下红外框可能把接触矩形某一轴上报为接近全屏宽度的异常长条,导致手掌擦被异常放大。

修改

  • 新增 PalmEraserGeometry,统一计算有效接触宽度:异常细长接触使用 sqrt(width * height) 近似真实手掌尺寸,并增加 200 DIP 上限。
  • MW_TouchEvents.GetTouchBoundWidth() 和手掌擦激活逻辑接入新计算。
  • NativeInkInputRouter.TryGetPalmEraserWidth() 同步同一逻辑,保持两处公式一致。
  • 新增 NativeInk 测试:上下红外异常长条场景、普通接触不回归、手掌橡皮最大宽度保护。

验证

  • 测试项目构建通过。
  • 新增手掌擦路由测试全部通过。
  • 主项目构建通过,0 错误。

@augmentcode

augmentcode Bot commented Aug 20, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR corrects palm-eraser sizing for top/bottom infrared touch frames.

Changes:

  • Adds PalmEraserGeometry as the shared contact-width and eraser-size calculator.
  • Detects elongated contact rectangles and estimates their effective size with a geometric mean.
  • Caps the final palm-eraser width at 200 DIP to prevent extreme eraser sizes.
  • Routes both WPF touch handling and NativeInk routing through the shared calculations.
  • Preserves width-based handling for ordinary, non-elongated non-quad-IR contacts.
  • Adds NativeInk tests for elongated top/bottom IR contacts, normal contacts, and the size cap.
  • Links the new shared helper into the NativeInk test project.
Technical note: Threshold decisions now use the normalized effective contact width, while the cap is applied after configured eraser-size and special-screen multipliers.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

return contactWidthDip;

var min = Math.Min(contactWidthDip, contactHeightDip);
var max = Math.Max(contactWidthDip, contactHeightDip);

@augmentcode augmentcode Bot Aug 20, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In Ink Canvas/Ink/PalmEraserGeometry.cs:37, this early return also applies when isQuadIr is true, changing the previous quad-IR result for a zero-height contact from 0 to the raw width. A quad-IR frame with a screen-wide width and a missing/degenerate height can therefore activate an oversized palm eraser again rather than being rejected by the existing threshold checks.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@HHH2309

HHH2309 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

你先别急

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.

2 participants