From 9da0218a338bb60fcffce63cc65e17f6a073406e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C4=8Dera?= <10546952+miloush@users.noreply.github.com> Date: Thu, 14 May 2026 09:51:27 +0100 Subject: [PATCH] move Capture(null) from Pointer.Dispose() to callsites (#21363) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan Kučera --- 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 3f168f66b0..f5742e16b1 100644 --- a/src/Avalonia.Base/Input/PenDevice.cs +++ b/src/Avalonia.Base/Input/PenDevice.cs @@ -104,7 +104,7 @@ namespace Avalonia.Input if (source != null) { - pointer.Capture(source); + pointer.Capture(source, CaptureSource.Implicit); var settings = ((IInputRoot?)(source as Interactive)?.GetVisualRoot())?.PlatformSettings; if (settings is not null) { @@ -173,7 +173,7 @@ namespace Avalonia.Input } 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 ebb98dd0bc..4b8f7260fe 100644 --- a/src/Avalonia.Base/Input/Pointer.cs +++ b/src/Avalonia.Base/Input/Pointer.cs @@ -136,10 +136,7 @@ namespace Avalonia.Input 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 8e662ea1b9..0780370bf1 100644 --- a/src/Avalonia.Base/Input/TouchDevice.cs +++ b/src/Avalonia.Base/Input/TouchDevice.cs @@ -48,7 +48,7 @@ namespace Avalonia.Input _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; @@ -109,6 +109,7 @@ namespace Avalonia.Input { target.RaiseEvent(e); } + pointer?.Capture(null, CaptureSource.Implicit); } } @@ -117,7 +118,7 @@ namespace Avalonia.Input _pointers.Remove(args.RawPointerId); using (pointer) { - pointer?.Capture(null); + pointer?.Capture(null, CaptureSource.Platform); pointer?.CaptureGestureRecognizer(null); if (pointer != null) pointer.IsGestureRecognitionSkipped = false;