Merge "Integrate PointerIcon with Scribe" into udc-dev

This commit is contained in:
TreeHugger Robot
2023-04-04 21:33:29 +00:00
committed by Android (Google) Code Review
4 changed files with 19 additions and 3 deletions

View File

@@ -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);
}
}

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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);
}