Browse Source
Respond to WM_CAPTURECHANGED (#19685)
* Respond to WM_CAPTURECHANGED
* Addressing PR feedback
---------
Co-authored-by: Jan Kučera <miloush@users.noreply.github.com>
pull/19709/head
Jan Kučera
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
42 additions and
4 deletions
-
src/Avalonia.Base/Input/MouseDevice.cs
-
src/Avalonia.Base/Input/Pointer.cs
-
src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs
-
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
|
|
@ -104,6 +104,9 @@ namespace Avalonia.Input |
|
|
case RawPointerEventType.Swipe: |
|
|
case RawPointerEventType.Swipe: |
|
|
e.Handled = GestureSwipe(mouse, e.Timestamp, e.Root, e.Position, props, ((RawPointerGestureEventArgs)e).Delta, keyModifiers, e.InputHitTestResult.firstEnabledAncestor); |
|
|
e.Handled = GestureSwipe(mouse, e.Timestamp, e.Root, e.Position, props, ((RawPointerGestureEventArgs)e).Delta, keyModifiers, e.InputHitTestResult.firstEnabledAncestor); |
|
|
break; |
|
|
break; |
|
|
|
|
|
case RawPointerEventType.CancelCapture: |
|
|
|
|
|
PlatformCaptureLost(); |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -308,7 +311,7 @@ namespace Avalonia.Input |
|
|
|
|
|
|
|
|
internal void PlatformCaptureLost() |
|
|
internal void PlatformCaptureLost() |
|
|
{ |
|
|
{ |
|
|
_pointer.Capture(null); |
|
|
_pointer.PlatformCaptureLost(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -32,14 +32,28 @@ namespace Avalonia.Input |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal void PlatformCaptureLost() |
|
|
|
|
|
{ |
|
|
|
|
|
if (Captured != null) |
|
|
|
|
|
Capture(null, platformInitiated: true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void Capture(IInputElement? control) |
|
|
public void Capture(IInputElement? control) |
|
|
|
|
|
{ |
|
|
|
|
|
Capture(control, platformInitiated: false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Capture(IInputElement? control, bool platformInitiated) |
|
|
{ |
|
|
{ |
|
|
if (Captured is Visual v1) |
|
|
if (Captured is Visual v1) |
|
|
v1.DetachedFromVisualTree -= OnCaptureDetached; |
|
|
v1.DetachedFromVisualTree -= OnCaptureDetached; |
|
|
var oldCapture = Captured; |
|
|
var oldCapture = Captured; |
|
|
Captured = control; |
|
|
Captured = control; |
|
|
PlatformCapture(control); |
|
|
|
|
|
|
|
|
if (!platformInitiated) |
|
|
|
|
|
PlatformCapture(control); |
|
|
|
|
|
|
|
|
if (oldCapture is Visual v2) |
|
|
if (oldCapture is Visual v2) |
|
|
{ |
|
|
{ |
|
|
var commonParent = FindCommonParent(control, oldCapture); |
|
|
var commonParent = FindCommonParent(control, oldCapture); |
|
|
|
|
|
@ -26,7 +26,8 @@ namespace Avalonia.Input.Raw |
|
|
TouchCancel, |
|
|
TouchCancel, |
|
|
Magnify, |
|
|
Magnify, |
|
|
Rotate, |
|
|
Rotate, |
|
|
Swipe |
|
|
Swipe, |
|
|
|
|
|
CancelCapture |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
|
|
|
@ -394,6 +394,26 @@ namespace Avalonia.Win32 |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case WindowsMessage.WM_CAPTURECHANGED: |
|
|
|
|
|
{ |
|
|
|
|
|
if (IsMouseInPointerEnabled) |
|
|
|
|
|
{ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (_hwnd != lParam) |
|
|
|
|
|
{ |
|
|
|
|
|
_trackingMouse = false; |
|
|
|
|
|
e = new RawPointerEventArgs( |
|
|
|
|
|
_mouseDevice, |
|
|
|
|
|
timestamp, |
|
|
|
|
|
Owner, |
|
|
|
|
|
RawPointerEventType.CancelCapture, |
|
|
|
|
|
new Point(-1, -1), |
|
|
|
|
|
WindowsKeyboardDevice.Instance.Modifiers); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
case WindowsMessage.WM_NCLBUTTONDOWN: |
|
|
case WindowsMessage.WM_NCLBUTTONDOWN: |
|
|
case WindowsMessage.WM_NCRBUTTONDOWN: |
|
|
case WindowsMessage.WM_NCRBUTTONDOWN: |
|
|
case WindowsMessage.WM_NCMBUTTONDOWN: |
|
|
case WindowsMessage.WM_NCMBUTTONDOWN: |
|
|
|