From c73d66dbe7f7b4f7dc5a2d8d77518269df5a13dd Mon Sep 17 00:00:00 2001 From: Elias Holzer Date: Fri, 12 Apr 2024 15:51:47 +0200 Subject: [PATCH] Testing injection of notifications - do we need to implement IWorldSpace2d? What is the default implementation doing? How would we like to express mouse coords? Very much uncharted/undocumented everything.. --- VL.CEF.Skia/VL.CEF.Skia.vl | 267 ++++++- VL.CEF/help/Explanation Overview WebImage.vl | 796 +++++++++++++++++++ VL.CEF/src/WebBrowser.InputHandling.cs | 20 +- 3 files changed, 1073 insertions(+), 10 deletions(-) create mode 100644 VL.CEF/help/Explanation Overview WebImage.vl diff --git a/VL.CEF.Skia/VL.CEF.Skia.vl b/VL.CEF.Skia/VL.CEF.Skia.vl index f67f696..632d9d1 100644 --- a/VL.CEF.Skia/VL.CEF.Skia.vl +++ b/VL.CEF.Skia/VL.CEF.Skia.vl @@ -1,6 +1,6 @@  - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + Comment + + + + + + + + 9 + Comment + + + + + + + + 9 + Link + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bang + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Press + + + + + + + + + + + + + + + + + + 9 + Comment + + + + + + + + 9 + Comment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + Comment + + + + + + + + 9 + Comment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VL.CEF/src/WebBrowser.InputHandling.cs b/VL.CEF/src/WebBrowser.InputHandling.cs index ca6cc2d..1b47eb2 100644 --- a/VL.CEF/src/WebBrowser.InputHandling.cs +++ b/VL.CEF/src/WebBrowser.InputHandling.cs @@ -1,6 +1,7 @@ using Stride.Core.Mathematics; using System; using System.Diagnostics; +using VL.Core; using VL.Lib.IO; using VL.Lib.IO.Notifications; using Xilium.CefGlue; @@ -11,11 +12,11 @@ partial class WebBrowser { CefEventFlags mouseModifiers; - public bool SendNotification(INotification notification) + public bool SendNotification(INotification notification, Func getPosition) { if (notification is MouseNotification mouseNotification) { - HandleMouseNotification(mouseNotification); + HandleMouseNotification(mouseNotification, getPosition); return true; } else if (notification is KeyNotification keyNotification) @@ -25,15 +26,15 @@ public bool SendNotification(INotification notification) } else if (notification is TouchNotification touchNotification) { - HandleTouchNotification(touchNotification); + HandleTouchNotification(touchNotification, getPosition); return true; } return false; } - private void HandleTouchNotification(TouchNotification n) + private void HandleTouchNotification(TouchNotification n, Func getPosition) { - var position = n.Position.DeviceToLogical(ScaleFactor); + var position = GetPositionInBrowserSpace(n, getPosition); var touchEvent = new CefTouchEvent() { Id = n.Id, @@ -104,7 +105,7 @@ private void HandleKeyNotification(KeyNotification n) Vector2 lastPosition; Stopwatch stopwatch = Stopwatch.StartNew(); - private void HandleMouseNotification(MouseNotification n) + private void HandleMouseNotification(MouseNotification n, Func getPosition) { if (n is MouseButtonNotification buttonNotification) { @@ -142,7 +143,7 @@ private void HandleMouseNotification(MouseNotification n) } { - var position = n.Position.DeviceToLogical(ScaleFactor); + var position = GetPositionInBrowserSpace(n, getPosition); var mouseEvent = new CefMouseEvent((int)position.X, (int)position.Y, GetModifiers(n)); var browserHost = BrowserHost; switch (n.Kind) @@ -209,5 +210,10 @@ CefEventFlags GetModifiers(NotificationBase n) result |= CefEventFlags.ControlDown | CefEventFlags.IsLeft; return result | mouseModifiers; } + + Vector2 GetPositionInBrowserSpace(NotificationWithPosition notification, Func getPosition) + { + return getPosition(notification).DeviceToLogical(ScaleFactor); + } } }