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

Commit e9aba46

Browse files
[fuchsia][scenic] Add input shield flag support in Flatland. (#36880)
This CL adds support for "intercept_all_input" flag in flutter_runner_config for flatland. Test: flutter-embedder-test
1 parent 40019b7 commit e9aba46

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

shell/platform/fuchsia/flutter/flatland_external_view_embedder.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ FlatlandExternalViewEmbedder::FlatlandExternalViewEmbedder(
3636
root_transform_id_ = flatland_->NextTransformId();
3737
flatland_->flatland()->CreateTransform(root_transform_id_);
3838
flatland_->flatland()->SetRootTransform(root_transform_id_);
39+
40+
if (intercept_all_input) {
41+
input_interceptor_transform_ = flatland_->NextTransformId();
42+
flatland_->flatland()->CreateTransform(*input_interceptor_transform_);
43+
44+
flatland_->flatland()->AddChild(root_transform_id_,
45+
*input_interceptor_transform_);
46+
child_transforms_.emplace_back(*input_interceptor_transform_);
47+
48+
// Attach full-screen hit testing shield. Note that since the hit-region
49+
// may be transformed (translated, rotated), we do not want to set
50+
// width/height to FLT_MAX. This will cause a numeric overflow.
51+
flatland_->flatland()->SetHitRegions(
52+
*input_interceptor_transform_,
53+
{{{0, 0, kMaxHitRegionSize, kMaxHitRegionSize},
54+
fuchsia::ui::composition::HitTestInteraction::
55+
SEMANTICALLY_INVISIBLE}});
56+
}
3957
}
4058

4159
FlatlandExternalViewEmbedder::~FlatlandExternalViewEmbedder() = default;
@@ -336,6 +354,18 @@ void FlatlandExternalViewEmbedder::SubmitFrame(
336354
// Reset for the next pass:
337355
flatland_layer_index++;
338356
}
357+
358+
// TODO(fxbug.dev/104956): Setting per-layer overlay hit region for Flatland
359+
// external view embedder should match with what is being done in GFX
360+
// external view embedder.
361+
// Set up the input interceptor at the top of the
362+
// scene, if applicable. It will capture all input, and any unwanted input
363+
// will be reinjected into embedded views.
364+
if (input_interceptor_transform_.has_value()) {
365+
flatland_->flatland()->AddChild(root_transform_id_,
366+
*input_interceptor_transform_);
367+
child_transforms_.emplace_back(*input_interceptor_transform_);
368+
}
339369
}
340370

341371
// 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+
// TransformId for the input interceptor node when input shield is turned on,
196+
// std::nullptr otherwise.
197+
std::optional<fuchsia::ui::composition::TransformId>
198+
input_interceptor_transform_;
199+
195200
FML_DISALLOW_COPY_AND_ASSIGN(FlatlandExternalViewEmbedder);
196201
};
197202

0 commit comments

Comments
 (0)