From b2f119de6b1d30c0cadd71d4e6c507bbe13042a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:53:41 -0700 Subject: [PATCH] [dart:ui] Add view ID to `PointerData.toString` (flutter/engine#51352) The `view_id` is useful information as the pointer's `x` and `y` coordinates are relative to the view's origin. Part of https://github.com/flutter/flutter/issues/112205 Part of https://github.com/flutter/flutter/issues/142845 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- engine/src/flutter/lib/ui/pointer.dart | 2 +- .../src/flutter/lib/ui/window/platform_configuration.h | 10 +++++----- engine/src/flutter/lib/web_ui/lib/pointer.dart | 2 +- .../platform/embedder/tests/embedder_unittests.cc | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/engine/src/flutter/lib/ui/pointer.dart b/engine/src/flutter/lib/ui/pointer.dart index cff2ec7fdf..fe99de4b90 100644 --- a/engine/src/flutter/lib/ui/pointer.dart +++ b/engine/src/flutter/lib/ui/pointer.dart @@ -381,7 +381,7 @@ class PointerData { final double rotation; @override - String toString() => 'PointerData(x: $physicalX, y: $physicalY)'; + String toString() => 'PointerData(viewId: $viewId, x: $physicalX, y: $physicalY)'; /// Returns a complete textual description of the information in this object. String toStringFull() { diff --git a/engine/src/flutter/lib/ui/window/platform_configuration.h b/engine/src/flutter/lib/ui/window/platform_configuration.h index c9162a2687..a8b54a80b8 100644 --- a/engine/src/flutter/lib/ui/window/platform_configuration.h +++ b/engine/src/flutter/lib/ui/window/platform_configuration.h @@ -481,13 +481,13 @@ class PlatformConfiguration final { void ReportTimings(std::vector timings); //---------------------------------------------------------------------------- - /// @brief Retrieves the Window with the given ID managed by the - /// `PlatformConfiguration`. + /// @brief Retrieves the viewport metrics with the given ID managed by + /// the `PlatformConfiguration`. /// - /// @param[in] window_id The id of the window to find and return. + /// @param[in] view_id The id of the view's viewport metrics to return. /// - /// @return a pointer to the Window. Returns nullptr if the ID is not - /// found. + /// @return a pointer to the ViewportMetrics. Returns nullptr if the ID is + /// not found. /// const ViewportMetrics* GetMetrics(int view_id); diff --git a/engine/src/flutter/lib/web_ui/lib/pointer.dart b/engine/src/flutter/lib/web_ui/lib/pointer.dart index a14455712c..cd69ee6350 100644 --- a/engine/src/flutter/lib/web_ui/lib/pointer.dart +++ b/engine/src/flutter/lib/web_ui/lib/pointer.dart @@ -111,7 +111,7 @@ class PointerData { final double rotation; @override - String toString() => 'PointerData(x: $physicalX, y: $physicalY)'; + String toString() => 'PointerData(viewId: $viewId, x: $physicalX, y: $physicalY)'; String toStringFull() { return '$runtimeType(' 'embedderId: $embedderId, ' diff --git a/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc index da76770763..44c7426fd7 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc +++ b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc @@ -2700,7 +2700,7 @@ TEST_F(EmbedderTest, CanSendPointer) { CREATE_NATIVE_ENTRY([&message_latch](Dart_NativeArguments args) { auto message = tonic::DartConverter::FromDart( Dart_GetNativeArgument(args, 0)); - ASSERT_EQ("PointerData(x: 123.0, y: 456.0)", message); + ASSERT_EQ("PointerData(viewId: 0, x: 123.0, y: 456.0)", message); message_latch.Signal(); })); @@ -2715,6 +2715,7 @@ TEST_F(EmbedderTest, CanSendPointer) { pointer_event.x = 123; pointer_event.y = 456; pointer_event.timestamp = static_cast(1234567890); + pointer_event.view_id = 0; FlutterEngineResult result = FlutterEngineSendPointerEvent(engine.get(), &pointer_event, 1);