diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-09-07 10:44:57 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2010-09-08 12:28:43 -0700 |
commit | b21fb104cc95fe7e5daf3b3626241e525c39a3f1 (patch) | |
tree | 5223ab6cdc459955d35add9af46210c8c6249a48 | |
parent | de2f3340d64e20e51029ff438f0d635d97b8a3e0 (diff) | |
download | frameworks_base-b21fb104cc95fe7e5daf3b3626241e525c39a3f1.zip frameworks_base-b21fb104cc95fe7e5daf3b3626241e525c39a3f1.tar.gz frameworks_base-b21fb104cc95fe7e5daf3b3626241e525c39a3f1.tar.bz2 |
Fix key repeat delay.
Change-Id: I6216e082324ee29bf50e37acc673350ca5417c4d
-rw-r--r-- | include/ui/InputDispatcher.h | 5 | ||||
-rw-r--r-- | libs/ui/InputDispatcher.cpp | 9 | ||||
-rw-r--r-- | services/jni/com_android_server_InputManager.cpp | 5 |
3 files changed, 14 insertions, 5 deletions
diff --git a/include/ui/InputDispatcher.h b/include/ui/InputDispatcher.h index 711a658..f00f2db 100644 --- a/include/ui/InputDispatcher.h +++ b/include/ui/InputDispatcher.h @@ -147,9 +147,12 @@ public: /* Notifies the system that an input channel recovered from ANR. */ virtual void notifyInputChannelRecoveredFromANR(const sp<InputChannel>& inputChannel) = 0; - /* Gets the key repeat timeout or -1 if automatic key repeating is disabled. */ + /* Gets the key repeat initial timeout or -1 if automatic key repeating is disabled. */ virtual nsecs_t getKeyRepeatTimeout() = 0; + /* Gets the key repeat inter-key delay. */ + virtual nsecs_t getKeyRepeatDelay() = 0; + /* Waits for key event input targets to become available. * If the event is being injected, injectorPid and injectorUid should specify the * process id and used id of the injecting application, otherwise they should both diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp index e5b7f28..df232d4 100644 --- a/libs/ui/InputDispatcher.cpp +++ b/libs/ui/InputDispatcher.cpp @@ -97,6 +97,7 @@ InputDispatcher::~InputDispatcher() { void InputDispatcher::dispatchOnce() { nsecs_t keyRepeatTimeout = mPolicy->getKeyRepeatTimeout(); + nsecs_t keyRepeatDelay = mPolicy->getKeyRepeatDelay(); bool skipPoll = false; nsecs_t currentTime; @@ -146,7 +147,7 @@ void InputDispatcher::dispatchOnce() { if (mInboundQueue.isEmpty()) { if (mKeyRepeatState.lastKeyEntry) { if (currentTime >= mKeyRepeatState.nextRepeatTime) { - processKeyRepeatLockedInterruptible(currentTime, keyRepeatTimeout); + processKeyRepeatLockedInterruptible(currentTime, keyRepeatDelay); skipPoll = true; } else { if (mKeyRepeatState.nextRepeatTime < nextWakeupTime) { @@ -335,7 +336,7 @@ void InputDispatcher::processKeyLockedInterruptible( } void InputDispatcher::processKeyRepeatLockedInterruptible( - nsecs_t currentTime, nsecs_t keyRepeatTimeout) { + nsecs_t currentTime, nsecs_t keyRepeatDelay) { KeyEntry* entry = mKeyRepeatState.lastKeyEntry; // Search the inbound queue for a key up corresponding to this device. @@ -352,7 +353,7 @@ void InputDispatcher::processKeyRepeatLockedInterruptible( } } - // Synthesize a key repeat after the repeat timeout expired. + // Synthesize a key repeat. // Reuse the repeated key entry if it is otherwise unreferenced. uint32_t policyFlags = entry->policyFlags & POLICY_FLAG_RAW_MASK; if (entry->refCount == 1) { @@ -375,7 +376,7 @@ void InputDispatcher::processKeyRepeatLockedInterruptible( entry->flags |= AKEY_EVENT_FLAG_LONG_PRESS; } - mKeyRepeatState.nextRepeatTime = currentTime + keyRepeatTimeout; + mKeyRepeatState.nextRepeatTime = currentTime + keyRepeatDelay; #if DEBUG_OUTBOUND_EVENT_DETAILS LOGD("processKeyRepeat - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, " diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp index 4318681..7af5e95 100644 --- a/services/jni/com_android_server_InputManager.cpp +++ b/services/jni/com_android_server_InputManager.cpp @@ -275,6 +275,7 @@ public: nsecs_t& outNewTimeout); virtual void notifyInputChannelRecoveredFromANR(const sp<InputChannel>& inputChannel); virtual nsecs_t getKeyRepeatTimeout(); + virtual nsecs_t getKeyRepeatDelay(); virtual int32_t waitForKeyEventTargets(KeyEvent* keyEvent, uint32_t policyFlags, int32_t injectorPid, int32_t injectorUid, Vector<InputTarget>& outTargets); virtual int32_t waitForMotionEventTargets(MotionEvent* motionEvent, uint32_t policyFlags, @@ -1011,6 +1012,10 @@ nsecs_t NativeInputManager::getKeyRepeatTimeout() { } } +nsecs_t NativeInputManager::getKeyRepeatDelay() { + return milliseconds_to_nanoseconds(50); +} + int32_t NativeInputManager::getMaxEventsPerSecond() { if (mMaxEventsPerSecond < 0) { JNIEnv* env = jniEnv(); |