[baseview][input] Enable Baseview's OnInputEvent callback.
This is not the flip itself to Scenic input; this is the CL that enables
BaseView to respond to Scenic input.
SCN-1149 #done
SCN-938 #comment
SY-908 #comment
TEST=CQ and manual tests:
{tiles, scenic input, web_runner} - PASS
{tiles, viewmanager input, web_runner} - PASS
Change-Id: I868404ed1388caf8f2fd74ee5afa51f06b5e679d
diff --git a/public/lib/ui/base_view/cpp/v1_base_view.cc b/public/lib/ui/base_view/cpp/v1_base_view.cc
index bf50750..4d6e2d8 100644
--- a/public/lib/ui/base_view/cpp/v1_base_view.cc
+++ b/public/lib/ui/base_view/cpp/v1_base_view.cc
@@ -112,13 +112,22 @@
void V1BaseView::HandleSessionEvents(
fidl::VectorPtr<fuchsia::ui::scenic::Event> events) {
const fuchsia::ui::gfx::Metrics* new_metrics = nullptr;
- for (const auto& event : *events) {
+ for (size_t i = 0; i < events->size(); ++i) {
+ const auto& event = (*events)[i];
if (event.is_gfx()) {
const fuchsia::ui::gfx::Event& scenic_event = event.gfx();
if (scenic_event.is_metrics() &&
scenic_event.metrics().node_id == parent_node_.id()) {
new_metrics = &scenic_event.metrics().metrics;
}
+ } else if (event.is_input()) {
+ // Act on input event just once.
+ OnInputEvent(std::move((*events)[i].input()));
+ // Create a dummy event to safely take its place.
+ fuchsia::ui::scenic::Command unhandled;
+ fuchsia::ui::scenic::Event unhandled_event;
+ unhandled_event.set_unhandled(std::move(unhandled));
+ (*events)[i] = std::move(unhandled_event);
}
}