Loading libs/gui/tests/EndToEndNativeInputTest.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -489,5 +489,13 @@ TEST_F(InputSurfacesTest, transfer_touch_focus) { toSurface->expectMotionEvent(AMOTION_EVENT_ACTION_UP, 1, 1); fromSurface->expectNoMotionEvent(AMOTION_EVENT_ACTION_UP); } TEST_F(InputSurfacesTest, input_respects_outscreen) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); surface->showAt(-1, -1); injectTap(0, 0); surface->expectTap(1, 1); } } } services/surfaceflinger/Layer.cpp +10 −12 Original line number Diff line number Diff line Loading @@ -2135,7 +2135,7 @@ bool Layer::isRemovedFromCurrentState() const { return mRemovedFromCurrentState; } InputWindowInfo Layer::fillInputInfo(const Rect& screenBounds) { InputWindowInfo Layer::fillInputInfo() { InputWindowInfo info = mDrawingState.inputInfo; ui::Transform t = getTransform(); Loading @@ -2148,20 +2148,18 @@ InputWindowInfo Layer::fillInputInfo(const Rect& screenBounds) { } // Transform layer size to screen space and inset it by surface insets. Rect layerBounds = getCroppedBufferSize(getDrawingState()); Rect layerBounds = getBufferSize(getDrawingState()); if (!layerBounds.isValid()) { layerBounds = getCroppedBufferSize(getDrawingState()); } layerBounds = t.transform(layerBounds); layerBounds.inset(info.surfaceInset, info.surfaceInset, info.surfaceInset, info.surfaceInset); // Intersect with screen bounds to shrink the frame by the surface insets. The surface insets // are not set on the screen bounds directly since the surface inset region may already be // cropped by a parent layer. Rect frame; screenBounds.intersect(layerBounds, &frame); info.frameLeft = frame.left; info.frameTop = frame.top; info.frameRight = frame.right; info.frameBottom = frame.bottom; // Input coordinate should match the layer bounds. info.frameLeft = layerBounds.left; info.frameTop = layerBounds.top; info.frameRight = layerBounds.right; info.frameBottom = layerBounds.bottom; // Position the touchable region relative to frame screen location and restrict it to frame // bounds. Loading services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -773,7 +773,7 @@ public: bool mPendingHWCDestroy{false}; void setInputInfo(const InputWindowInfo& info); InputWindowInfo fillInputInfo(const Rect& screenBounds); InputWindowInfo fillInputInfo(); bool hasInput() const; protected: Loading services/surfaceflinger/SurfaceFlinger.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -2944,8 +2944,7 @@ void SurfaceFlinger::updateInputWindows() { if (layer->hasInput()) { // When calculating the screen bounds we ignore the transparent region since it may // result in an unwanted offset. inputHandles.add(layer->fillInputInfo( layer->computeScreenBounds(false /* reduceTransparentRegion */))); inputHandles.add(layer->fillInputInfo()); } }); mInputFlinger->setInputWindows(inputHandles); Loading Loading
libs/gui/tests/EndToEndNativeInputTest.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -489,5 +489,13 @@ TEST_F(InputSurfacesTest, transfer_touch_focus) { toSurface->expectMotionEvent(AMOTION_EVENT_ACTION_UP, 1, 1); fromSurface->expectNoMotionEvent(AMOTION_EVENT_ACTION_UP); } TEST_F(InputSurfacesTest, input_respects_outscreen) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); surface->showAt(-1, -1); injectTap(0, 0); surface->expectTap(1, 1); } } }
services/surfaceflinger/Layer.cpp +10 −12 Original line number Diff line number Diff line Loading @@ -2135,7 +2135,7 @@ bool Layer::isRemovedFromCurrentState() const { return mRemovedFromCurrentState; } InputWindowInfo Layer::fillInputInfo(const Rect& screenBounds) { InputWindowInfo Layer::fillInputInfo() { InputWindowInfo info = mDrawingState.inputInfo; ui::Transform t = getTransform(); Loading @@ -2148,20 +2148,18 @@ InputWindowInfo Layer::fillInputInfo(const Rect& screenBounds) { } // Transform layer size to screen space and inset it by surface insets. Rect layerBounds = getCroppedBufferSize(getDrawingState()); Rect layerBounds = getBufferSize(getDrawingState()); if (!layerBounds.isValid()) { layerBounds = getCroppedBufferSize(getDrawingState()); } layerBounds = t.transform(layerBounds); layerBounds.inset(info.surfaceInset, info.surfaceInset, info.surfaceInset, info.surfaceInset); // Intersect with screen bounds to shrink the frame by the surface insets. The surface insets // are not set on the screen bounds directly since the surface inset region may already be // cropped by a parent layer. Rect frame; screenBounds.intersect(layerBounds, &frame); info.frameLeft = frame.left; info.frameTop = frame.top; info.frameRight = frame.right; info.frameBottom = frame.bottom; // Input coordinate should match the layer bounds. info.frameLeft = layerBounds.left; info.frameTop = layerBounds.top; info.frameRight = layerBounds.right; info.frameBottom = layerBounds.bottom; // Position the touchable region relative to frame screen location and restrict it to frame // bounds. Loading
services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -773,7 +773,7 @@ public: bool mPendingHWCDestroy{false}; void setInputInfo(const InputWindowInfo& info); InputWindowInfo fillInputInfo(const Rect& screenBounds); InputWindowInfo fillInputInfo(); bool hasInput() const; protected: Loading
services/surfaceflinger/SurfaceFlinger.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -2944,8 +2944,7 @@ void SurfaceFlinger::updateInputWindows() { if (layer->hasInput()) { // When calculating the screen bounds we ignore the transparent region since it may // result in an unwanted offset. inputHandles.add(layer->fillInputInfo( layer->computeScreenBounds(false /* reduceTransparentRegion */))); inputHandles.add(layer->fillInputInfo()); } }); mInputFlinger->setInputWindows(inputHandles); Loading