Loading core/java/android/inputmethodservice/InputMethodService.java +7 −4 Original line number Diff line number Diff line Loading @@ -255,7 +255,8 @@ public class InputMethodService extends AbstractInputMethodService { public static final int CURSOR_ANCHOR_MONITOR_MODE_NONE = 0x0; /** * The IME expects that {@link #onUpdateCursor(Rect)} is called back. * The IME will receive {@link #onUpdateCursor(Rect)} called back with the current * cursor rectangle in screen coordinates. */ public static final int CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT = 0x1; Loading Loading @@ -1703,9 +1704,11 @@ public class InputMethodService extends AbstractInputMethodService { } /** * Called when the application has reported a new location of its text * cursor. This is only called if explicitly requested by the input method. * The default implementation does nothing. * Called when the application has reported a new location of its text cursor. This is only * called if explicitly requested by the input method. The default implementation does nothing. * @param newCursor The new cursor position, in screen coordinates if the input method calls * {@link #setCursorAnchorMonitorMode} with {@link #CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT}. * Otherwise, this is in local coordinates. */ public void onUpdateCursor(Rect newCursor) { // Intentionally empty Loading core/java/android/view/inputmethod/InputMethodManager.java +25 −4 Original line number Diff line number Diff line Loading @@ -317,6 +317,10 @@ public final class InputMethodManager { int mCursorSelEnd; int mCursorCandStart; int mCursorCandEnd; /** * The buffer to retrieve the view location in screen coordinates in {@link #updateCursor}. */ private final int[] mViewTopLeft = new int[2]; // ----------------------------------------------------------- Loading Loading @@ -1487,9 +1491,23 @@ public final class InputMethodManager { return false; } synchronized (mH) { return mCursorAnchorMonitorMode == InputMethodService.CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT; return (mCursorAnchorMonitorMode & InputMethodService.CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT) != 0; } } /** * Returns true if the current input method wants to receive the cursor rectangle in * screen coordinates rather than local coordinates in the attached view. * * @hide */ public boolean usesScreenCoordinatesForCursorLocked() { // {@link InputMethodService#CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT} also means // that {@link InputMethodService#onUpdateCursor} should provide the cursor rectangle // in screen coordinates rather than local coordinates. return (mCursorAnchorMonitorMode & InputMethodService.CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT) != 0; } /** Loading Loading @@ -1518,15 +1536,18 @@ public final class InputMethodManager { || mCurrentTextBoxAttribute == null || mCurMethod == null) { return; } mTmpCursorRect.set(left, top, right, bottom); if (!mCursorRect.equals(mTmpCursorRect)) { if (DEBUG) Log.d(TAG, "updateCursor"); try { if (DEBUG) Log.v(TAG, "CURSOR CHANGE: " + mCurMethod); mCurMethod.updateCursor(mTmpCursorRect); mCursorRect.set(mTmpCursorRect); if (usesScreenCoordinatesForCursorLocked()) { view.getLocationOnScreen(mViewTopLeft); mTmpCursorRect.offset(mViewTopLeft[0], mViewTopLeft[1]); } mCurMethod.updateCursor(mTmpCursorRect); } catch (RemoteException e) { Log.w(TAG, "IME died: " + mCurId, e); } Loading Loading
core/java/android/inputmethodservice/InputMethodService.java +7 −4 Original line number Diff line number Diff line Loading @@ -255,7 +255,8 @@ public class InputMethodService extends AbstractInputMethodService { public static final int CURSOR_ANCHOR_MONITOR_MODE_NONE = 0x0; /** * The IME expects that {@link #onUpdateCursor(Rect)} is called back. * The IME will receive {@link #onUpdateCursor(Rect)} called back with the current * cursor rectangle in screen coordinates. */ public static final int CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT = 0x1; Loading Loading @@ -1703,9 +1704,11 @@ public class InputMethodService extends AbstractInputMethodService { } /** * Called when the application has reported a new location of its text * cursor. This is only called if explicitly requested by the input method. * The default implementation does nothing. * Called when the application has reported a new location of its text cursor. This is only * called if explicitly requested by the input method. The default implementation does nothing. * @param newCursor The new cursor position, in screen coordinates if the input method calls * {@link #setCursorAnchorMonitorMode} with {@link #CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT}. * Otherwise, this is in local coordinates. */ public void onUpdateCursor(Rect newCursor) { // Intentionally empty Loading
core/java/android/view/inputmethod/InputMethodManager.java +25 −4 Original line number Diff line number Diff line Loading @@ -317,6 +317,10 @@ public final class InputMethodManager { int mCursorSelEnd; int mCursorCandStart; int mCursorCandEnd; /** * The buffer to retrieve the view location in screen coordinates in {@link #updateCursor}. */ private final int[] mViewTopLeft = new int[2]; // ----------------------------------------------------------- Loading Loading @@ -1487,9 +1491,23 @@ public final class InputMethodManager { return false; } synchronized (mH) { return mCursorAnchorMonitorMode == InputMethodService.CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT; return (mCursorAnchorMonitorMode & InputMethodService.CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT) != 0; } } /** * Returns true if the current input method wants to receive the cursor rectangle in * screen coordinates rather than local coordinates in the attached view. * * @hide */ public boolean usesScreenCoordinatesForCursorLocked() { // {@link InputMethodService#CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT} also means // that {@link InputMethodService#onUpdateCursor} should provide the cursor rectangle // in screen coordinates rather than local coordinates. return (mCursorAnchorMonitorMode & InputMethodService.CURSOR_ANCHOR_MONITOR_MODE_CURSOR_RECT) != 0; } /** Loading Loading @@ -1518,15 +1536,18 @@ public final class InputMethodManager { || mCurrentTextBoxAttribute == null || mCurMethod == null) { return; } mTmpCursorRect.set(left, top, right, bottom); if (!mCursorRect.equals(mTmpCursorRect)) { if (DEBUG) Log.d(TAG, "updateCursor"); try { if (DEBUG) Log.v(TAG, "CURSOR CHANGE: " + mCurMethod); mCurMethod.updateCursor(mTmpCursorRect); mCursorRect.set(mTmpCursorRect); if (usesScreenCoordinatesForCursorLocked()) { view.getLocationOnScreen(mViewTopLeft); mTmpCursorRect.offset(mViewTopLeft[0], mViewTopLeft[1]); } mCurMethod.updateCursor(mTmpCursorRect); } catch (RemoteException e) { Log.w(TAG, "IME died: " + mCurId, e); } Loading