Skip to content

Align Touch/Pen capture semantics with Mouse - #21325

Merged
MrJul merged 1 commit into
masterfrom
fixes/touch-capture
May 14, 2026
Merged

Align Touch/Pen capture semantics with Mouse#21325
MrJul merged 1 commit into
masterfrom
fixes/touch-capture

Conversation

@miloush

@miloush miloush commented May 7, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

Removes Capture(null) from Pointer.Disposable(), expecting callers to call it explicitly with the appropriate source.

What is the current behavior?

PenUp and TouchUp are treated as explicit capture loss, resulting in popups closed unexpectedly.

What is the updated/expected behavior with this PR?

Like with mouse, the captures on down and up are marked as implicit. TouchCancel is treated as loss from platform.

How was the solution implemented (if it's not obvious)?

Pointer.Dispose() is now no-op - keeping Pointer : IDisposable for ABI compatibility. Added explicit Capture(null, source) to call sites.

Checklist

Breaking changes

The only Dispose() that was not complemented with Capture(null, source) is in PenDevice.ProcessRawEvent for shouldReleasePointer = true, which happens on LeaveWindow and XButton2Up. The former is no-op for mouse too, and the latter is already handled in PenUp it calls.

Obsoletions / Deprecations

Fixed issues

@miloush miloush added the backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch label May 7, 2026
@MrJul MrJul added backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch enhancement labels May 7, 2026
@MrJul

MrJul commented May 7, 2026

Copy link
Copy Markdown
Member

Pointer is public, so callers can cast it to IDisposable or use with using. We do not expect any 3rd party disposing our pointers, but to alleviate the breaking change, we could keep it IDisposable with empty Dispose() method. However, that would only mask the change of behavior that it no longer results in capture disposal.

It's not so much about third-party code unexpectedly calling Dispose, but about ABI compatibility that we can't break. Please keep an empty Dispose() implementation for now and add a TODO13 comment so we can remove in it v13.

@miloush
miloush force-pushed the fixes/touch-capture branch from 256dba2 to fb6e994 Compare May 7, 2026 16:11
@miloush

miloush commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

updated

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0065260-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@miloush

miloush commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

the failing tests look legit, will look into them

@miloush miloush self-assigned this May 7, 2026
@miloush

miloush commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

though weirdly none seem to be related to pointer or touch

@miloush

miloush commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@MrJul I cannot repro the failing integration tests locally (and they do not look like they should be affected by the PR), can you try run it again?

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@MrJul
MrJul added this pull request to the merge queue May 14, 2026
Merged via the queue into master with commit fceaa72 May 14, 2026
11 checks passed
@MrJul
MrJul deleted the fixes/touch-capture branch May 14, 2026 09:31
@MrJul MrJul added backported-11.3.x and removed backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels May 19, 2026
MrJul pushed a commit to MrJul/Avalonia that referenced this pull request May 28, 2026
)

Co-authored-by: Jan Kučera <miloush@users.noreply.github.com>
@MrJul MrJul added backported-12.0.x and removed backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants