Loading core/java/android/inputmethodservice/InkWindow.java +3 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,9 @@ final class InkWindow extends PhoneWindow { mGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mInkView == null) { return; } if (mInkView.isVisibleToUser()) { if (mInkViewVisibilityListener != null) { mInkViewVisibilityListener.onInkViewVisible(); Loading core/java/android/inputmethodservice/InputMethodService.java +18 −13 Original line number Diff line number Diff line Loading @@ -977,7 +977,7 @@ public class InputMethodService extends AbstractInputMethodService { Log.d(TAG, "Input should have started before starting Stylus handwriting."); return; } maybeCreateInkWindow(); maybeCreateAndInitInkWindow(); if (!mOnPreparedStylusHwCalled) { // prepare hasn't been called by Stylus HOVER. onPrepareStylusHandwriting(); Loading Loading @@ -1037,21 +1037,21 @@ public class InputMethodService extends AbstractInputMethodService { */ @Override public void initInkWindow() { maybeCreateInkWindow(); mInkWindow.initOnly(); maybeCreateAndInitInkWindow(); onPrepareStylusHandwriting(); mOnPreparedStylusHwCalled = true; } /** * Create and attach token to Ink window if it wasn't already created. * Create, attach token and layout Ink window if it wasn't already created. */ private void maybeCreateInkWindow() { private void maybeCreateAndInitInkWindow() { if (mInkWindow == null) { mInkWindow = new InkWindow(mWindow.getContext()); mInkWindow.setToken(mToken); } // TODO(b/243571274): set an idle-timeout after which InkWindow is removed. mInkWindow.initOnly(); } /** Loading Loading @@ -2487,16 +2487,20 @@ public class InputMethodService extends AbstractInputMethodService { * @param motionEvent {@link MotionEvent} from stylus. */ public void onStylusHandwritingMotionEvent(@NonNull MotionEvent motionEvent) { if (mInkWindow.isInkViewVisible()) { if (mInkWindow != null && mInkWindow.isInkViewVisible()) { mInkWindow.getDecorView().dispatchTouchEvent(motionEvent); } else { if (mPendingEvents == null) { mPendingEvents = new RingBuffer(MotionEvent.class, MAX_EVENTS_BUFFER); } mPendingEvents.append(motionEvent); if (mInkWindow != null) { mInkWindow.setInkViewVisibilityListener(() -> { if (mPendingEvents != null && !mPendingEvents.isEmpty()) { for (MotionEvent event : mPendingEvents.toArray()) { if (mInkWindow == null) { break; } mInkWindow.getDecorView().dispatchTouchEvent(event); } mPendingEvents.clear(); Loading @@ -2504,6 +2508,7 @@ public class InputMethodService extends AbstractInputMethodService { }); } } } /** * Called when the current stylus handwriting session was finished (either by the system or Loading Loading
core/java/android/inputmethodservice/InkWindow.java +3 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,9 @@ final class InkWindow extends PhoneWindow { mGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mInkView == null) { return; } if (mInkView.isVisibleToUser()) { if (mInkViewVisibilityListener != null) { mInkViewVisibilityListener.onInkViewVisible(); Loading
core/java/android/inputmethodservice/InputMethodService.java +18 −13 Original line number Diff line number Diff line Loading @@ -977,7 +977,7 @@ public class InputMethodService extends AbstractInputMethodService { Log.d(TAG, "Input should have started before starting Stylus handwriting."); return; } maybeCreateInkWindow(); maybeCreateAndInitInkWindow(); if (!mOnPreparedStylusHwCalled) { // prepare hasn't been called by Stylus HOVER. onPrepareStylusHandwriting(); Loading Loading @@ -1037,21 +1037,21 @@ public class InputMethodService extends AbstractInputMethodService { */ @Override public void initInkWindow() { maybeCreateInkWindow(); mInkWindow.initOnly(); maybeCreateAndInitInkWindow(); onPrepareStylusHandwriting(); mOnPreparedStylusHwCalled = true; } /** * Create and attach token to Ink window if it wasn't already created. * Create, attach token and layout Ink window if it wasn't already created. */ private void maybeCreateInkWindow() { private void maybeCreateAndInitInkWindow() { if (mInkWindow == null) { mInkWindow = new InkWindow(mWindow.getContext()); mInkWindow.setToken(mToken); } // TODO(b/243571274): set an idle-timeout after which InkWindow is removed. mInkWindow.initOnly(); } /** Loading Loading @@ -2487,16 +2487,20 @@ public class InputMethodService extends AbstractInputMethodService { * @param motionEvent {@link MotionEvent} from stylus. */ public void onStylusHandwritingMotionEvent(@NonNull MotionEvent motionEvent) { if (mInkWindow.isInkViewVisible()) { if (mInkWindow != null && mInkWindow.isInkViewVisible()) { mInkWindow.getDecorView().dispatchTouchEvent(motionEvent); } else { if (mPendingEvents == null) { mPendingEvents = new RingBuffer(MotionEvent.class, MAX_EVENTS_BUFFER); } mPendingEvents.append(motionEvent); if (mInkWindow != null) { mInkWindow.setInkViewVisibilityListener(() -> { if (mPendingEvents != null && !mPendingEvents.isEmpty()) { for (MotionEvent event : mPendingEvents.toArray()) { if (mInkWindow == null) { break; } mInkWindow.getDecorView().dispatchTouchEvent(event); } mPendingEvents.clear(); Loading @@ -2504,6 +2508,7 @@ public class InputMethodService extends AbstractInputMethodService { }); } } } /** * Called when the current stylus handwriting session was finished (either by the system or Loading