Skip to content

Commit 9da0218

Browse files
authored
move Capture(null) from Pointer.Dispose() to callsites (#21363)
Co-authored-by: Jan Kučera <miloush@users.noreply.github.com>
1 parent f7681a8 commit 9da0218

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/Avalonia.Base/Input/PenDevice.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private bool PenDown(Pointer pointer, ulong timestamp,
104104

105105
if (source != null)
106106
{
107-
pointer.Capture(source);
107+
pointer.Capture(source, CaptureSource.Implicit);
108108
var settings = ((IInputRoot?)(source as Interactive)?.GetVisualRoot())?.PlatformSettings;
109109
if (settings is not null)
110110
{
@@ -173,7 +173,7 @@ private bool PenUp(Pointer pointer, ulong timestamp,
173173
}
174174
finally
175175
{
176-
pointer.Capture(null);
176+
pointer.Capture(null, CaptureSource.Implicit);
177177
pointer.CaptureGestureRecognizer(null);
178178
pointer.IsGestureRecognitionSkipped = false;
179179
_lastMouseDownButton = default;

src/Avalonia.Base/Input/Pointer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ private void OnCaptureDetached(object? sender, VisualTreeAttachmentEventArgs e)
136136

137137
public void Dispose()
138138
{
139-
if (Captured != null)
140-
{
141-
Capture(null);
142-
}
139+
// callers are responsible for calling Capture(null, source) with an appropriate source
143140
}
144141

145142
/// <summary>

src/Avalonia.Base/Input/TouchDevice.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void ProcessRawEvent(RawInputEventArgs ev)
4848

4949
_pointers[args.RawPointerId] = pointer = new Pointer(Pointer.GetNextFreeId(),
5050
PointerType.Touch, _pointers.Count == 0);
51-
pointer.Capture(hit);
51+
pointer.Capture(hit, CaptureSource.Implicit);
5252
}
5353

5454
var target = pointer.Captured ?? args.InputHitTestResult.firstEnabledAncestor ?? args.Root;
@@ -109,6 +109,7 @@ public void ProcessRawEvent(RawInputEventArgs ev)
109109
{
110110
target.RaiseEvent(e);
111111
}
112+
pointer?.Capture(null, CaptureSource.Implicit);
112113
}
113114
}
114115

@@ -117,7 +118,7 @@ public void ProcessRawEvent(RawInputEventArgs ev)
117118
_pointers.Remove(args.RawPointerId);
118119
using (pointer)
119120
{
120-
pointer?.Capture(null);
121+
pointer?.Capture(null, CaptureSource.Platform);
121122
pointer?.CaptureGestureRecognizer(null);
122123
if (pointer != null)
123124
pointer.IsGestureRecognitionSkipped = false;

0 commit comments

Comments
 (0)