Fade out the mouse pointer after inactivity or other events.
Fades out the mouse pointer:
- after 15 seconds of inactivity normally
- after 3 seconds of inactivity in lights out mode
- after a non-modifier key down
- after a touch down
Extended the native Looper to support enqueuing time delayed
messages. This is used by the PointerController to control
pointer fade timing.
Change-Id: I87792fea7dbe2d9376c78cf354fe3189a484d9da
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index a865d9f..c3c143c 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -399,6 +399,17 @@
}
}
+void InputReader::fadePointer() {
+ { // acquire device registry reader lock
+ RWLock::AutoRLock _rl(mDeviceRegistryLock);
+
+ for (size_t i = 0; i < mDevices.size(); i++) {
+ InputDevice* device = mDevices.valueAt(i);
+ device->fadePointer();
+ }
+ } // release device registry reader lock
+}
+
void InputReader::getInputConfiguration(InputConfiguration* outConfiguration) {
{ // acquire state lock
AutoMutex _l(mStateLock);
@@ -695,6 +706,14 @@
return result;
}
+void InputDevice::fadePointer() {
+ size_t numMappers = mMappers.size();
+ for (size_t i = 0; i < numMappers; i++) {
+ InputMapper* mapper = mMappers[i];
+ mapper->fadePointer();
+ }
+}
+
// --- InputMapper ---
@@ -739,6 +758,9 @@
return 0;
}
+void InputMapper::fadePointer() {
+}
+
void InputMapper::dumpRawAbsoluteAxisInfo(String8& dump,
const RawAbsoluteAxisInfo& axis, const char* name) {
if (axis.valid) {
@@ -967,6 +989,10 @@
getContext()->updateGlobalMetaState();
}
+ if (down && !isMetaKey(keyCode)) {
+ getContext()->fadePointer();
+ }
+
if (policyFlags & POLICY_FLAG_FUNCTION) {
newMetaState |= AMETA_FUNCTION_ON;
}
@@ -1348,6 +1374,9 @@
} else {
hscroll = 0;
}
+ if (hscroll != 0 || vscroll != 0) {
+ mPointerController->unfade();
+ }
} // release lock
int32_t metaState = mContext->getGlobalMetaState();
@@ -1376,6 +1405,13 @@
}
}
+void CursorInputMapper::fadePointer() {
+ { // acquire lock
+ AutoMutex _l(mLock);
+ mPointerController->fade();
+ } // release lock
+}
+
// --- TouchInputMapper ---
@@ -2275,7 +2311,6 @@
uint32_t policyFlags = 0;
// Preprocess pointer data.
-
if (mParameters.useBadTouchFilter) {
if (applyBadTouchFilter()) {
havePointerIds = false;
@@ -2303,8 +2338,12 @@
savedTouch = & mCurrentTouch;
}
- // Process touches and virtual keys.
+ // Hide the pointer on an initial down.
+ if (mLastTouch.pointerCount == 0 && mCurrentTouch.pointerCount != 0) {
+ getContext()->fadePointer();
+ }
+ // Process touches and virtual keys.
TouchResult touchResult = consumeOffScreenTouches(when, policyFlags);
if (touchResult == DISPATCH_TOUCH) {
detectGestures(when);
@@ -2312,7 +2351,6 @@
}
// Copy current touch to last touch in preparation for the next cycle.
-
if (touchResult == DROP_STROKE) {
mLastTouch.clear();
} else {