Skip to content

Commit

Permalink
perf(WindowManager): Add ReleasePointerCapture binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Mar 27, 2023
1 parent 6fc79f1 commit aa423c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ partial void CapturePointerNative(Pointer pointer)

partial void ReleasePointerNative(Pointer pointer)
{
var command = "Uno.UI.WindowManager.current.releasePointerCapture(" + HtmlId + ", " + pointer.PointerId + ");";
WebAssemblyRuntime.InvokeJS(command);
WindowManagerInterop.ReleasePointerCapture(HtmlId, pointer.PointerId);
}
#endregion

Expand Down
13 changes: 13 additions & 0 deletions src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ internal static void SetPointerCapture(IntPtr htmlId, uint pointerId)
#endif
}

internal static void ReleasePointerCapture(IntPtr htmlId, uint pointerId)
{
#if NET7_0_OR_GREATER
NativeMethods.ReleasePointerCapture(htmlId, pointerId);
#else
var command = "Uno.UI.WindowManager.current.releasePointerCapture(" + htmlId + ", " + pointerId + ");";
WebAssemblyRuntime.InvokeJS(command);
#endif
}

#region MeasureView
internal static Size MeasureView(IntPtr htmlId, Size availableSize, bool measureContent)
{
Expand Down Expand Up @@ -1220,6 +1230,9 @@ internal static partial void ArrangeElement(
[JSImport("globalThis.Uno.UI.WindowManager.current.measureViewNativeFast")]
internal static partial void MeasureView(IntPtr htmlId, double availableWidth, double availableHeight, bool measureContent, IntPtr pReturn);

[JSImport("globalThis.Uno.UI.WindowManager.current.releasePointerCapture")]
internal static partial void ReleasePointerCapture(IntPtr htmlId, double pointerId);

[JSImport("globalThis.Uno.UI.WindowManager.current.setAttributesNativeFast")]
internal static partial void SetAttributes(IntPtr htmlId, string[] pairs);

Expand Down
4 changes: 1 addition & 3 deletions src/Uno.UI/ts/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1478,10 +1478,8 @@ namespace Uno.UI {
this.getView(viewId).setPointerCapture(pointerId);
}

public releasePointerCapture(viewId: number, pointerId: number): string {
public releasePointerCapture(viewId: number, pointerId: number): void {
this.getView(viewId).releasePointerCapture(pointerId);

return "ok";
}

public focusView(elementId: number): string {
Expand Down

0 comments on commit aa423c3

Please sign in to comment.