Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pointers): WASM Fix possible unrelated pointer entered #18046

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Uno.CrossTargetting.targets
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
UIElements. On iOS, this means additional weak references
backed fields to handle opaque native reference pinning and avoid
memory leaks.
- UNO_HAS_ENHANCED_HIT_TEST_PROPERTY: Used to mark if the ENUM hit test property is present or not
- UNO_HAS_MANAGED_SCROLL_PRESENTER: Determines if the platforms supports managed scroll presenter which
uses render transforms instead of native scroll feature (if any)
- UNO_HAS_MANAGED_POINTERS: Determines if the pointer events are dispatched by uno instead of the system (if any).
Expand All @@ -66,12 +65,12 @@
</PropertyGroup>

<PropertyGroup Condition="'$(UnoRuntimeIdentifier)'=='WebAssembly'">
<DefineConstants>$(DefineConstants);__WASM__;UNO_HAS_ENHANCED_HIT_TEST_PROPERTY;UNO_HAS_ENHANCED_LIFECYCLE;UNO_HAS_MANAGED_POINTERS;HAS_INPUT_INJECTOR</DefineConstants>
<DefineConstants>$(DefineConstants);__WASM__;UNO_HAS_ENHANCED_LIFECYCLE;UNO_HAS_MANAGED_POINTERS;HAS_INPUT_INJECTOR</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(UnoRuntimeIdentifier)'=='Skia'">
<DefineConstants>$(DefineConstants);__SKIA__;SUPPORTS_RTL;UNO_SUPPORTS_NATIVEHOST;UNO_HAS_ENHANCED_LIFECYCLE</DefineConstants>
<DefineConstants>$(DefineConstants);UNO_HAS_MANAGED_POINTERS;UNO_HAS_ENHANCED_HIT_TEST_PROPERTY;UNO_HAS_MANAGED_SCROLL_PRESENTER;HAS_INPUT_INJECTOR</DefineConstants>
<DefineConstants>$(DefineConstants);UNO_HAS_MANAGED_POINTERS;UNO_HAS_MANAGED_SCROLL_PRESENTER;HAS_INPUT_INJECTOR</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_COMPOSITION_API;UNO_HAS_BORDER_VISUAL</DefineConstants>
<DefineConstants>$(DefineConstants);HAS_RENDER_TARGET_BITMAP</DefineConstants>
</PropertyGroup>
Expand Down
8 changes: 8 additions & 0 deletions src/Uno.UI/Runtime/BrowserPointerInputSource.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal partial class BrowserPointerInputSource : IUnoCorePointerInputSource
private static readonly Logger? _logTrace = _log.IsTraceEnabled(LogLevel.Trace) ? _log : null;

private ulong _bootTime;
private bool _isOver;
private PointerPoint? _lastPoint;
private CoreCursor _pointerCursor = new(CoreCursorType.Arrow, 0);

Expand Down Expand Up @@ -107,11 +108,18 @@ private static int OnNativeEvent(

switch (evt)
{
case HtmlPointerEvent.pointerover when that._isOver:
// If there isn't any html node that hit-tested, we might get a pointer-over event, but we are interested only in pointer entering over the window
_logTrace?.Trace("Ignoring pointer-over event since pointer is already over the window.");
break;

case HtmlPointerEvent.pointerover:
that._isOver = true;
that.PointerEntered?.Invoke(that, args);
break;

case HtmlPointerEvent.pointerleave:
that._isOver = false;
that.PointerExited?.Invoke(that, args);
break;

Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/UIElement.Pointers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static UIElement()
var uiElement = typeof(UIElement);
VisibilityProperty.GetMetadata(uiElement).MergePropertyChangedCallback(ClearPointersStateIfNeeded);
Microsoft.UI.Xaml.Controls.Control.IsEnabledProperty.GetMetadata(typeof(Microsoft.UI.Xaml.Controls.Control)).MergePropertyChangedCallback(ClearPointersStateIfNeeded);
#if UNO_HAS_ENHANCED_HIT_TEST_PROPERTY
#if UNO_HAS_MANAGED_POINTERS
HitTestVisibilityProperty.GetMetadata(uiElement).MergePropertyChangedCallback(ClearPointersStateIfNeeded);
#endif
}
Expand Down Expand Up @@ -267,7 +267,7 @@ internal struct PointerEventDispatchResult
/// </summary>
internal HitTestability GetHitTestVisibility()
{
#if __WASM__ || __SKIA__ || __MACOS__
#if UNO_HAS_MANAGED_POINTERS
return HitTestVisibility;
#else
// This is a coalesced HitTestVisible and should be unified with it
Expand Down
Loading