Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 124f672

Browse files
committed
[fuchsia][scenic] Add input shield flag support in Flatland.
This CL adds support for "intercept_all_input" flag in flutter_runner_config for flatland. Test: flutter-embedder-test
1 parent 2875385 commit 124f672

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

shell/platform/fuchsia/flutter/flatland_external_view_embedder.cc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ FlatlandExternalViewEmbedder::FlatlandExternalViewEmbedder(
2828
std::shared_ptr<FlatlandConnection> flatland,
2929
std::shared_ptr<SurfaceProducer> surface_producer,
3030
bool intercept_all_input)
31-
: flatland_(flatland), surface_producer_(surface_producer) {
31+
: flatland_(flatland),
32+
surface_producer_(surface_producer),
33+
intercept_all_input_(intercept_all_input) {
3234
flatland_->flatland()->CreateView2(
3335
std::move(view_creation_token), std::move(view_identity),
3436
std::move(view_protocols), std::move(parent_viewport_watcher_request));
3537

3638
root_transform_id_ = flatland_->NextTransformId();
3739
flatland_->flatland()->CreateTransform(root_transform_id_);
3840
flatland_->flatland()->SetRootTransform(root_transform_id_);
41+
42+
if (intercept_all_input_) {
43+
input_interceptor_node_ = flatland_->NextTransformId();
44+
flatland_->flatland()->CreateTransform(*input_interceptor_node_);
45+
child_transforms_.emplace_back(*input_interceptor_node_);
46+
}
3947
}
4048

4149
FlatlandExternalViewEmbedder::~FlatlandExternalViewEmbedder() = default;
@@ -336,6 +344,27 @@ void FlatlandExternalViewEmbedder::SubmitFrame(
336344
// Reset for the next pass:
337345
flatland_layer_index++;
338346
}
347+
348+
// TODO(fxbug.dev/104956): Setting hit regions for Flatland external view
349+
// embedder should match with what is being done in GFX external view
350+
// embedder.
351+
// Set up the input interceptor at the top of the scene, if applicable. It
352+
// will capture all input, and any unwanted input will be reinjected into
353+
// embedded views.
354+
if (intercept_all_input_) {
355+
FML_CHECK(input_interceptor_node_.has_value());
356+
flatland_->flatland()->AddChild(root_transform_id_,
357+
*input_interceptor_node_);
358+
359+
// Attach full-screen hit testing shield. Note that since the hit-region
360+
// may be transformed (translated, rotated), we do not want to set
361+
// width/height to FLT_MAX. This will cause a numeric overflow.
362+
flatland_->flatland()->SetHitRegions(
363+
*input_interceptor_node_,
364+
{{{0, 0, kMaxHitRegionSize, kMaxHitRegionSize},
365+
fuchsia::ui::composition::HitTestInteraction::
366+
SEMANTICALLY_INVISIBLE}});
367+
}
339368
}
340369

341370
// Present the session to Scenic, along with surface acquire/release fences.

shell/platform/fuchsia/flutter/flatland_external_view_embedder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ class FlatlandExternalViewEmbedder final
192192
SkISize frame_size_ = SkISize::Make(0, 0);
193193
float frame_dpr_ = 1.f;
194194

195+
// Set to true if input shield is enabled.
196+
const bool intercept_all_input_;
197+
198+
std::optional<fuchsia::ui::composition::TransformId> input_interceptor_node_;
199+
195200
FML_DISALLOW_COPY_AND_ASSIGN(FlatlandExternalViewEmbedder);
196201
};
197202

0 commit comments

Comments
 (0)