Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b259127

Browse files
authored
[dart:ui] Add view ID to PointerData.toString (#51352)
The `view_id` is useful information as the pointer's `x` and `y` coordinates are relative to the view's origin. Part of flutter/flutter#112205 Part of flutter/flutter#142845 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent b230278 commit b259127

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

lib/ui/pointer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class PointerData {
381381
final double rotation;
382382

383383
@override
384-
String toString() => 'PointerData(x: $physicalX, y: $physicalY)';
384+
String toString() => 'PointerData(viewId: $viewId, x: $physicalX, y: $physicalY)';
385385

386386
/// Returns a complete textual description of the information in this object.
387387
String toStringFull() {

lib/ui/window/platform_configuration.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,13 @@ class PlatformConfiguration final {
481481
void ReportTimings(std::vector<int64_t> timings);
482482

483483
//----------------------------------------------------------------------------
484-
/// @brief Retrieves the Window with the given ID managed by the
485-
/// `PlatformConfiguration`.
484+
/// @brief Retrieves the viewport metrics with the given ID managed by
485+
/// the `PlatformConfiguration`.
486486
///
487-
/// @param[in] window_id The id of the window to find and return.
487+
/// @param[in] view_id The id of the view's viewport metrics to return.
488488
///
489-
/// @return a pointer to the Window. Returns nullptr if the ID is not
490-
/// found.
489+
/// @return a pointer to the ViewportMetrics. Returns nullptr if the ID is
490+
/// not found.
491491
///
492492
const ViewportMetrics* GetMetrics(int view_id);
493493

lib/web_ui/lib/pointer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class PointerData {
111111
final double rotation;
112112

113113
@override
114-
String toString() => 'PointerData(x: $physicalX, y: $physicalY)';
114+
String toString() => 'PointerData(viewId: $viewId, x: $physicalX, y: $physicalY)';
115115
String toStringFull() {
116116
return '$runtimeType('
117117
'embedderId: $embedderId, '

shell/platform/embedder/tests/embedder_unittests.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2700,7 +2700,7 @@ TEST_F(EmbedderTest, CanSendPointer) {
27002700
CREATE_NATIVE_ENTRY([&message_latch](Dart_NativeArguments args) {
27012701
auto message = tonic::DartConverter<std::string>::FromDart(
27022702
Dart_GetNativeArgument(args, 0));
2703-
ASSERT_EQ("PointerData(x: 123.0, y: 456.0)", message);
2703+
ASSERT_EQ("PointerData(viewId: 0, x: 123.0, y: 456.0)", message);
27042704
message_latch.Signal();
27052705
}));
27062706

@@ -2715,6 +2715,7 @@ TEST_F(EmbedderTest, CanSendPointer) {
27152715
pointer_event.x = 123;
27162716
pointer_event.y = 456;
27172717
pointer_event.timestamp = static_cast<size_t>(1234567890);
2718+
pointer_event.view_id = 0;
27182719

27192720
FlutterEngineResult result =
27202721
FlutterEngineSendPointerEvent(engine.get(), &pointer_event, 1);

0 commit comments

Comments
 (0)