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