From fb6e994d36c486331ac819a3880887deb582b8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C4=8Dera?= Date: Thu, 7 May 2026 17:11:37 +0100 Subject: [PATCH] move Capture(null) from Pointer.Dispose() to callsites --- src/Avalonia.Base/Input/PenDevice.cs | 4 ++-- src/Avalonia.Base/Input/Pointer.cs | 5 +---- src/Avalonia.Base/Input/TouchDevice.cs | 5 +++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.Base/Input/PenDevice.cs b/src/Avalonia.Base/Input/PenDevice.cs index b3301ce6126..8780f5291a8 100644 --- a/src/Avalonia.Base/Input/PenDevice.cs +++ b/src/Avalonia.Base/Input/PenDevice.cs @@ -104,7 +104,7 @@ private bool PenDown(Pointer pointer, ulong timestamp, if (source != null) { - pointer.Capture(source); + pointer.Capture(source, CaptureSource.Implicit); var settings = (source as Interactive)?.GetPlatformSettings(); if (settings is not null) { @@ -173,7 +173,7 @@ private bool PenUp(Pointer pointer, ulong timestamp, } finally { - pointer.Capture(null); + pointer.Capture(null, CaptureSource.Implicit); pointer.CaptureGestureRecognizer(null); pointer.IsGestureRecognitionSkipped = false; _lastMouseDownButton = default; diff --git a/src/Avalonia.Base/Input/Pointer.cs b/src/Avalonia.Base/Input/Pointer.cs index 7de3dbe713e..cb0416f3269 100644 --- a/src/Avalonia.Base/Input/Pointer.cs +++ b/src/Avalonia.Base/Input/Pointer.cs @@ -136,10 +136,7 @@ private void OnCaptureDetached(object? sender, VisualTreeAttachmentEventArgs e) public void Dispose() { - if (Captured != null) - { - Capture(null); - } + // callers are responsible for calling Capture(null, source) with an appropriate source } /// diff --git a/src/Avalonia.Base/Input/TouchDevice.cs b/src/Avalonia.Base/Input/TouchDevice.cs index 27381bbe00f..7a7f343c87c 100644 --- a/src/Avalonia.Base/Input/TouchDevice.cs +++ b/src/Avalonia.Base/Input/TouchDevice.cs @@ -48,7 +48,7 @@ public void ProcessRawEvent(RawInputEventArgs ev) _pointers[args.RawPointerId] = pointer = new Pointer(Pointer.GetNextFreeId(), PointerType.Touch, _pointers.Count == 0); - pointer.Capture(hit); + pointer.Capture(hit, CaptureSource.Implicit); } var target = pointer.Captured ?? args.InputHitTestResult.firstEnabledAncestor ?? args.Root.RootElement; @@ -109,6 +109,7 @@ public void ProcessRawEvent(RawInputEventArgs ev) { target.RaiseEvent(e); } + pointer?.Capture(null, CaptureSource.Implicit); } } @@ -117,7 +118,7 @@ public void ProcessRawEvent(RawInputEventArgs ev) _pointers.Remove(args.RawPointerId); using (pointer) { - pointer?.Capture(null); + pointer?.Capture(null, CaptureSource.Platform); pointer?.CaptureGestureRecognizer(null); if (pointer != null) pointer.IsGestureRecognitionSkipped = false;