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

Commit 8e89b31a authored by Chong Zhang's avatar Chong Zhang
Browse files

Move window moving and resizing handling to WindowManager

- add a startMoving API to initiate a window move from app, once
  the move starts WindowManager will take over the event handling.

- detect touch events along window's outside border and start
  a resize if necessary

Change-Id: Ic7e8baba34e0aa27a43173e044ffb46e93e219e0
parent 59876c3e
Loading
Loading
Loading
Loading
+0 −34
Original line number Original line Diff line number Diff line
@@ -2735,40 +2735,6 @@ public class Activity extends ContextThemeWrapper
        return ActivityManagerNative.getDefault().getActivityStackId(mToken);
        return ActivityManagerNative.getDefault().getActivityStackId(mToken);
    }
    }


    /**
     * Returns the bounds of the task that contains this activity.
     *
     * @return Rect The bounds that contains the activity.
     * @hide
     */
    @Override
    public Rect getActivityBounds() throws RemoteException {
        return ActivityManagerNative.getDefault().getActivityBounds(mToken);
    }

    /**
     * Sets the bounds (size and position) of the task or stack that contains this
     * activity.
     * NOTE: The requested bounds might not the fully honored by the system depending
     * on the window placement policy.
     *
     * @param newBounds The new target bounds of the activity in task or stack.
     * @hide
     */
    @Override
    public void setActivityBounds(Rect newBounds) throws RemoteException {
        ActivityManagerNative.getDefault().setActivityBounds(mToken, newBounds);
    }

    /**
     * Activates this activity, hence bringing it to the top and giving it focus.
     * Note: This will only work for activities which are located on the freeform desktop.
     * @hide
     */
    public void activateActivity() throws RemoteException {
        ActivityManagerNative.getDefault().activateActivity(mToken);
    }

    /**
    /**
     * Called to process key events.  You can override this to intercept all
     * Called to process key events.  You can override this to intercept all
     * key events before they are dispatched to the window.  Be sure to call
     * key events before they are dispatched to the window.  Be sure to call
+0 −67
Original line number Original line Diff line number Diff line
@@ -752,24 +752,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
            return true;
        }
        }


        case GET_ACTIVITY_BOUNDS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            Rect r = getActivityBounds(token);
            reply.writeNoException();
            r.writeToParcel(reply, 0);
            return true;
        }

        case SET_ACTIVITY_BOUNDS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            Rect r = Rect.CREATOR.createFromParcel(data);
            setActivityBounds(token, r);
            reply.writeNoException();
            return true;
        }

        case POSITION_TASK_IN_STACK_TRANSACTION: {
        case POSITION_TASK_IN_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
            int taskId = data.readInt();
@@ -827,14 +809,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
            return true;
        }
        }


        case ACTIVATE_ACTIVITY_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            activateActivity(token);
            reply.writeNoException();
            return true;
        }

        case SET_FOCUSED_TASK_TRANSACTION: {
        case SET_FOCUSED_TASK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
            int taskId = data.readInt();
@@ -3631,18 +3605,6 @@ class ActivityManagerProxy implements IActivityManager
        return focusedStackId;
        return focusedStackId;
    }
    }
    @Override
    @Override
    public void activateActivity(IBinder token) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(ACTIVATE_ACTIVITY_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
    @Override
    public void setFocusedTask(int taskId) throws RemoteException
    public void setFocusedTask(int taskId) throws RemoteException
    {
    {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
@@ -5940,35 +5902,6 @@ class ActivityManagerProxy implements IActivityManager
        return rect;
        return rect;
    }
    }


    @Override
    public void setActivityBounds(IBinder token, Rect r) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        r.writeToParcel(data, 0);
        mRemote.transact(SET_ACTIVITY_BOUNDS_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public Rect getActivityBounds(IBinder token) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(GET_ACTIVITY_BOUNDS_TRANSACTION, data, reply, 0);
        reply.readException();
        Rect rect = Rect.CREATOR.createFromParcel(reply);
        data.recycle();
        reply.recycle();
        return rect;
    }

    @Override
    @Override
    public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException {
    public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
+0 −6
Original line number Original line Diff line number Diff line
@@ -147,7 +147,6 @@ public interface IActivityManager extends IInterface {
    public boolean isInHomeStack(int taskId) throws RemoteException;
    public boolean isInHomeStack(int taskId) throws RemoteException;
    public void setFocusedStack(int stackId) throws RemoteException;
    public void setFocusedStack(int stackId) throws RemoteException;
    public int getFocusedStackId() throws RemoteException;
    public int getFocusedStackId() throws RemoteException;
    public void activateActivity(IBinder token) throws RemoteException;
    public void setFocusedTask(int taskId) throws RemoteException;
    public void setFocusedTask(int taskId) throws RemoteException;
    public void registerTaskStackListener(ITaskStackListener listener) throws RemoteException;
    public void registerTaskStackListener(ITaskStackListener listener) throws RemoteException;
    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
@@ -491,8 +490,6 @@ public interface IActivityManager extends IInterface {
            throws RemoteException;
            throws RemoteException;
    public void setTaskResizeable(int taskId, boolean resizeable) throws RemoteException;
    public void setTaskResizeable(int taskId, boolean resizeable) throws RemoteException;
    public void resizeTask(int taskId, Rect bounds) throws RemoteException;
    public void resizeTask(int taskId, Rect bounds) throws RemoteException;
    public void setActivityBounds(IBinder token, Rect bounds) throws RemoteException;
    public Rect getActivityBounds(IBinder token) throws RemoteException;


    public Rect getTaskBounds(int taskId) throws RemoteException;
    public Rect getTaskBounds(int taskId) throws RemoteException;
    public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException;
    public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException;
@@ -891,7 +888,4 @@ public interface IActivityManager extends IInterface {
    int GET_ACTIVITY_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 343;
    int GET_ACTIVITY_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 343;
    int MOVE_ACTIVITY_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
    int MOVE_ACTIVITY_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
    int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
    int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
    int GET_ACTIVITY_BOUNDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 346;
    int SET_ACTIVITY_BOUNDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 347;
    int ACTIVATE_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 348;
}
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -211,4 +211,12 @@ interface IWindowSession {
     * The assumption is that this method will be called rather infrequently.
     * The assumption is that this method will be called rather infrequently.
     */
     */
    void pokeDrawLock(IBinder window);
    void pokeDrawLock(IBinder window);

    /**
     * Starts a task window move with {startX, startY} as starting point. The amount of move
     * will be the offset between {startX, startY} and the new cursor position.
     *
     * Returns true if the move started successfully; false otherwise.
     */
    boolean startMovingTask(IWindow window, float startX, float startY);
}
}
+20 −0
Original line number Original line Diff line number Diff line
@@ -19749,6 +19749,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return okay;
        return okay;
    }
    }
    /**
     * Starts a move from {startX, startY}, the amount of the movement will be the offset
     * between {startX, startY} and the new cursor positon.
     * @param startX horizontal coordinate where the move started.
     * @param startY vertical coordinate where the move started.
     * @return whether moving was started successfully.
     * @hide
     */
    public final boolean startMovingTask(float startX, float startY) {
        if (ViewDebug.DEBUG_POSITIONING) {
            Log.d(VIEW_LOG_TAG, "startMovingTask: {" + startX + "," + startY + "}");
        }
        try {
            return mAttachInfo.mSession.startMovingTask(mAttachInfo.mWindow, startX, startY);
        } catch (RemoteException e) {
            Log.e(VIEW_LOG_TAG, "Unable to start moving", e);
        }
        return false;
    }
    /**
    /**
     * Handles drag events sent by the system following a call to
     * Handles drag events sent by the system following a call to
     * {@link android.view.View#startDrag(ClipData,DragShadowBuilder,Object,int) startDrag()}.
     * {@link android.view.View#startDrag(ClipData,DragShadowBuilder,Object,int) startDrag()}.
Loading