Commit 68f78e87 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

Fuchsia: Add support for receiving input events from Scenic.

ViewsV2 eschews InputConnection in favor of using Scenic for delivering
input events to applications.

This adds input event handling for pointer and touch events via
ScenicSession.

Keyboard events are already being delivered by the ImeService and
are handled by InputMethodKeyboardControllerFuchsia, so no changes are
needed for receiving keyboard inputs.

      "tiles --input_path=new" switches.

Test: manual test against both "tiles --input_path=old" and
Bug: 900428
Change-Id: I8ba2e0c7d35d0dd9d52ef54379d6d693bd9e82d5
Reviewed-on: https://chromium-review.googlesource.com/c/1308910
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604758}
parent ec445d80
......@@ -65,9 +65,8 @@ ScenicWindow::ScenicWindow(
view_listener_binding_.set_error_handler(
fit::bind_member(this, &ScenicWindow::OnViewError));
// Setup input event listener.
// TODO(crbug.com/881591): Migrate off InputConnection and use IMEService
// for receiving keyboard input instead.
// Setup ViewsV1 input event listener.
// TODO(crbug.com/881591): Remove this when ViewsV1 deprecation is complete.
fuchsia::sys::ServiceProviderPtr view_service_provider;
view_->GetServiceProvider(view_service_provider.NewRequest());
view_service_provider->ConnectToService(
......@@ -226,23 +225,34 @@ void ScenicWindow::OnScenicError() {
void ScenicWindow::OnScenicEvents(
fidl::VectorPtr<fuchsia::ui::scenic::Event> events) {
for (const auto& event : events.get()) {
if (!event.is_gfx() || !event.gfx().is_metrics())
continue;
auto& metrics = event.gfx().metrics();
if (metrics.node_id != parent_node_.id())
continue;
device_pixel_ratio_ =
std::max(metrics.metrics.scale_x, metrics.metrics.scale_y);
ScenicScreen* screen = manager_->screen();
if (screen)
screen->OnWindowMetrics(window_id_, device_pixel_ratio_);
if (!size_dips_.IsEmpty())
UpdateSize();
for (const auto& event : *events) {
if (event.is_gfx()) {
if (!event.gfx().is_metrics())
continue;
auto& metrics = event.gfx().metrics();
if (metrics.node_id != parent_node_.id())
continue;
device_pixel_ratio_ =
std::max(metrics.metrics.scale_x, metrics.metrics.scale_y);
ScenicScreen* screen = manager_->screen();
if (screen)
screen->OnWindowMetrics(window_id_, device_pixel_ratio_);
if (!size_dips_.IsEmpty())
UpdateSize();
} else if (event.is_input()) {
auto& input_event = event.input();
if (input_event.is_focus()) {
delegate_->OnActivationChanged(input_event.focus().focused);
} else {
// Scenic doesn't care if the input event was handled, so ignore the
// "handled" status.
ignore_result(event_dispatcher_.ProcessEvent(input_event));
}
}
}
}
......
......@@ -78,6 +78,7 @@ class OZONE_EXPORT ScenicWindow : public PlatformWindow,
OnPropertiesChangedCallback callback) override;
// fuchsia::ui::input::InputListener interface.
// TODO(crbug.com/881591): Remove this when ViewsV1 deprecation is complete.
void OnEvent(fuchsia::ui::input::InputEvent event,
OnEventCallback callback) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment