Revert "[fuchsia] Convert Gfx PlatformView to use modern TouchSource API (#35018)"
This reverts commit 25e8021c91e4c4f3805f6fa635868d4dca1e29f0.
diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc
index 1d491d3..ab94955 100644
--- a/shell/platform/fuchsia/flutter/engine.cc
+++ b/shell/platform/fuchsia/flutter/engine.cc
@@ -166,8 +166,8 @@
} else {
gfx_protocols.set_view_focuser(focuser.NewRequest());
gfx_protocols.set_view_ref_focused(view_ref_focused.NewRequest());
- gfx_protocols.set_touch_source(touch_source.NewRequest());
- // GFX used only on products without a mouse.
+ // TODO(fxbug.dev/85125): Enable TouchSource for GFX.
+ // gfx_protocols.set_touch_source(touch_source.NewRequest());
}
scenic->CreateSessionT(std::move(gfx_protocols), [] {});
diff --git a/shell/platform/fuchsia/flutter/platform_view.cc b/shell/platform/fuchsia/flutter/platform_view.cc
index 85d671c..6ae402b 100644
--- a/shell/platform/fuchsia/flutter/platform_view.cc
+++ b/shell/platform/fuchsia/flutter/platform_view.cc
@@ -109,31 +109,33 @@
});
// Begin watching for pointer events.
- pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
- std::vector<flutter::PointerData> events) {
- if (!weak) {
- FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
- return;
- }
+ if (is_flatland) { // TODO(fxbug.dev/85125): make unconditional
+ pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
+ std::vector<flutter::PointerData> events) {
+ if (!weak) {
+ FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
+ return;
+ }
- if (events.empty()) {
- return; // No work, bounce out.
- }
+ if (events.size() == 0) {
+ return; // No work, bounce out.
+ }
- // If pixel ratio hasn't been set, use a default value of 1.
- const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
- auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
- for (size_t i = 0; i < events.size(); ++i) {
- auto& event = events[i];
- // Translate logical to physical coordinates, as per
- // flutter::PointerData contract. Done here because pixel ratio comes
- // from the graphics API.
- event.physical_x = event.physical_x * pixel_ratio;
- event.physical_y = event.physical_y * pixel_ratio;
- packet->SetPointerData(i, event);
- }
- weak->DispatchPointerDataPacket(std::move(packet));
- });
+ // If pixel ratio hasn't been set, use a default value of 1.
+ const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
+ auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
+ for (size_t i = 0; i < events.size(); ++i) {
+ auto& event = events[i];
+ // Translate logical to physical coordinates, as per
+ // flutter::PointerData contract. Done here because pixel ratio comes
+ // from the graphics API.
+ event.physical_x = event.physical_x * pixel_ratio;
+ event.physical_y = event.physical_y * pixel_ratio;
+ packet->SetPointerData(i, event);
+ }
+ weak->DispatchPointerDataPacket(std::move(packet));
+ });
+ }
// Configure the pointer injector delegate.
pointer_injector_delegate_ = std::make_unique<PointerInjectorDelegate>(
diff --git a/shell/platform/fuchsia/flutter/platform_view_unittest.cc b/shell/platform/fuchsia/flutter/platform_view_unittest.cc
index 4f6a9cc..92c04c4 100644
--- a/shell/platform/fuchsia/flutter/platform_view_unittest.cc
+++ b/shell/platform/fuchsia/flutter/platform_view_unittest.cc
@@ -1396,7 +1396,8 @@
EXPECT_EQ(expected_result_string, response->result_string);
}
-TEST_F(PlatformViewTests, TouchSourceLogicalToPhysicalConversion) {
+// TODO(fxbug.dev/85125): Enable when GFX converts to TouchSource.
+TEST_F(PlatformViewTests, DISABLED_TouchSourceLogicalToPhysicalConversion) {
constexpr std::array<std::array<float, 2>, 2> kRect = {{{0, 0}, {20, 20}}};
constexpr std::array<float, 9> kIdentity = {1, 0, 0, 0, 1, 0, 0, 0, 1};
constexpr fuchsia::ui::pointer::TouchInteractionId kIxnOne = {
diff --git a/shell/platform/fuchsia/flutter/pointer_delegate.cc b/shell/platform/fuchsia/flutter/pointer_delegate.cc
index 1977521..71cdb63 100644
--- a/shell/platform/fuchsia/flutter/pointer_delegate.cc
+++ b/shell/platform/fuchsia/flutter/pointer_delegate.cc
@@ -447,9 +447,7 @@
// Start watching both channels.
touch_source_->Watch(std::move(touch_responses_), /*copy*/ touch_responder_);
touch_responses_.clear();
- if (mouse_source_) {
- mouse_source_->Watch(/*copy*/ mouse_responder_);
- }
+ mouse_source_->Watch(/*copy*/ mouse_responder_);
}
} // namespace flutter_runner