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

Commit 6f0b045d authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev
Browse files

Reset mouse pointer to default when moving away from the window edge

Bug: 28476151
Change-Id: I15bd2408fb3b7fc58fc9936318c0ec9eda504c22
parent 0f618300
Loading
Loading
Loading
Loading
+27 −36
Original line number Diff line number Diff line
@@ -18,16 +18,14 @@ package com.android.server.wm;

import android.graphics.Rect;
import android.graphics.Region;
import android.view.DisplayInfo;
import android.hardware.input.InputManager;
import android.view.GestureDetector;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.WindowManagerPolicy.PointerEventListener;

import com.android.server.wm.WindowManagerService.H;

import static android.view.PointerIcon.STYLE_NOT_SPECIFIED;
import static android.view.PointerIcon.STYLE_DEFAULT;
import static android.view.PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW;
import static android.view.PointerIcon.STYLE_VERTICAL_DOUBLE_ARROW;
import static android.view.PointerIcon.STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
@@ -89,14 +87,10 @@ public class TaskTapPointerEventListener implements PointerEventListener {
                final int x = (int) motionEvent.getX();
                final int y = (int) motionEvent.getY();
                final Task task = mDisplayContent.findTaskForControlPoint(x, y);
                InputDevice inputDevice = motionEvent.getDevice();
                if (task == null || inputDevice == null) {
                    mPointerIconShape = STYLE_NOT_SPECIFIED;
                    break;
                }
                int iconShape = STYLE_NOT_SPECIFIED;
                if (task != null) {
                    task.getDimBounds(mTmpRect);
                    if (!mTmpRect.isEmpty() && !mTmpRect.contains(x, y)) {
                    int iconShape = STYLE_DEFAULT;
                        if (x < mTmpRect.left) {
                            iconShape =
                                (y < mTmpRect.top) ? STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
@@ -110,22 +104,19 @@ public class TaskTapPointerEventListener implements PointerEventListener {
                        } else if (y < mTmpRect.top || y > mTmpRect.bottom) {
                            iconShape = STYLE_VERTICAL_DOUBLE_ARROW;
                        }
                    }
                }
                if (mPointerIconShape != iconShape) {
                    mPointerIconShape = iconShape;
                        inputDevice.setPointerShape(iconShape);
                    }
                    if (mPointerIconShape == STYLE_NOT_SPECIFIED) {
                        // Find the underlying window and ask it restore the pointer icon.
                        mService.mH.obtainMessage(H.RESTORE_POINTER_ICON,
                                x, y, mDisplayContent).sendToTarget();
                    } else {
                    mPointerIconShape = STYLE_NOT_SPECIFIED;
                        InputManager.getInstance().setPointerIconShape(mPointerIconShape);
                    }
            } break;

            case MotionEvent.ACTION_HOVER_EXIT:
                mPointerIconShape = STYLE_NOT_SPECIFIED;
                InputDevice inputDevice = motionEvent.getDevice();
                if (inputDevice != null) {
                    inputDevice.setPointerShape(STYLE_DEFAULT);
                }
                break;
            } break;

            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_POINTER_UP: {
+8 −0
Original line number Diff line number Diff line
@@ -7891,6 +7891,8 @@ public class WindowManagerService extends IWindowManager.Stub

        public static final int NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED = 53;

        public static final int RESTORE_POINTER_ICON = 54;

        /**
         * Used to denote that an integer field in a message will not be used.
         */
@@ -8520,6 +8522,12 @@ public class WindowManagerService extends IWindowManager.Stub
                    mAmInternal.notifyDockedStackMinimizedChanged(msg.arg1 == 1);
                }
                break;
                case RESTORE_POINTER_ICON: {
                    synchronized (mWindowMap) {
                        restorePointerIconLocked((DisplayContent)msg.obj, msg.arg1, msg.arg2);
                    }
                }
                break;
            }
            if (DEBUG_WINDOW_TRACE) {
                Slog.v(TAG_WM, "handleMessage: exit");