Browse Source

change name and check invalidate rect

ahopper 7 years ago
parent
commit
7c5802efcf

+ 3 - 3
src/Avalonia.Controls/TopLevel.cs

@@ -230,7 +230,7 @@ namespace Avalonia.Controls
         void IRenderRoot.Invalidate(Rect rect)
         {
             PlatformImpl?.Invalidate(rect);
-            UpdatePointerOver();
+            UpdatePointerOver(rect);
         }
         
         /// <inheritdoc/>
@@ -351,9 +351,9 @@ namespace Avalonia.Controls
             _inputManager.ProcessInput(e);
         }
 
-        private void UpdatePointerOver()
+        private void UpdatePointerOver(Rect rect)
         {
-            (this as IInputRoot).MouseDevice.LayoutUpdated(this);
+            (this as IInputRoot).MouseDevice.SceneInvalidated(this, rect);
         }
     }
 }

+ 1 - 1
src/Avalonia.Input/IPointerDevice.cs

@@ -13,6 +13,6 @@ namespace Avalonia.Input
 
         Point GetPosition(IVisual relativeTo);
 
-        void LayoutUpdated(IInputRoot root);
+        void SceneInvalidated(IInputRoot root, Rect rect);
     }
 }

+ 12 - 7
src/Avalonia.Input/MouseDevice.cs

@@ -104,16 +104,21 @@ namespace Avalonia.Input
                 ProcessRawEvent(margs);
         }
 
-        public void LayoutUpdated(IInputRoot root)
+        public void SceneInvalidated(IInputRoot root, Rect rect)
         {
-            if (Captured == null)
+            var clientPoint = root.PointToClient(Position);
+
+            if (rect.Contains(clientPoint))
             {
-                SetPointerOver(this, root, root.PointToClient(Position));    
+                if (Captured == null)
+                {
+                    SetPointerOver(this, root, clientPoint);
+                }
+                else
+                {
+                    SetPointerOver(this, root, Captured);
+                }
             }
-            else
-            {
-                SetPointerOver(this, root, Captured);               
-            }                   
         }
 
         private void ProcessRawEvent(RawMouseEventArgs e)