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

Commit cd9c97db authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Adjust docked stack divider for orientation.

Bug: 24575031
Change-Id: Iabebaab386a5e4df3e9af36be329bc0384fd6c87
parent 44bc4daf
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.wm;

import static android.app.ActivityManager.DOCKED_STACK_ID;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
@@ -25,16 +26,15 @@ import static android.view.WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING
import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static com.android.server.wm.TaskStack.DOCKED_BOTTOM;
import static com.android.server.wm.TaskStack.DOCKED_INVALID;
import static com.android.server.wm.TaskStack.DOCKED_LEFT;
import static com.android.server.wm.TaskStack.DOCKED_RIGHT;
import static com.android.server.wm.TaskStack.DOCKED_TOP;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.RemoteException;
import android.util.Slog;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -58,7 +58,6 @@ public class DockedStackDividerController implements View.OnTouchListener {
    private Rect mOriginalRect = new Rect();
    private int mDockSide;


    DockedStackDividerController(Context context, DisplayContent displayContent) {
        mContext = context;
        mDisplayContent = displayContent;
@@ -66,13 +65,16 @@ public class DockedStackDividerController implements View.OnTouchListener {
                com.android.internal.R.dimen.docked_stack_divider_thickness);
    }

    private void addDivider() {
    private void addDivider(Configuration configuration) {
        View view = LayoutInflater.from(mContext).inflate(
                com.android.internal.R.layout.docked_stack_divider, null);
        view.setOnTouchListener(this);
        WindowManagerGlobal manager = WindowManagerGlobal.getInstance();
        final boolean landscape = configuration.orientation == ORIENTATION_LANDSCAPE;
        final int width = landscape ? mDividerWidth : MATCH_PARENT;
        final int height = landscape ? MATCH_PARENT : mDividerWidth;
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                mDividerWidth, MATCH_PARENT, TYPE_DOCK_DIVIDER,
                width, height, TYPE_DOCK_DIVIDER,
                FLAG_TOUCHABLE_WHEN_WAKING | FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL
                        | FLAG_WATCH_OUTSIDE_TOUCH | FLAG_SPLIT_TOUCH,
                PixelFormat.OPAQUE);
@@ -92,10 +94,13 @@ public class DockedStackDividerController implements View.OnTouchListener {
        return mView != null;
    }

    void update() {
    void update(Configuration configuration, boolean forceUpdate) {
        if (forceUpdate && mView != null) {
            removeDivider();
        }
        TaskStack stack = mDisplayContent.getDockedStackLocked();
        if (stack != null && mView == null) {
            addDivider();
            addDivider(configuration);
        } else if (stack == null && mView != null) {
            removeDivider();
        }
+25 −1
Original line number Diff line number Diff line
@@ -3420,12 +3420,20 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        synchronized(mWindowMap) {
            final boolean orientationChanged = mCurConfiguration.orientation != config.orientation;
            mCurConfiguration = new Configuration(config);
            if (mWaitingForConfig) {
                mWaitingForConfig = false;
                mLastFinishedFreezeSource = "new-config";
            }
            mWindowPlacerLocked.performSurfacePlacement();
            if (orientationChanged) {
                for (int i = mDisplayContents.size() - 1; i >= 0; i--) {
                    DisplayContent content = mDisplayContents.valueAt(i);
                    Message.obtain(mH, H.UPDATE_DOCKED_STACK_DIVIDER, H.DOCK_DIVIDER_FORCE_UPDATE,
                            H.UNUSED, content).sendToTarget();
                }
            }
        }
    }

@@ -7165,6 +7173,21 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int RESIZE_STACK = 43;
        public static final int RESIZE_TASK = 44;

        /**
         * Used to indicate in the message that the dock divider needs to be updated only if it's
         * necessary.
         */
        static final int DOCK_DIVIDER_NO_FORCE_UPDATE = 0;
        /**
         * Used to indicate in the message that the dock divider should be force-removed before
         * updating, so new configuration can be applied.
         */
        static final int DOCK_DIVIDER_FORCE_UPDATE = 1;
        /**
         * Used to denote that an integer field in a message will not be used.
         */
        public static final int UNUSED = 0;

        @Override
        public void handleMessage(Message msg) {
            if (DEBUG_WINDOW_TRACE) {
@@ -7706,8 +7729,9 @@ public class WindowManagerService extends IWindowManager.Stub
                break;
                case UPDATE_DOCKED_STACK_DIVIDER: {
                    DisplayContent content = (DisplayContent) msg.obj;
                    final boolean forceUpdate = msg.arg1 == DOCK_DIVIDER_FORCE_UPDATE;
                    synchronized (mWindowMap) {
                        content.mDividerControllerLocked.update();
                        content.mDividerControllerLocked.update(mCurConfiguration, forceUpdate);
                    }
                }
                break;
+2 −1
Original line number Diff line number Diff line
@@ -965,7 +965,8 @@ class WindowSurfacePlacer {
        }

        mService.mPolicy.finishLayoutLw();
        mService.mH.obtainMessage(UPDATE_DOCKED_STACK_DIVIDER, displayContent).sendToTarget();
        mService.mH.obtainMessage(UPDATE_DOCKED_STACK_DIVIDER,
                DOCK_DIVIDER_NO_FORCE_UPDATE, UNUSED, displayContent).sendToTarget();
    }

    /**