blob: 68d819a1da4316be915f428ca2d6145d06a69d69 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/ui/scenic/lib/input/input_system.h"
namespace scenic_impl::input {
InputSystem::InputSystem(sys::ComponentContext *context, inspect::Node &inspect_node,
RequestFocusFunc request_focus)
: request_focus_(std::move(request_focus)),
hit_tester_(view_tree_snapshot_, inspect_node),
mouse_system_(context, view_tree_snapshot_, hit_tester_,
[this](zx_koid_t koid) { request_focus_(koid); }),
touch_system_(context, view_tree_snapshot_, hit_tester_, inspect_node),
pointerinjector_registry_(
context,
/*inject_touch_exclusive=*/
[&touch_system = touch_system_](InternalTouchEvent event, StreamId stream_id) {
touch_system.InjectTouchEventExclusive(std::move(event), stream_id);
},
/*inject_touch_hit_tested=*/
[&touch_system = touch_system_](InternalTouchEvent event, StreamId stream_id) {
touch_system.InjectTouchEventHitTested(std::move(event), stream_id);
},
/*inject_mouse_exclusive=*/
[&mouse_system = mouse_system_](InternalMouseEvent event, StreamId stream_id) {
mouse_system.InjectMouseEventExclusive(std::move(event), stream_id);
},
/*inject_mouse_hit_tested=*/
[&mouse_system = mouse_system_](InternalMouseEvent event, StreamId stream_id) {
mouse_system.InjectMouseEventHitTested(std::move(event), stream_id);
},
// Explicit call necessary to cancel mouse stream, because mouse stream itself does not
// track phase.
/*cancel_mouse_stream=*/
[&mouse_system = mouse_system_](StreamId stream_id) {
mouse_system.CancelMouseStream(stream_id);
},
inspect_node.CreateChild("PointerinjectorRegistry")) {}
} // namespace scenic_impl::input