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

Commit f00c36c5 authored by /e/ robot's avatar /e/ robot
Browse files

Merge remote-tracking branch 'origin/lineage-17.1' into v1-q

parents 6bd3db04 0d4186c1
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -321,7 +321,11 @@ final class InputMonitor {
    }

    void updateInputWindowsImmediately() {
        if (mUpdateInputWindowsPending) {
        updateInputWindowsImmediately(false);
    }

    void updateInputWindowsImmediately(boolean ignorePending) {
        if (ignorePending || mUpdateInputWindowsPending) {
            mApplyImmediately = true;
            mUpdateInputWindows.run();
            mApplyImmediately = false;
+8 −2
Original line number Diff line number Diff line
@@ -308,7 +308,11 @@ class TaskPositioner implements IBinder.DeathRecipient {
        mDisplayContent.pauseRotationLocked();

        // Notify InputMonitor to take mDragWindowHandle.
        mDisplayContent.getInputMonitor().updateInputWindowsImmediately();
        // We must add mDragWindowHandle to InputManager immediately although
        // there is pending for updateInputWindows. Otherwise, the
        // InputManager.transferTouchFocus will fail because of not-found
        // mDragWindowHandle(to window).
        mDisplayContent.getInputMonitor().updateInputWindowsImmediately(true);
        new SurfaceControl.Transaction().syncInputWindows().apply();

        mSideMargin = dipToPixel(SIDE_MARGIN_DIP, mDisplayMetrics);
@@ -351,8 +355,10 @@ class TaskPositioner implements IBinder.DeathRecipient {
        }
        mDisplayContent.resumeRotationLocked();
        mDisplayContent = null;
        if (mClientCallback != null) {
            mClientCallback.unlinkToDeath(this, 0 /* flags */);
        }
    }

    void startDrag(WindowState win, boolean resize, boolean preserveOrientation, float startX,
                   float startY) {
+29 −7
Original line number Diff line number Diff line
@@ -123,13 +123,7 @@ public class TaskPositioningControllerTests extends WindowTestsBase {
            assertNull(mTarget.getDragWindowHandleLocked());
        }

        final DisplayContent content = mock(DisplayContent.class);
        when(content.findTaskForResizePoint(anyInt(), anyInt())).thenReturn(mWindow.getTask());
        assertNotNull(mWindow.getTask().getTopVisibleAppMainWindow());

        mTarget.handleTapOutsideTask(content, 0, 0);
        // Wait until the looper processes finishTaskPositioning.
        assertTrue(mWm.mH.runWithScissors(() -> { }, TIMEOUT_MS));
        triggerHandleTapOutsideTask();

        synchronized (mWm.mGlobalLock) {
            assertTrue(mTarget.isPositioningLocked());
@@ -143,4 +137,32 @@ public class TaskPositioningControllerTests extends WindowTestsBase {
        assertFalse(mTarget.isPositioningLocked());
        assertNull(mTarget.getDragWindowHandleLocked());
    }

    @Test
    public void testHandleTapOutsideTaskWithTransferTouchFocusFailed() {
        when(mWm.mInputManager.transferTouchFocus(
                any(InputChannel.class),
                any(InputChannel.class))).thenReturn(false);
        synchronized (mWm.mGlobalLock) {
            assertFalse(mTarget.isPositioningLocked());
            assertNull(mTarget.getDragWindowHandleLocked());
        }

        triggerHandleTapOutsideTask();

        synchronized (mWm.mGlobalLock) {
            assertFalse(mTarget.isPositioningLocked());
            assertNull(mTarget.getDragWindowHandleLocked());
        }
    }

    private void triggerHandleTapOutsideTask() {
        final DisplayContent content = mock(DisplayContent.class);
        when(content.findTaskForResizePoint(anyInt(), anyInt())).thenReturn(mWindow.getTask());
        assertNotNull(mWindow.getTask().getTopVisibleAppMainWindow());

        mTarget.handleTapOutsideTask(content, 0, 0);
        // Wait until the looper processes finishTaskPositioning.
        assertTrue(mWm.mH.runWithScissors(() -> { }, TIMEOUT_MS));
    }
}