Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5cb25783 authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceFlinger Input: Shrink frame by surfaceInsets.

Probably best explained by the comment in InputWindow.h. We can't
use touchable region because we need to shift the coordinate space.
As a follow-up I'm going to look in to shifting the coordinate space
on the client but it was very non obvious where to do so.

Test: Manual
Bug: 80101428
Bug: 113136004
Bug: 111440400
Change-Id: Ibbaffa89a80f3a047c716265251f547631bdf802
parent f759f163
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -117,16 +117,35 @@ struct InputWindowInfo {
        INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004,
    };
    
    /* These values are filled in by the WM and passed through SurfaceFlinger
     * unless specified otherwise.
     */
    sp<IBinder> token;
    std::string name;
    int32_t layoutParamsFlags;
    int32_t layoutParamsType;
    nsecs_t dispatchingTimeout;

    /* These values are filled in by SurfaceFlinger. */
    int32_t frameLeft;
    int32_t frameTop;
    int32_t frameRight;
    int32_t frameBottom;

    /*
     * SurfaceFlinger consumes this value to shrink the computed frame. This is
     * different from shrinking the touchable region in that it DOES shift the coordinate
     * space where-as the touchable region does not and is more like "cropping". This
     * is used for window shadows.
     */
    int32_t surfaceInset = 0;

    float scaleFactor;

    /*
     * This is filled in by the WM relative to the frame and then translated
     * to absolute coordinates by SurfaceFlinger once the frame is computed.
     */
    Region touchableRegion;
    bool visible;
    bool canReceiveKeys;
+2 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ status_t InputWindowInfo::write(Parcel& output) const {
    output.writeInt32(frameTop);
    output.writeInt32(frameRight);
    output.writeInt32(frameBottom);
    output.writeInt32(surfaceInset);
    output.writeFloat(scaleFactor);
    output.writeBool(visible);
    output.writeBool(canReceiveKeys);
@@ -119,6 +120,7 @@ InputWindowInfo InputWindowInfo::read(const Parcel& from) {
    ret.frameTop = from.readInt32();
    ret.frameRight = from.readInt32();
    ret.frameBottom = from.readInt32();
    ret.surfaceInset = from.readInt32();
    ret.scaleFactor = from.readFloat();
    ret.visible = from.readBool();
    ret.canReceiveKeys = from.readBool();
+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ TEST(InputWindowInfo, Parcelling) {
    i.frameTop = 34;
    i.frameRight = 16;
    i.frameBottom = 19;
    i.surfaceInset = 17;
    i.scaleFactor = 0.3;
    i.visible = false;
    i.canReceiveKeys = false;
@@ -73,6 +74,7 @@ TEST(InputWindowInfo, Parcelling) {
    ASSERT_EQ(i.frameTop, i2.frameTop);
    ASSERT_EQ(i.frameRight, i2.frameRight);
    ASSERT_EQ(i.frameBottom, i2.frameBottom);
    ASSERT_EQ(i.surfaceInset, i2.surfaceInset);
    ASSERT_EQ(i.scaleFactor, i2.scaleFactor);
    ASSERT_EQ(i.visible, i2.visible);
    ASSERT_EQ(i.canReceiveKeys, i2.canReceiveKeys);
+5 −5
Original line number Diff line number Diff line
@@ -2069,12 +2069,12 @@ bool Layer::isRemovedFromCurrentState() const {

InputWindowInfo Layer::fillInputInfo(const Rect& screenBounds) {
    InputWindowInfo info = mDrawingState.inputInfo;
    info.frameLeft = screenBounds.left;
    info.inputInfo.frameTop = screenBounds.top;
    info.inputInfo.frameRight = screenBounds.right;
    info.inputInfo.frameBottom = screenBounds.bottom;
    info.frameLeft = screenBounds.left + info.surfaceInset;
    info.frameTop = screenBounds.top + info.surfaceInset;
    info.frameRight = screenBounds.right - info.surfaceInset;
    info.frameBottom = screenBounds.bottom - info.surfaceInset;

    info.touchableRegion = mDrawingState.inputInfo.touchableRegion.translate(
    info.touchableRegion = info.touchableRegion.translate(
            screenBounds.left,
            screenBounds.top);
    info.visible = isVisible();