Skip to content

Commit

Permalink
perf(WindowManager): Add SetPointerCapture binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Mar 24, 2023
1 parent bf0276d commit 6fc79f1
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 @@ -343,8 +343,7 @@ internal static void RemoveActivePointer(PointerIdentifier managedId)
#region Capture
partial void CapturePointerNative(Pointer pointer)
{
var command = "Uno.UI.WindowManager.current.setPointerCapture(" + HtmlId + ", " + pointer.PointerId + ");";
WebAssemblyRuntime.InvokeJS(command);
WindowManagerInterop.SetPointerCapture(HtmlId, pointer.PointerId);
}

partial void ReleasePointerNative(Pointer pointer)
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 @@ -192,6 +192,16 @@ private struct WindowManagerSetPointerEventsParams

#endregion

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

#region MeasureView
internal static Size MeasureView(IntPtr htmlId, Size availableSize, bool measureContent)
{
Expand Down Expand Up @@ -1216,6 +1226,9 @@ internal static partial class NativeMethods
[JSImport("globalThis.Uno.UI.WindowManager.current.setElementTransformNativeFast")]
internal static partial void SetElementTransform(IntPtr htmlId, float m11, float m12, float m21, float m22, float m31, float m32);

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

[JSImport("globalThis.Uno.UI.WindowManager.current.setPointerEventsNativeFast")]
internal static partial void SetPointerEvents(IntPtr htmlId, bool enabled);

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 @@ -1474,10 +1474,8 @@ namespace Uno.UI {
}
}

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

return "ok";
}

public releasePointerCapture(viewId: number, pointerId: number): string {
Expand Down

0 comments on commit 6fc79f1

Please sign in to comment.