diff --git a/src/Uno.CrossTargetting.targets b/src/Uno.CrossTargetting.targets index a19d815a80f3..08c09d9d52a7 100644 --- a/src/Uno.CrossTargetting.targets +++ b/src/Uno.CrossTargetting.targets @@ -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). @@ -66,12 +65,12 @@ - $(DefineConstants);__WASM__;UNO_HAS_ENHANCED_HIT_TEST_PROPERTY;UNO_HAS_ENHANCED_LIFECYCLE;UNO_HAS_MANAGED_POINTERS;HAS_INPUT_INJECTOR + $(DefineConstants);__WASM__;UNO_HAS_ENHANCED_LIFECYCLE;UNO_HAS_MANAGED_POINTERS;HAS_INPUT_INJECTOR $(DefineConstants);__SKIA__;SUPPORTS_RTL;UNO_SUPPORTS_NATIVEHOST;UNO_HAS_ENHANCED_LIFECYCLE - $(DefineConstants);UNO_HAS_MANAGED_POINTERS;UNO_HAS_ENHANCED_HIT_TEST_PROPERTY;UNO_HAS_MANAGED_SCROLL_PRESENTER;HAS_INPUT_INJECTOR + $(DefineConstants);UNO_HAS_MANAGED_POINTERS;UNO_HAS_MANAGED_SCROLL_PRESENTER;HAS_INPUT_INJECTOR $(DefineConstants);HAS_COMPOSITION_API;UNO_HAS_BORDER_VISUAL $(DefineConstants);HAS_RENDER_TARGET_BITMAP diff --git a/src/Uno.UI/Runtime/BrowserPointerInputSource.wasm.cs b/src/Uno.UI/Runtime/BrowserPointerInputSource.wasm.cs index 4e9b854d4c1d..51c2741190c9 100644 --- a/src/Uno.UI/Runtime/BrowserPointerInputSource.wasm.cs +++ b/src/Uno.UI/Runtime/BrowserPointerInputSource.wasm.cs @@ -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); @@ -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; diff --git a/src/Uno.UI/UI/Xaml/UIElement.Pointers.cs b/src/Uno.UI/UI/Xaml/UIElement.Pointers.cs index bedd8ab61201..26c7c315fe8a 100644 --- a/src/Uno.UI/UI/Xaml/UIElement.Pointers.cs +++ b/src/Uno.UI/UI/Xaml/UIElement.Pointers.cs @@ -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 } @@ -267,7 +267,7 @@ internal struct PointerEventDispatchResult /// 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