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

Commit 476f053d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Integrate PointerIcon with Scribe" into udc-dev

parents d765772c 0cb1ad00
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -26,13 +26,17 @@ import android.annotation.NonNull;
import android.content.Context;
import android.os.IBinder;
import android.util.Slog;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.WindowManager;

import com.android.internal.policy.PhoneWindow;

import java.util.Objects;

/**
 * Window of type {@code LayoutParams.TYPE_INPUT_METHOD_DIALOG} for drawing
 * Handwriting Ink on screen.
@@ -185,4 +189,12 @@ final class InkWindow extends PhoneWindow {
        return getDecorView().getVisibility() == View.VISIBLE
                && mInkView != null && mInkView.isVisibleToUser();
    }

    void dispatchHandwritingEvent(@NonNull MotionEvent event) {
        final View decor = getDecorView();
        Objects.requireNonNull(decor);
        final ViewRootImpl viewRoot = decor.getViewRootImpl();
        Objects.requireNonNull(viewRoot);
        viewRoot.enqueueInputEvent(event);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -2563,7 +2563,7 @@ public class InputMethodService extends AbstractInputMethodService {
     */
    public void onStylusHandwritingMotionEvent(@NonNull MotionEvent motionEvent) {
        if (mInkWindow != null && mInkWindow.isInkViewVisible()) {
            mInkWindow.getDecorView().dispatchTouchEvent(motionEvent);
            mInkWindow.dispatchHandwritingEvent(motionEvent);
        } else {
            if (mPendingEvents == null) {
                mPendingEvents = new RingBuffer(MotionEvent.class, MAX_EVENTS_BUFFER);
@@ -2576,7 +2576,7 @@ public class InputMethodService extends AbstractInputMethodService {
                            if (mInkWindow == null) {
                                break;
                            }
                            mInkWindow.getDecorView().dispatchTouchEvent(event);
                            mInkWindow.dispatchHandwritingEvent(event);
                        }
                        mPendingEvents.clear();
                    }
+1 −1
Original line number Diff line number Diff line
@@ -9272,7 +9272,7 @@ public final class ViewRootImpl implements ViewParent,
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    void enqueueInputEvent(InputEvent event) {
    public void enqueueInputEvent(InputEvent event) {
        enqueueInputEvent(event, null, 0, false);
    }

+4 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.view.InputChannel;
import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.MotionEvent;
import android.view.PointerIcon;
import android.view.SurfaceControl;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -273,6 +274,9 @@ final class HandwritingModeController {
        }
        mHandwritingSurface.startIntercepting(imePid, imeUid);

        // Unset the pointer icon for the stylus in case the app had set it.
        InputManagerGlobal.getInstance().setPointerIconType(PointerIcon.TYPE_NOT_SPECIFIED);

        return new HandwritingSession(mCurrentRequestId, mHandwritingSurface.getInputChannel(),
                mHandwritingBuffer);
    }