summaryrefslogtreecommitdiffstats
path: root/services/jni
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-06-14 20:22:50 -0700
committerJeff Brown <jeffbrown@google.com>2011-06-14 22:07:31 -0700
commit474dcb5c3ddff737c4ac9fc44a1f7be569605e5f (patch)
tree5fc1710768966b240ded5e6e62e51f77d7e57c55 /services/jni
parent93fa9b30b91f75ee161d0791ff17f98d1a603812 (diff)
downloadframeworks_base-474dcb5c3ddff737c4ac9fc44a1f7be569605e5f.zip
frameworks_base-474dcb5c3ddff737c4ac9fc44a1f7be569605e5f.tar.gz
frameworks_base-474dcb5c3ddff737c4ac9fc44a1f7be569605e5f.tar.bz2
Add support for disabling pointer gestures.
Made it possible for individual windows to disable pointer gestures while the window has focus using a private API. Cleaned up the InputReader configuration code to enable in-place reconfiguration of input devices without having to reopen them all. This change makes changing the pointer speed somewhat nicer since the pointer doesn't jump back to the origin after each change. Change-Id: I9727419c2f4cb39e16acb4b15fd7fd84526b1239
Diffstat (limited to 'services/jni')
-rw-r--r--services/jni/com_android_server_InputManager.cpp37
-rw-r--r--services/jni/com_android_server_InputWindow.cpp6
2 files changed, 39 insertions, 4 deletions
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 7c5084f..8a46ab0 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -234,6 +234,9 @@ private:
// Pointer speed.
int32_t pointerSpeed;
+ // True if pointer gestures are enabled.
+ bool pointerGesturesEnabled;
+
// Sprite controller singleton, created on first use.
sp<SpriteController> spriteController;
@@ -274,6 +277,7 @@ NativeInputManager::NativeInputManager(jobject contextObj,
mLocked.systemUiVisibility = ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE;
mLocked.pointerSpeed = 0;
+ mLocked.pointerGesturesEnabled = true;
}
sp<EventHub> eventHub = new EventHub();
@@ -443,6 +447,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
outConfig->pointerVelocityControlParameters.scale = exp2f(mLocked.pointerSpeed
* POINTER_SPEED_EXPONENT);
+ outConfig->pointerGesturesEnabled = mLocked.pointerGesturesEnabled;
} // release lock
}
@@ -594,6 +599,7 @@ bool NativeInputManager::isKeyRepeatEnabled() {
void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowObjArray) {
Vector<InputWindow> windows;
+ bool newPointerGesturesEnabled = true;
jsize length = env->GetArrayLength(windowObjArray);
for (jsize i = 0; i < length; i++) {
jobject windowObj = env->GetObjectArrayElement(windowObjArray, i);
@@ -606,11 +612,29 @@ void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowObjArra
android_server_InputWindow_toNative(env, windowObj, &window);
if (window.inputChannel == NULL) {
windows.pop();
+ } else if (window.hasFocus) {
+ if (window.inputFeatures & InputWindow::INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES) {
+ newPointerGesturesEnabled = false;
+ }
}
env->DeleteLocalRef(windowObj);
}
mInputManager->getDispatcher()->setInputWindows(windows);
+
+ uint32_t changes = 0;
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ if (mLocked.pointerGesturesEnabled != newPointerGesturesEnabled) {
+ mLocked.pointerGesturesEnabled = newPointerGesturesEnabled;
+ changes |= InputReaderConfiguration::CHANGE_POINTER_GESTURE_ENABLEMENT;
+ }
+ } // release lock
+
+ if (changes) {
+ mInputManager->getReader()->requestRefreshConfiguration(changes);
+ }
}
void NativeInputManager::setFocusedApplication(JNIEnv* env, jobject applicationObj) {
@@ -650,14 +674,19 @@ void NativeInputManager::updateInactivityTimeoutLocked(const sp<PointerControlle
}
void NativeInputManager::setPointerSpeed(int32_t speed) {
- AutoMutex _l(mLock);
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ if (mLocked.pointerSpeed == speed) {
+ return;
+ }
- if (mLocked.pointerSpeed != speed) {
LOGI("Setting pointer speed to %d.", speed);
mLocked.pointerSpeed = speed;
+ } // release lock
- mInputManager->getReader()->refreshConfiguration();
- }
+ mInputManager->getReader()->requestRefreshConfiguration(
+ InputReaderConfiguration::CHANGE_POINTER_SPEED);
}
bool NativeInputManager::isScreenOn() {
diff --git a/services/jni/com_android_server_InputWindow.cpp b/services/jni/com_android_server_InputWindow.cpp
index 012ce21..0426f63 100644
--- a/services/jni/com_android_server_InputWindow.cpp
+++ b/services/jni/com_android_server_InputWindow.cpp
@@ -48,6 +48,7 @@ static struct {
jfieldID layer;
jfieldID ownerPid;
jfieldID ownerUid;
+ jfieldID inputFeatures;
} gInputWindowClassInfo;
@@ -130,6 +131,8 @@ void android_server_InputWindow_toNative(
gInputWindowClassInfo.ownerPid);
outInputWindow->ownerUid = env->GetIntField(inputWindowObj,
gInputWindowClassInfo.ownerUid);
+ outInputWindow->inputFeatures = env->GetIntField(inputWindowObj,
+ gInputWindowClassInfo.inputFeatures);
}
@@ -206,6 +209,9 @@ int register_android_server_InputWindow(JNIEnv* env) {
GET_FIELD_ID(gInputWindowClassInfo.ownerUid, clazz,
"ownerUid", "I");
+
+ GET_FIELD_ID(gInputWindowClassInfo.inputFeatures, clazz,
+ "inputFeatures", "I");
return 0;
}