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

Commit cbb9a5a

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 cbb9a5a

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

shell/platform/fuchsia/flutter/flatland_external_view_embedder.cc

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ 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));
@@ -336,6 +338,29 @@ void FlatlandExternalViewEmbedder::SubmitFrame(
336338
// Reset for the next pass:
337339
flatland_layer_index++;
338340
}
341+
342+
// TODO(fxbug.dev/104956): Setting hit regions for Flatland external view
343+
// embedder should match with what is being done in GFX external view
344+
// embedder.
345+
// Set up the input interceptor at the top of the scene, if applicable. It
346+
// will capture all input, and any unwanted input will be reinjected into
347+
// embedded views.
348+
if (intercept_all_input_) {
349+
fuchsia::ui::composition::TransformId input_interceptor_node =
350+
flatland_->NextTransformId();
351+
flatland_->flatland()->CreateTransform(input_interceptor_node);
352+
flatland_->flatland()->AddChild(root_transform_id_,
353+
input_interceptor_node);
354+
355+
// Attach full-screen hit testing shield. Note that since the hit-region
356+
// may be transformed (translated, rotated), we do not want to set
357+
// width/height to FLT_MAX. This will cause a numeric overflow.
358+
flatland_->flatland()->SetHitRegions(
359+
input_interceptor_node,
360+
{{{0, 0, kMaxHitRegionSize, kMaxHitRegionSize},
361+
fuchsia::ui::composition::HitTestInteraction::
362+
SEMANTICALLY_INVISIBLE}});
363+
}
339364
}
340365

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

shell/platform/fuchsia/flutter/flatland_external_view_embedder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ 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+
195198
FML_DISALLOW_COPY_AND_ASSIGN(FlatlandExternalViewEmbedder);
196199
};
197200

0 commit comments

Comments
 (0)