diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-03-02 14:41:58 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-03-02 15:37:57 -0800 |
commit | 05dc66ada6b61a6bdf806ffaa62617ac5394695d (patch) | |
tree | a7e395476241706de31498185a5c2ccb979bcb54 /services/input/InputReader.cpp | |
parent | e43111fad31ad8e36a66df52a8c6002799996413 (diff) | |
download | frameworks_base-05dc66ada6b61a6bdf806ffaa62617ac5394695d.zip frameworks_base-05dc66ada6b61a6bdf806ffaa62617ac5394695d.tar.gz frameworks_base-05dc66ada6b61a6bdf806ffaa62617ac5394695d.tar.bz2 |
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
Diffstat (limited to 'services/input/InputReader.cpp')
-rw-r--r-- | services/input/InputReader.cpp | 44 |
1 files changed, 41 insertions, 3 deletions
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 @@ bool InputReader::shouldDropVirtualKey(nsecs_t now, } } +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 @@ int32_t InputDevice::getMetaState() { 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 @@ int32_t InputMapper::getMetaState() { return 0; } +void InputMapper::fadePointer() { +} + void InputMapper::dumpRawAbsoluteAxisInfo(String8& dump, const RawAbsoluteAxisInfo& axis, const char* name) { if (axis.valid) { @@ -967,6 +989,10 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode, getContext()->updateGlobalMetaState(); } + if (down && !isMetaKey(keyCode)) { + getContext()->fadePointer(); + } + if (policyFlags & POLICY_FLAG_FUNCTION) { newMetaState |= AMETA_FUNCTION_ON; } @@ -1348,6 +1374,9 @@ void CursorInputMapper::sync(nsecs_t when) { } else { hscroll = 0; } + if (hscroll != 0 || vscroll != 0) { + mPointerController->unfade(); + } } // release lock int32_t metaState = mContext->getGlobalMetaState(); @@ -1376,6 +1405,13 @@ int32_t CursorInputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCod } } +void CursorInputMapper::fadePointer() { + { // acquire lock + AutoMutex _l(mLock); + mPointerController->fade(); + } // release lock +} + // --- TouchInputMapper --- @@ -2275,7 +2311,6 @@ void TouchInputMapper::syncTouch(nsecs_t when, bool havePointerIds) { uint32_t policyFlags = 0; // Preprocess pointer data. - if (mParameters.useBadTouchFilter) { if (applyBadTouchFilter()) { havePointerIds = false; @@ -2303,8 +2338,12 @@ void TouchInputMapper::syncTouch(nsecs_t when, bool havePointerIds) { 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 @@ void TouchInputMapper::syncTouch(nsecs_t when, bool havePointerIds) { } // Copy current touch to last touch in preparation for the next cycle. - if (touchResult == DROP_STROKE) { mLastTouch.clear(); } else { |