Introduce WindowInfo::InputConfig flag to control input behavior
Instead of re-using layoutParams flags and layoutParam types and having
redundant information in WindowInfo, we add a new InputConfig flag that
the native input pipeline will use for all input window configurations.
This also reduces WindowInfo's size by converting booleans into flags.
Bug: 216806304
Test: atest libgui_test
Test: atest inputflinger_tests
Change-Id: If0354cc2cfc84986f7f0d48cd9348be1ff82293d
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index a039250..d290a76 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2161,8 +2161,8 @@
void Layer::fillInputFrameInfo(WindowInfo& info, const ui::Transform& screenToDisplay) {
Rect tmpBounds = getInputBounds();
if (!tmpBounds.isValid()) {
- info.flags = WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::NOT_FOCUSABLE;
- info.focusable = false;
+ info.inputConfig |=
+ WindowInfo::InputConfig::NOT_TOUCH_MODAL | WindowInfo::InputConfig::NOT_FOCUSABLE;
info.touchableRegion.clear();
// A layer could have invalid input bounds and still expect to receive touch input if it has
// replaceTouchableRegionWithCrop. For that case, the input transform needs to be calculated
@@ -2309,7 +2309,7 @@
mDrawingState.inputInfo.ownerUid = mOwnerUid;
mDrawingState.inputInfo.ownerPid = mOwnerPid;
mDrawingState.inputInfo.inputFeatures = WindowInfo::Feature::NO_INPUT_CHANNEL;
- mDrawingState.inputInfo.flags = WindowInfo::Flag::NOT_TOUCH_MODAL;
+ mDrawingState.inputInfo.inputConfig |= WindowInfo::InputConfig::NOT_TOUCH_MODAL;
mDrawingState.inputInfo.displayId = getLayerStack().id;
}
@@ -2327,7 +2327,9 @@
// We are just using these layers for occlusion detection in
// InputDispatcher, and obviously if they aren't visible they can't occlude
// anything.
- info.visible = hasInputInfo() ? canReceiveInput() : isVisible();
+ const bool visible = hasInputInfo() ? canReceiveInput() : isVisible();
+ info.setInputConfig(WindowInfo::InputConfig::NOT_VISIBLE, !visible);
+
info.alpha = getAlpha();
fillTouchOcclusionMode(info);
handleDropInputMode(info);
@@ -2349,8 +2351,9 @@
// Inherit the trusted state from the parent hierarchy, but don't clobber the trusted state
// if it was set by WM for a known system overlay
- info.trustedOverlay = info.trustedOverlay || isTrustedOverlay();
-
+ if (isTrustedOverlay()) {
+ info.inputConfig |= WindowInfo::InputConfig::TRUSTED_OVERLAY;
+ }
// If the layer is a clone, we need to crop the input region to cloned root to prevent
// touches from going outside the cloned area.
@@ -2482,7 +2485,7 @@
}
// Cloned layers shouldn't handle watch outside since their z order is not determined by
// WM or the client.
- mDrawingState.inputInfo.flags &= ~WindowInfo::Flag::WATCH_OUTSIDE_TOUCH;
+ mDrawingState.inputInfo.setInputConfig(WindowInfo::InputConfig::WATCH_OUTSIDE_TOUCH, false);
}
void Layer::updateClonedRelatives(const std::map<sp<Layer>, sp<Layer>>& clonedLayersMap) {
diff --git a/services/surfaceflinger/LayerProtoHelper.cpp b/services/surfaceflinger/LayerProtoHelper.cpp
index 015caa6..bc06b5c 100644
--- a/services/surfaceflinger/LayerProtoHelper.cpp
+++ b/services/surfaceflinger/LayerProtoHelper.cpp
@@ -175,12 +175,12 @@
}
InputWindowInfoProto* proto = getInputWindowInfoProto();
- proto->set_layout_params_flags(inputInfo.flags.get());
+ proto->set_layout_params_flags(inputInfo.layoutParamsFlags.get());
using U = std::underlying_type_t<WindowInfo::Type>;
// TODO(b/129481165): This static assert can be safely removed once conversion warnings
// are re-enabled.
static_assert(std::is_same_v<U, int32_t>);
- proto->set_layout_params_type(static_cast<U>(inputInfo.type));
+ proto->set_layout_params_type(static_cast<U>(inputInfo.layoutParamsType));
LayerProtoHelper::writeToProto({inputInfo.frameLeft, inputInfo.frameTop, inputInfo.frameRight,
inputInfo.frameBottom},
@@ -189,9 +189,10 @@
[&]() { return proto->mutable_touchable_region(); });
proto->set_surface_inset(inputInfo.surfaceInset);
- proto->set_visible(inputInfo.visible);
- proto->set_focusable(inputInfo.focusable);
- proto->set_has_wallpaper(inputInfo.hasWallpaper);
+ using InputConfig = gui::WindowInfo::InputConfig;
+ proto->set_visible(!inputInfo.inputConfig.test(InputConfig::NOT_VISIBLE));
+ proto->set_focusable(!inputInfo.inputConfig.test(InputConfig::NOT_FOCUSABLE));
+ proto->set_has_wallpaper(inputInfo.inputConfig.test(InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER));
proto->set_global_scale_factor(inputInfo.globalScaleFactor);
LayerProtoHelper::writeToProtoDeprecated(inputInfo.transform, proto->mutable_transform());
diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
index a91698f..c736d05 100644
--- a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
+++ b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
@@ -183,13 +183,16 @@
if (layer.windowInfoHandle) {
const gui::WindowInfo* inputInfo = layer.windowInfoHandle->getInfo();
proto::LayerState_WindowInfo* windowInfoProto = proto.mutable_window_info_handle();
- windowInfoProto->set_layout_params_flags(inputInfo->flags.get());
- windowInfoProto->set_layout_params_type(static_cast<int32_t>(inputInfo->type));
+ windowInfoProto->set_layout_params_flags(inputInfo->layoutParamsFlags.get());
+ windowInfoProto->set_layout_params_type(
+ static_cast<int32_t>(inputInfo->layoutParamsType));
LayerProtoHelper::writeToProto(inputInfo->touchableRegion,
windowInfoProto->mutable_touchable_region());
windowInfoProto->set_surface_inset(inputInfo->surfaceInset);
- windowInfoProto->set_focusable(inputInfo->focusable);
- windowInfoProto->set_has_wallpaper(inputInfo->hasWallpaper);
+ windowInfoProto->set_focusable(
+ !inputInfo->inputConfig.test(gui::WindowInfo::InputConfig::NOT_FOCUSABLE));
+ windowInfoProto->set_has_wallpaper(inputInfo->inputConfig.test(
+ gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER));
windowInfoProto->set_global_scale_factor(inputInfo->globalScaleFactor);
proto::LayerState_Transform* transformProto = windowInfoProto->mutable_transform();
transformProto->set_dsdx(inputInfo->transform.dsdx());
@@ -471,13 +474,17 @@
gui::WindowInfo inputInfo;
const proto::LayerState_WindowInfo& windowInfoProto = proto.window_info_handle();
- inputInfo.flags = static_cast<gui::WindowInfo::Flag>(windowInfoProto.layout_params_flags());
- inputInfo.type = static_cast<gui::WindowInfo::Type>(windowInfoProto.layout_params_type());
+ inputInfo.layoutParamsFlags =
+ static_cast<gui::WindowInfo::Flag>(windowInfoProto.layout_params_flags());
+ inputInfo.layoutParamsType =
+ static_cast<gui::WindowInfo::Type>(windowInfoProto.layout_params_type());
LayerProtoHelper::readFromProto(windowInfoProto.touchable_region(),
inputInfo.touchableRegion);
inputInfo.surfaceInset = windowInfoProto.surface_inset();
- inputInfo.focusable = windowInfoProto.focusable();
- inputInfo.hasWallpaper = windowInfoProto.has_wallpaper();
+ inputInfo.setInputConfig(gui::WindowInfo::InputConfig::NOT_FOCUSABLE,
+ !windowInfoProto.focusable());
+ inputInfo.setInputConfig(gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER,
+ windowInfoProto.has_wallpaper());
inputInfo.globalScaleFactor = windowInfoProto.global_scale_factor();
const proto::LayerState_Transform& transformProto = windowInfoProto.transform();
inputInfo.transform.set(transformProto.dsdx(), transformProto.dtdx(), transformProto.dtdy(),