@@ -21,6 +21,7 @@ FlatlandPlatformView::FlatlandPlatformView(
21
21
fuchsia::ui::views::ViewRefFocusedHandle view_ref_focused,
22
22
fuchsia::ui::composition::ParentViewportWatcherHandle
23
23
parent_viewport_watcher,
24
+ fuchsia::ui::pointerinjector::RegistryHandle pointerinjector_registry,
24
25
OnEnableWireframe wireframe_enabled_callback,
25
26
OnCreateFlatlandView on_create_view_callback,
26
27
OnUpdateView on_update_view_callback,
@@ -43,6 +44,7 @@ FlatlandPlatformView::FlatlandPlatformView(
43
44
std::move(mouse_source),
44
45
std::move(focuser),
45
46
std::move(view_ref_focused),
47
+ std::move(pointerinjector_registry),
46
48
std::move(wireframe_enabled_callback),
47
49
std::move(on_update_view_callback),
48
50
std::move(on_create_surface_callback),
@@ -148,6 +150,10 @@ void FlatlandPlatformView::OnChildViewViewRef(
148
150
149
151
focus_delegate_->OnChildViewViewRef (view_id, std::move (view_ref));
150
152
153
+ fuchsia::ui::views::ViewRef view_ref_clone;
154
+ fidl::Clone (view_ref, &view_ref_clone);
155
+ pointer_injector_delegate_->OnCreateView (view_id, std::move (view_ref_clone));
156
+
151
157
child_view_info_.at (content_id)
152
158
.child_view_watcher ->GetViewRef (
153
159
[this , content_id, view_id](fuchsia::ui::views::ViewRef view_ref) {
@@ -164,16 +170,32 @@ void FlatlandPlatformView::OnCreateView(ViewCallback on_view_created,
164
170
task_runners_.GetPlatformTaskRunner (),
165
171
view_id = view_id_raw](
166
172
fuchsia::ui::composition::ContentId content_id,
167
- fuchsia::ui::composition::ChildViewWatcherPtr
168
- child_view_watcher ) {
173
+ fuchsia::ui::composition::ChildViewWatcherHandle
174
+ child_view_watcher_handle ) {
169
175
FML_CHECK (weak);
170
176
FML_CHECK (weak->child_view_info_ .count (content_id.value ) == 0 );
177
+
178
+ // Bind the child view watcher to the platform thread so that the FIDL calls
179
+ // are handled on the platform thread.
180
+ fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher =
181
+ child_view_watcher_handle.Bind ();
171
182
FML_CHECK (child_view_watcher);
172
183
173
- child_view_watcher.set_error_handler ([](zx_status_t status) {
174
- FML_LOG (ERROR) << " Interface error on: ChildViewWatcher status: "
175
- << status;
176
- });
184
+ child_view_watcher.set_error_handler (
185
+ [weak, view_id](zx_status_t status) {
186
+ FML_LOG (ERROR) << " Interface error on: ChildViewWatcher status: "
187
+ << status;
188
+
189
+ if (!weak) {
190
+ FML_LOG (WARNING)
191
+ << " Flatland View bound to PlatformView after PlatformView was "
192
+ " destroyed; ignoring." ;
193
+ return ;
194
+ }
195
+
196
+ // Disconnected views cannot listen to pointer events.
197
+ weak->pointer_injector_delegate_ ->OnDestroyView (view_id);
198
+ });
177
199
178
200
platform_task_runner->PostTask (
179
201
fml::MakeCopyable ([weak, view_id, content_id,
@@ -226,6 +248,7 @@ void FlatlandPlatformView::OnDisposeView(int64_t view_id_raw) {
226
248
FML_DCHECK (weak->child_view_info_ .count (content_id.value ) == 1 );
227
249
weak->child_view_info_ .erase (content_id.value );
228
250
weak->focus_delegate_ ->OnDisposeChildView (view_id_raw);
251
+ weak->pointer_injector_delegate_ ->OnDestroyView (view_id_raw);
229
252
});
230
253
};
231
254
on_destroy_view_callback_ (view_id_raw, std::move (on_view_unbound));
0 commit comments