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

Commit fa209a71 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Use rotated bounds as source touchable region for rotated app

The Layer in SF side will transform the given touchable region
according to the transformation matrix of surface. So if a window
is rotated, the raw touchable region should be the rotated bounds
instead of the bounds in display space. Then the raw region can
be rotated to the correct orientation. Otherwise the region is
like being rotated twice.

Bug: 175849666
Test: WindowStateTests#testUpdateInputWindowHandle
Change-Id: I266aaa21651c0bd5964e99d755382933d1336a9c
parent a0334be8
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -2624,6 +2624,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        // events can slip to activity from letterbox.
        mActivityRecord.getLetterboxInnerBounds(mTmpRect);
        if (mTmpRect.isEmpty()) {
            final Rect transformedBounds = mActivityRecord.getFixedRotationTransformDisplayBounds();
            if (transformedBounds != null) {
                // Task is in the same orientation as display, so the rotated bounds should be
                // chosen as the touchable region. Then when the surface layer transforms the
                // region to display space, the orientation will be consistent.
                mTmpRect.set(transformedBounds);
            } else {
                // If this is a modal window we need to dismiss it if it's not full screen
                // and the touch happens outside of the frame that displays the content. This
                // means we need to intercept touches outside of that window. The dim layer
@@ -2636,6 +2643,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    getRootTask().getDimBounds(mTmpRect);
                }
            }
        }
        adjustRegionInFreefromWindowMode(mTmpRect);
        outRegion.set(mTmpRect);
        cropRegionToStackBoundsIfNeeded(outRegion);
+6 −0
Original line number Diff line number Diff line
@@ -739,6 +739,12 @@ public class WindowStateTests extends WindowTestsBase {
        InputMonitor.setInputWindowInfoIfNeeded(transaction, sc, handleWrapper);
        verify(transaction, never()).setInputWindowInfo(any(), any());

        // The rotated bounds have higher priority as the touchable region.
        final Rect rotatedBounds = new Rect(0, 0, 123, 456);
        doReturn(rotatedBounds).when(win.mToken).getFixedRotationTransformDisplayBounds();
        mDisplayContent.getInputMonitor().populateInputWindowHandle(handleWrapper, win);
        assertEquals(rotatedBounds, handle.touchableRegion.getBounds());

        // Populate as an overlay to disable the input of window.
        InputMonitor.populateOverlayInputInfo(handleWrapper, false /* isVisible */);
        // The overlay attributes should be set.