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

Commit dfabcb1c authored by David Stevens's avatar David Stevens Committed by Android (Google) Code Review
Browse files

Merge "Handle focused tasks on multiple displays"

parents 33a119c9 ee9e2770
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2031,6 +2031,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
            return runTaskDragTaskTest(pw);
        } else if (op.equals("size-task-test")) {
            return runTaskSizeTaskTest(pw);
        } else if (op.equals("focus")) {
            return runTaskFocus(pw);
        } else {
            getErrPrintWriter().println("Error: unknown command '" + op + "'");
            return -1;
@@ -2322,6 +2324,13 @@ final class ActivityManagerShellCommand extends ShellCommand {
        return 0;
    }

    int runTaskFocus(PrintWriter pw) throws RemoteException {
        final int taskId = Integer.parseInt(getNextArgRequired());
        pw.println("Setting focus to task " + taskId);
        mInterface.setFocusedTask(taskId);
        return 0;
    }

    int runWrite(PrintWriter pw) {
        mInternal.enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
                "registerUidObserver()");
+19 −13
Original line number Diff line number Diff line
@@ -1072,6 +1072,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    }

    void setTouchExcludeRegion(Task focusedTask) {
        // The provided task is the task on this display with focus, so if WindowManagerService's
        // focused app is not on this display, focusedTask will be null.
        if (focusedTask == null) {
            mTouchExcludeRegion.setEmpty();
        } else {
            mTouchExcludeRegion.set(mBaseDisplayRect);
            final int delta = dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, mDisplayMetrics);
            mTmpRect2.setEmpty();
@@ -1086,6 +1091,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            if (!mTmpRect2.isEmpty()) {
                mTouchExcludeRegion.op(mTmpRect2, Region.Op.UNION);
            }
        }
        final WindowState inputMethod = mService.mInputMethodWindow;
        if (inputMethod != null && inputMethod.isVisibleLw()) {
            // If the input method is visible and the user is typing, we don't want these touch
+1 −1
Original line number Diff line number Diff line
@@ -784,7 +784,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        if (updateInputWindowsNeeded) {
            mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
        }
        mService.setFocusTaskRegionLocked();
        mService.setFocusTaskRegionLocked(null);

        // Check to see if we are now in a state where the screen should
        // be enabled, because the window obscured flags have changed.
+14 −8
Original line number Diff line number Diff line
@@ -2586,13 +2586,18 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    void setFocusTaskRegionLocked() {
    void setFocusTaskRegionLocked(AppWindowToken previousFocus) {
        final Task focusedTask = mFocusedApp != null ? mFocusedApp.mTask : null;
        if (focusedTask != null) {
            final DisplayContent displayContent = focusedTask.getDisplayContent();
            if (displayContent != null) {
                displayContent.setTouchExcludeRegion(focusedTask);
        final Task previousTask = previousFocus != null ? previousFocus.mTask : null;
        final DisplayContent focusedDisplayContent =
                focusedTask != null ? focusedTask.getDisplayContent() : null;
        final DisplayContent previousDisplayContent =
                previousTask != null ? previousTask.getDisplayContent() : null;
        if (previousDisplayContent != null && previousDisplayContent != focusedDisplayContent) {
            previousDisplayContent.setTouchExcludeRegion(null);
        }
        if (focusedDisplayContent != null) {
            focusedDisplayContent.setTouchExcludeRegion(focusedTask);
        }
    }

@@ -2618,9 +2623,10 @@ public class WindowManagerService extends IWindowManager.Stub

            final boolean changed = mFocusedApp != newFocus;
            if (changed) {
                AppWindowToken prev = mFocusedApp;
                mFocusedApp = newFocus;
                mInputMonitor.setFocusedAppLw(newFocus);
                setFocusTaskRegionLocked();
                setFocusTaskRegionLocked(prev);
            }

            if (moveFocusNow && changed) {
@@ -7456,7 +7462,7 @@ public class WindowManagerService extends IWindowManager.Stub
        synchronized (mWindowMap) {
            getDefaultDisplayContentLocked().getDockedDividerController()
                    .setTouchRegion(touchRegion);
            setFocusTaskRegionLocked();
            setFocusTaskRegionLocked(null);
        }
    }