// Input device vibrator control.
void vibrate(int deviceId, in long[] pattern, int repeat, IBinder token);
void cancelVibrate(int deviceId, IBinder token);
+
+ void setPointerIconShape(int shapeId);
}
}
}
+ /**
+ * Changes the mouse pointer's icon shape into the specified id.
+ *
+ * @param iconId The id of the pointer graphic, as a value between
+ * {@link PointerIcon.STYLE_ARROW} and {@link PointerIcon.STYLE_GRABBING}.
+ *
+ * @hide
+ */
+ public void setPointerIconShape(int iconId) {
+ try {
+ mIm.setPointerIconShape(iconId);
+ } catch (RemoteException ex) {
+ // Do nothing.
+ }
+ }
+
private void populateInputDevicesLocked() {
if (mInputDevicesChangedListener == null) {
final InputDevicesChangedListener listener = new InputDevicesChangedListener();
}
/**
+ * Sets the current pointer shape.
+ * @param pointerShape the id of the pointer icon.
+ * @hide
+ */
+ public void setPointerShape(int pointerShape) {
+ InputManager.getInstance().setPointerIconShape(pointerShape);
+ }
+
+ /**
* Provides information about the range of values for a particular {@link MotionEvent} axis.
*
* @see InputDevice#getMotionRange(int)
/** Style constant: Null icon. It has no bitmap. */
public static final int STYLE_NULL = 0;
+ /** Style constant: no icons are specified. If all views uses this, then falls back
+ * to the default style, but this is helpful to distinguish a view explicitly want
+ * to have the default icon.
+ */
+ public static final int STYLE_NOT_SPECIFIED = 1;
+
/** Style constant: Arrow icon. (Default mouse pointer) */
public static final int STYLE_ARROW = 1000;
/** {@hide} Style constant: Spot anchor icon for touchpads. */
public static final int STYLE_SPOT_ANCHOR = 2002;
+ // Style constants for additional predefined icons for mice.
+ /** Style constant: context-menu. */
+ public static final int STYLE_CONTEXT_MENU = 1001;
+
+ /** Style constant: hand. */
+ public static final int STYLE_HAND = 1002;
+
+ /** Style constant: help. */
+ public static final int STYLE_HELP = 1003;
+
+ /** Style constant: wait. */
+ public static final int STYLE_WAIT = 1004;
+
+ /** Style constant: cell. */
+ public static final int STYLE_CELL = 1006;
+
+ /** Style constant: crosshair. */
+ public static final int STYLE_CROSSHAIR = 1007;
+
+ /** Style constant: text. */
+ public static final int STYLE_TEXT = 1008;
+
+ /** Style constant: vertical-text. */
+ public static final int STYLE_VERTICAL_TEXT = 1009;
+
+ /** Style constant: alias (indicating an alias of/shortcut to something is
+ * to be created. */
+ public static final int STYLE_ALIAS = 1010;
+
+ /** Style constant: copy. */
+ public static final int STYLE_COPY = 1011;
+
+ /** Style constant: no-drop. */
+ public static final int STYLE_NO_DROP = 1012;
+
+ /** Style constant: all-scroll. */
+ public static final int STYLE_ALL_SCROLL = 1013;
+
+ /** Style constant: horizontal double arrow mainly for resizing. */
+ public static final int STYLE_HORIZONTAL_DOUBLE_ARROW = 1014;
+
+ /** Style constant: vertical double arrow mainly for resizing. */
+ public static final int STYLE_VERTICAL_DOUBLE_ARROW = 1015;
+
+ /** Style constant: diagonal double arrow -- top-right to bottom-left. */
+ public static final int STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016;
+
+ /** Style constant: diagonal double arrow -- top-left to bottom-right. */
+ public static final int STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017;
+
+ /** Style constant: zoom-in. */
+ public static final int STYLE_ZOOM_IN = 1018;
+
+ /** Style constant: zoom-out. */
+ public static final int STYLE_ZOOM_OUT = 1019;
+
+ /** Style constant: grab. */
+ public static final int STYLE_GRAB = 1020;
+
+ /** Style constant: grabbing. */
+ public static final int STYLE_GRABBING = 1021;
+
// OEM private styles should be defined starting at this range to avoid
// conflicts with any system styles that may be defined in the future.
private static final int STYLE_OEM_FIRST = 10000;
- // The default pointer icon.
- private static final int STYLE_DEFAULT = STYLE_ARROW;
+ /** {@hide} The default pointer icon. */
+ public static final int STYLE_DEFAULT = STYLE_ARROW;
private static final PointerIcon gNullIcon = new PointerIcon(STYLE_NULL);
return com.android.internal.R.styleable.Pointer_pointerIconSpotTouch;
case STYLE_SPOT_ANCHOR:
return com.android.internal.R.styleable.Pointer_pointerIconSpotAnchor;
+ case STYLE_HAND:
+ return com.android.internal.R.styleable.Pointer_pointerIconHand;
+ case STYLE_CONTEXT_MENU:
+ return com.android.internal.R.styleable.Pointer_pointerIconContextMenu;
+ case STYLE_HELP:
+ return com.android.internal.R.styleable.Pointer_pointerIconHelp;
+ case STYLE_WAIT:
+ // falls back to the default icon because no animation support.
+ return com.android.internal.R.styleable.Pointer_pointerIconArrow;
+ case STYLE_CELL:
+ return com.android.internal.R.styleable.Pointer_pointerIconCell;
+ case STYLE_CROSSHAIR:
+ return com.android.internal.R.styleable.Pointer_pointerIconCrosshair;
+ case STYLE_TEXT:
+ return com.android.internal.R.styleable.Pointer_pointerIconText;
+ case STYLE_VERTICAL_TEXT:
+ return com.android.internal.R.styleable.Pointer_pointerIconVerticalText;
+ case STYLE_ALIAS:
+ return com.android.internal.R.styleable.Pointer_pointerIconAlias;
+ case STYLE_COPY:
+ return com.android.internal.R.styleable.Pointer_pointerIconCopy;
+ case STYLE_ALL_SCROLL:
+ return com.android.internal.R.styleable.Pointer_pointerIconAllScroll;
+ case STYLE_NO_DROP:
+ return com.android.internal.R.styleable.Pointer_pointerIconNodrop;
+ case STYLE_HORIZONTAL_DOUBLE_ARROW:
+ return com.android.internal.R.styleable.Pointer_pointerIconHorizontalDoubleArrow;
+ case STYLE_VERTICAL_DOUBLE_ARROW:
+ return com.android.internal.R.styleable.Pointer_pointerIconVerticalDoubleArrow;
+ case STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW:
+ return com.android.internal.R.styleable.
+ Pointer_pointerIconTopRightDiagonalDoubleArrow;
+ case STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW:
+ return com.android.internal.R.styleable.
+ Pointer_pointerIconTopLeftDiagonalDoubleArrow;
+ case STYLE_ZOOM_IN:
+ return com.android.internal.R.styleable.Pointer_pointerIconZoomIn;
+ case STYLE_ZOOM_OUT:
+ return com.android.internal.R.styleable.Pointer_pointerIconZoomOut;
+ case STYLE_GRAB:
+ return com.android.internal.R.styleable.Pointer_pointerIconGrab;
+ case STYLE_GRABBING:
+ return com.android.internal.R.styleable.Pointer_pointerIconGrabbing;
default:
return 0;
}
}
}
+ /** @hide */
+ public int getPointerShape(MotionEvent event, float x, float y) {
+ return PointerIcon.STYLE_NOT_SPECIFIED;
+ }
+
//
// Properties
//
return false;
}
+ /** @hide */
+ @Override
+ public int getPointerShape(MotionEvent event, float x, float y) {
+ // Check what the child under the pointer says about the pointer.
+ final int childrenCount = mChildrenCount;
+ if (childrenCount != 0) {
+ final ArrayList<View> preorderedList = buildOrderedChildList();
+ final boolean customOrder = preorderedList == null
+ && isChildrenDrawingOrderEnabled();
+ final View[] children = mChildren;
+ for (int i = childrenCount - 1; i >= 0; i--) {
+ final int childIndex = customOrder ? getChildDrawingOrder(childrenCount, i) : i;
+ final View child = (preorderedList == null)
+ ? children[childIndex] : preorderedList.get(childIndex);
+ PointF point = getLocalPoint();
+ if (isTransformedTouchPointInView(x, y, child, point)) {
+ final int pointerShape = child.getPointerShape(event, point.x, point.y);
+ if (pointerShape != PointerIcon.STYLE_NOT_SPECIFIED) {
+ return pointerShape;
+ }
+ break;
+ }
+ }
+ }
+
+ // The pointer is not a child or the child has no preferences, returning the default
+ // implementation.
+ return super.getPointerShape(event, x, y);
+ }
+
/**
* {@inheritDoc}
*/
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
+import android.hardware.input.InputManager;
import android.media.AudioManager;
import android.os.Binder;
import android.os.Build;
private long mFpsPrevTime = -1;
private int mFpsNumFrames;
+ private int mPointerIconShape = PointerIcon.STYLE_NOT_SPECIFIED;
+
/**
* see {@link #playSoundEffect(int)}
*/
private int processPointerEvent(QueuedInputEvent q) {
final MotionEvent event = (MotionEvent)q.mEvent;
+ if (event.getPointerCount() == 1
+ && event.isFromSource(InputDevice.SOURCE_MOUSE)) {
+ if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER
+ || event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
+ // Other apps or the window manager may change the icon shape outside of
+ // this app, therefore the icon shape has to be reset on enter/exit event.
+ mPointerIconShape = PointerIcon.STYLE_NOT_SPECIFIED;
+ }
+
+ final float x = event.getX();
+ final float y = event.getY();
+ if (x >= 0 && x < mView.getWidth() && y >= 0 && y < mView.getHeight()) {
+ int pointerShape = mView.getPointerShape(event, x, y);
+ if (pointerShape == PointerIcon.STYLE_NOT_SPECIFIED) {
+ pointerShape = PointerIcon.STYLE_DEFAULT;
+ }
+
+ if (mPointerIconShape != pointerShape) {
+ mPointerIconShape = pointerShape;
+ event.getDevice().setPointerShape(pointerShape);
+ }
+ }
+ }
+
mAttachInfo.mUnbufferedDispatchRequested = false;
boolean handled = mView.dispatchPointerEvent(event);
if (mAttachInfo.mUnbufferedDispatchRequested && !mUnbufferedInputDispatch) {
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import android.view.PointerIcon;
import android.view.View;
import android.view.ViewParent;
import android.view.ViewStructure;
return mLayout != null ? mLayout.getHeight() : 0;
}
+ /**
+ * @hide
+ */
+ @Override
+ public int getPointerShape(MotionEvent event, float x, float y) {
+ if (isTextSelectable() || isTextEditable()) {
+ return PointerIcon.STYLE_TEXT;
+ }
+ return super.getPointerShape(event, x, y);
+ }
+
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
// Note: If the IME is in fullscreen mode and IMS#mExtractEditText is in text action mode,
POINTER_ICON_STYLE_CUSTOM = -1,
POINTER_ICON_STYLE_NULL = 0,
POINTER_ICON_STYLE_ARROW = 1000,
+ POINTER_ICON_STYLE_CONTEXT_MENU = 1001,
+ POINTER_ICON_STYLE_HAND = 1002,
+ POINTER_ICON_STYLE_HELP = 1003,
+ POINTER_ICON_STYLE_WAIT = 1004,
+ POINTER_ICON_STYLE_CELL = 1006,
+ POINTER_ICON_STYLE_CROSSHAIR = 1007,
+ POINTER_ICON_STYLE_TEXT = 1008,
+ POINTER_ICON_STYLE_VERTICAL_TEXT = 1009,
+ POINTER_ICON_STYLE_ALIAS = 1010,
+ POINTER_ICON_STYLE_COPY = 1011,
+ POINTER_ICON_STYLE_NO_DROP = 1012,
+ POINTER_ICON_STYLE_ALL_SCROLL = 1013,
+ POINTER_ICON_STYLE_HORIZONTAL_DOUBLE_ARROW = 1014,
+ POINTER_ICON_STYLE_VERTICAL_DOUBLE_ARROW = 1015,
+ POINTER_ICON_STYLE_TOP_RIGHT_DOUBLE_ARROW = 1016,
+ POINTER_ICON_STYLE_TOP_LEFT_DOUBLE_ARROW = 1017,
+ POINTER_ICON_STYLE_ZOOM_IN = 1018,
+ POINTER_ICON_STYLE_ZOOM_OUT = 1019,
+ POINTER_ICON_STYLE_GRAB = 1020,
+ POINTER_ICON_STYLE_GRABBING = 1021,
+
POINTER_ICON_STYLE_SPOT_HOVER = 2000,
POINTER_ICON_STYLE_SPOT_TOUCH = 2001,
POINTER_ICON_STYLE_SPOT_ANCHOR = 2002,
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_alias"
+ android:hotSpotX="8dp"
+ android:hotSpotY="6dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_all_scroll"
+ android:hotSpotX="11dp"
+ android:hotSpotY="11dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_cell"
+ android:hotSpotX="11dp"
+ android:hotSpotY="11dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_context_menu"
+ android:hotSpotX="4dp"
+ android:hotSpotY="4dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_copy"
+ android:hotSpotX="9dp"
+ android:hotSpotY="9dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_crosshair"
+ android:hotSpotX="12dp"
+ android:hotSpotY="12dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_grab"
+ android:hotSpotX="8dp"
+ android:hotSpotY="5dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_grabbing"
+ android:hotSpotX="9dp"
+ android:hotSpotY="9dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_hand"
+ android:hotSpotX="9dp"
+ android:hotSpotY="4dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_help"
+ android:hotSpotX="4dp"
+ android:hotSpotY="4dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_horizontal_double_arrow"
+ android:hotSpotX="11dp"
+ android:hotSpotY="12dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_nodrop"
+ android:hotSpotX="9dp"
+ android:hotSpotY="9dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_text"
+ android:hotSpotX="12dp"
+ android:hotSpotY="12dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_top_left_diagonal_double_arrow"
+ android:hotSpotX="11dp"
+ android:hotSpotY="11dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_top_right_diagonal_double_arrow"
+ android:hotSpotX="12dp"
+ android:hotSpotY="11dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_vertical_double_arrow"
+ android:hotSpotX="11dp"
+ android:hotSpotY="12dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_vertical_text"
+ android:hotSpotX="12dp"
+ android:hotSpotY="11dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_zoom_in"
+ android:hotSpotX="10dp"
+ android:hotSpotY="10dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<pointer-icon xmlns:android="http://schemas.android.com/apk/res/android"
+ android:bitmap="@drawable/pointer_zoom_out"
+ android:hotSpotX="10dp"
+ android:hotSpotY="10dp" />
<attr name="pointerIconSpotTouch" format="reference" />
<!-- Reference to a pointer icon drawable with STYLE_SPOT_ANCHOR -->
<attr name="pointerIconSpotAnchor" format="reference" />
+ <!-- Reference to a pointer drawable with STYLE_CONTEXT_MENU -->
+ <attr name="pointerIconContextMenu" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_HAND -->
+ <attr name="pointerIconHand" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_HELP -->
+ <attr name="pointerIconHelp" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_CELL -->
+ <attr name="pointerIconCell" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_CROSSHAIR -->
+ <attr name="pointerIconCrosshair" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_TEXT -->
+ <attr name="pointerIconText" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_VERTICAL_TEXT -->
+ <attr name="pointerIconVerticalText" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_ALIAS -->
+ <attr name="pointerIconAlias" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_COPY -->
+ <attr name="pointerIconCopy" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_NODROP -->
+ <attr name="pointerIconNodrop" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_ALL_SCROLL -->
+ <attr name="pointerIconAllScroll" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_HORIZONTAL_DOUBLE_ARROW -->
+ <attr name="pointerIconHorizontalDoubleArrow" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_VERTICAL_DOUBLE_ARROW -->
+ <attr name="pointerIconVerticalDoubleArrow" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW -->
+ <attr name="pointerIconTopRightDiagonalDoubleArrow" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW -->
+ <attr name="pointerIconTopLeftDiagonalDoubleArrow" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_ZOOM_IN -->
+ <attr name="pointerIconZoomIn" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_ZOOM_OUT -->
+ <attr name="pointerIconZoomOut" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_GRAB -->
+ <attr name="pointerIconGrab" format="reference"/>
+ <!-- Reference to a pointer drawable with STYLE_GRABBING -->
+ <attr name="pointerIconGrabbing" format="reference"/>
</declare-styleable>
<declare-styleable name="PointerIcon">
<item name="pointerIconSpotHover">@drawable/pointer_spot_hover_icon</item>
<item name="pointerIconSpotTouch">@drawable/pointer_spot_touch_icon</item>
<item name="pointerIconSpotAnchor">@drawable/pointer_spot_anchor_icon</item>
+ <item name="pointerIconHand">@drawable/pointer_hand_icon</item>
+ <item name="pointerIconContextMenu">@drawable/pointer_context_menu_icon</item>
+ <item name="pointerIconHelp">@drawable/pointer_help_icon</item>
+ <item name="pointerIconCell">@drawable/pointer_cell_icon</item>
+ <item name="pointerIconCrosshair">@drawable/pointer_crosshair_icon</item>
+ <item name="pointerIconText">@drawable/pointer_text_icon</item>
+ <item name="pointerIconVerticalText">@drawable/pointer_vertical_text_icon</item>
+ <item name="pointerIconAlias">@drawable/pointer_alias_icon</item>
+ <item name="pointerIconCopy">@drawable/pointer_copy_icon</item>
+ <item name="pointerIconAllScroll">@drawable/pointer_all_scroll_icon</item>
+ <item name="pointerIconNodrop">@drawable/pointer_nodrop_icon</item>
+ <item name="pointerIconHorizontalDoubleArrow">
+ @drawable/pointer_horizontal_double_arrow_icon
+ </item>
+ <item name="pointerIconVerticalDoubleArrow">
+ @drawable/pointer_vertical_double_arrow_icon
+ </item>
+ <item name="pointerIconTopRightDiagonalDoubleArrow">
+ @drawable/pointer_top_right_diagonal_double_arrow_icon
+ </item>
+ <item name="pointerIconTopLeftDiagonalDoubleArrow">
+ @drawable/pointer_top_left_diagonal_double_arrow_icon
+ </item>
+ <item name="pointerIconZoomIn">@drawable/pointer_zoom_in_icon</item>
+ <item name="pointerIconZoomOut">@drawable/pointer_zoom_out_icon</item>
+ <item name="pointerIconGrab">@drawable/pointer_grab_icon</item>
+ <item name="pointerIconGrabbing">@drawable/pointer_grabbing_icon</item>
</style>
<!-- Wifi dialog styles -->
mLocked.pointerAlpha = 0.0f; // pointer is initially faded
mLocked.pointerSprite = mSpriteController->createSprite();
mLocked.pointerIconChanged = false;
+ mLocked.requestedPointerShape = 0;
mLocked.buttonState = 0;
void PointerController::setPresentation(Presentation presentation) {
AutoMutex _l(mLock);
+ if (presentation == PRESENTATION_POINTER && mLocked.additionalMouseResources.empty()) {
+ mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources);
+ }
+
if (mLocked.presentation != presentation) {
mLocked.presentation = presentation;
mLocked.presentationChanged = true;
updatePointerLocked();
}
+void PointerController::updatePointerShape(int iconId) {
+ AutoMutex _l(mLock);
+ if (mLocked.requestedPointerShape != iconId) {
+ mLocked.requestedPointerShape = iconId;
+ mLocked.presentationChanged = true;
+ updatePointerLocked();
+ }
+}
+
void PointerController::setPointerIcon(const SpriteIcon& icon) {
AutoMutex _l(mLock);
}
if (mLocked.pointerIconChanged || mLocked.presentationChanged) {
- mLocked.pointerSprite->setIcon(mLocked.presentation == PRESENTATION_POINTER
- ? mLocked.pointerIcon : mResources.spotAnchor);
+ if (mLocked.presentation == PRESENTATION_POINTER) {
+ if (mLocked.requestedPointerShape == 0) {
+ mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
+ } else {
+ std::map<int, SpriteIcon>::const_iterator iter =
+ mLocked.additionalMouseResources.find(mLocked.requestedPointerShape);
+ if (iter != mLocked.additionalMouseResources.end()) {
+ mLocked.pointerSprite->setIcon(iter->second);
+ } else {
+ ALOGW("Can't find the resource for icon id %d", mLocked.requestedPointerShape);
+ mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
+ }
+ }
+ } else {
+ mLocked.pointerSprite->setIcon(mResources.spotAnchor);
+ }
mLocked.pointerIconChanged = false;
mLocked.presentationChanged = false;
}
#include "SpriteController.h"
+#include <map>
+
#include <ui/DisplayInfo.h>
#include <input/Input.h>
#include <inputflinger/PointerControllerInterface.h>
SpriteIcon spotAnchor;
};
-
/*
* Pointer controller policy interface.
*
public:
virtual void loadPointerResources(PointerResources* outResources) = 0;
+ virtual void loadAdditionalMouseResources(std::map<int, SpriteIcon>* outResources) = 0;
};
const uint32_t* spotIdToIndex, BitSet32 spotIdBits);
virtual void clearSpots();
+ void updatePointerShape(int iconId);
void setDisplayViewport(int32_t width, int32_t height, int32_t orientation);
void setPointerIcon(const SpriteIcon& icon);
void setInactivityTimeout(InactivityTimeout inactivityTimeout);
SpriteIcon pointerIcon;
bool pointerIconChanged;
+ std::map<int, SpriteIcon> additionalMouseResources;
+
+ int32_t requestedPointerShape;
+
int32_t buttonState;
Vector<Spot*> spots;
private static native void nativeReloadDeviceAliases(long ptr);
private static native String nativeDump(long ptr);
private static native void nativeMonitor(long ptr);
+ private static native void nativeSetPointerIconShape(long ptr, int iconId);
// Input event injection constants defined in InputDispatcher.h.
private static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0;
}
}
+ // Binder call
+ @Override
+ public void setPointerIconShape(int iconId) {
+ nativeSetPointerIconShape(mPtr, iconId);
+ }
+
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP)
void setShowTouches(bool enabled);
void setInteractive(bool interactive);
void reloadCalibration();
+ void setPointerIconShape(int32_t iconId);
/* --- InputReaderPolicyInterface implementation --- */
/* --- PointerControllerPolicyInterface implementation --- */
virtual void loadPointerResources(PointerResources* outResources);
+ virtual void loadAdditionalMouseResources(std::map<int, SpriteIcon>* outResources);
private:
sp<InputManager> mInputManager;
InputReaderConfiguration::CHANGE_TOUCH_AFFINE_TRANSFORMATION);
}
+void NativeInputManager::setPointerIconShape(int32_t iconId) {
+ AutoMutex _l(mLock);
+ sp<PointerController> controller = mLocked.pointerController.promote();
+ if (controller != NULL) {
+ // Use 0 (the default icon) for ARROW.
+ controller->updatePointerShape((iconId == POINTER_ICON_STYLE_ARROW) ? 0 : iconId);
+ }
+}
+
TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
JNIEnv *env, jfloatArray matrixArr) {
ScopedFloatArrayRO matrix(env, matrixArr);
&outResources->spotAnchor);
}
+void NativeInputManager::loadAdditionalMouseResources(std::map<int, SpriteIcon>* outResources) {
+ JNIEnv* env = jniEnv();
+
+ for (int iconId = POINTER_ICON_STYLE_CONTEXT_MENU; iconId <= POINTER_ICON_STYLE_GRABBING;
+ ++iconId) {
+ loadSystemIconAsSprite(env, mContextObj, iconId, &((*outResources)[iconId]));
+ }
+}
+
// ----------------------------------------------------------------------------
im->getInputManager()->getDispatcher()->monitor();
}
+static void nativeSetPointerIconShape(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint iconId) {
+ NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
+ im->setPointerIconShape(iconId);
+}
+
// ----------------------------------------------------------------------------
static const JNINativeMethod gInputManagerMethods[] = {
(void*) nativeDump },
{ "nativeMonitor", "(J)V",
(void*) nativeMonitor },
+ { "nativeSetPointerIconShape", "(JI)V",
+ (void*) nativeSetPointerIconShape },
};
#define FIND_CLASS(var, className) \