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

Commit 527905e1 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev
Browse files

Do not call IWindowSession.updatePointer icon from pointer handler

Currently if View.setPointerIcon is called from inside a pointer
event handler this will cause a redundant round-trip to the server
which can be easily avoided.

Bug: 27107871
Change-Id: Ia641818c3700c0d96d0c32e020b91af58dccfa2a
parent 79c11a8c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -21584,7 +21584,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public void setPointerIcon(PointerIcon pointerIcon) {
        mPointerIcon = pointerIcon;
        if (mAttachInfo == null) {
        if (mAttachInfo == null || mAttachInfo.mHandlingPointerEvent) {
            return;
        }
        try {
@@ -22636,6 +22636,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         */
        boolean mHighContrastText;
        /**
         * Set to true if a pointer event is currently being handled.
         */
        boolean mHandlingPointerEvent;
        /**
         * Global to the view hierarchy used as a temporary for dealing with
         * x/y points in the transparent region computations.
+18 −13
Original line number Diff line number Diff line
@@ -4311,6 +4311,24 @@ public final class ViewRootImpl implements ViewParent,
        private int processPointerEvent(QueuedInputEvent q) {
            final MotionEvent event = (MotionEvent)q.mEvent;

            mAttachInfo.mUnbufferedDispatchRequested = false;
            final View eventTarget =
                    (event.isFromSource(InputDevice.SOURCE_MOUSE) && mCapturingView != null) ?
                            mCapturingView : mView;
            mAttachInfo.mHandlingPointerEvent = true;
            boolean handled = eventTarget.dispatchPointerEvent(event);
            maybeUpdatePointerIcon(event);
            mAttachInfo.mHandlingPointerEvent = false;
            if (mAttachInfo.mUnbufferedDispatchRequested && !mUnbufferedInputDispatch) {
                mUnbufferedInputDispatch = true;
                if (mConsumeBatchedInputScheduled) {
                    scheduleConsumeBatchedInputImmediately();
                }
            }
            return handled ? FINISH_HANDLED : FORWARD;
        }

        private void maybeUpdatePointerIcon(MotionEvent event) {
            if (event.getPointerCount() == 1
                    && event.isFromSource(InputDevice.SOURCE_MOUSE)) {
                if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER
@@ -4327,19 +4345,6 @@ public final class ViewRootImpl implements ViewParent,
                    }
                }
            }

            mAttachInfo.mUnbufferedDispatchRequested = false;
            final View eventTarget =
                    (event.isFromSource(InputDevice.SOURCE_MOUSE) && mCapturingView != null) ?
                            mCapturingView : mView;
            boolean handled = eventTarget.dispatchPointerEvent(event);
            if (mAttachInfo.mUnbufferedDispatchRequested && !mUnbufferedInputDispatch) {
                mUnbufferedInputDispatch = true;
                if (mConsumeBatchedInputScheduled) {
                    scheduleConsumeBatchedInputImmediately();
                }
            }
            return handled ? FINISH_HANDLED : FORWARD;
        }

        private int processTrackballEvent(QueuedInputEvent q) {