summaryrefslogtreecommitdiffstats
path: root/services/input
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-05-09 19:00:59 -0700
committerDianne Hackborn <hackbod@google.com>2011-05-09 19:00:59 -0700
commitaa9d84c37e05f696ec158dac98ce38cf41e18314 (patch)
tree49a8e08d51840eec7ff20b624c59408f2f7523aa /services/input
parent28e77e616d8f005c8e07d6f28a83f8ca9772aedf (diff)
parent05be6d6fe09ddfb706d1bef3b20c3d37f45e3c8a (diff)
downloadframeworks_base-aa9d84c37e05f696ec158dac98ce38cf41e18314.zip
frameworks_base-aa9d84c37e05f696ec158dac98ce38cf41e18314.tar.gz
frameworks_base-aa9d84c37e05f696ec158dac98ce38cf41e18314.tar.bz2
resolved conflicts for merge of 05be6d6f to master
Change-Id: Ic6a6c5bb300f6f1d43f9ed550b284282b4f16212
Diffstat (limited to 'services/input')
-rw-r--r--services/input/InputDispatcher.cpp71
-rw-r--r--services/input/InputDispatcher.h7
-rw-r--r--services/input/InputWindow.cpp3
-rw-r--r--services/input/InputWindow.h6
4 files changed, 67 insertions, 20 deletions
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index 46de933..d97a9be 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -177,6 +177,14 @@ static bool validateMotionEvent(int32_t action, size_t pointerCount,
return true;
}
+static void scalePointerCoords(const PointerCoords* inCoords, size_t count, float scaleFactor,
+ PointerCoords* outCoords) {
+ for (size_t i = 0; i < count; i++) {
+ outCoords[i] = inCoords[i];
+ outCoords[i].scale(scaleFactor);
+ }
+}
+
static void dumpRegion(String8& dump, const SkRegion& region) {
if (region.isEmpty()) {
dump.append("<empty>");
@@ -1603,6 +1611,7 @@ void InputDispatcher::addWindowTargetLocked(const InputWindow* window, int32_t t
target.flags = targetFlags;
target.xOffset = - window->frameLeft;
target.yOffset = - window->frameTop;
+ target.scaleFactor = window->scaleFactor;
target.pointerIds = pointerIds;
}
@@ -1616,6 +1625,7 @@ void InputDispatcher::addMonitoringTargetsLocked() {
target.xOffset = 0;
target.yOffset = 0;
target.pointerIds.clear();
+ target.scaleFactor = 1.0f;
}
}
@@ -1717,12 +1727,12 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,
bool resumeWithAppendedMotionSample) {
#if DEBUG_DISPATCH_CYCLE
LOGD("channel '%s' ~ prepareDispatchCycle - flags=%d, "
- "xOffset=%f, yOffset=%f, "
+ "xOffset=%f, yOffset=%f, scaleFactor=%f"
"pointerIds=0x%x, "
"resumeWithAppendedMotionSample=%s",
connection->getInputChannelName(), inputTarget->flags,
inputTarget->xOffset, inputTarget->yOffset,
- inputTarget->pointerIds.value,
+ inputTarget->scaleFactor, inputTarget->pointerIds.value,
toString(resumeWithAppendedMotionSample));
#endif
@@ -1803,8 +1813,19 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,
// consumed the motion event (or if the channel is broken).
MotionEntry* motionEntry = static_cast<MotionEntry*>(eventEntry);
MotionSample* appendedMotionSample = motionEntry->lastSample;
- status_t status = connection->inputPublisher.appendMotionSample(
- appendedMotionSample->eventTime, appendedMotionSample->pointerCoords);
+ status_t status;
+ if (motionEventDispatchEntry->scaleFactor == 1.0f) {
+ status = connection->inputPublisher.appendMotionSample(
+ appendedMotionSample->eventTime, appendedMotionSample->pointerCoords);
+ } else {
+ PointerCoords scaledCoords[MAX_POINTERS];
+ for (size_t i = 0; i < motionEntry->pointerCount; i++) {
+ scaledCoords[i] = appendedMotionSample->pointerCoords[i];
+ scaledCoords[i].scale(motionEventDispatchEntry->scaleFactor);
+ }
+ status = connection->inputPublisher.appendMotionSample(
+ appendedMotionSample->eventTime, scaledCoords);
+ }
if (status == OK) {
#if DEBUG_BATCHING
LOGD("channel '%s' ~ Successfully streamed new motion sample.",
@@ -1867,7 +1888,8 @@ void InputDispatcher::enqueueDispatchEntryLocked(
// This is a new event.
// Enqueue a new dispatch entry onto the outbound queue for this connection.
DispatchEntry* dispatchEntry = mAllocator.obtainDispatchEntry(eventEntry, // increments ref
- inputTargetFlags, inputTarget->xOffset, inputTarget->yOffset);
+ inputTargetFlags, inputTarget->xOffset, inputTarget->yOffset,
+ inputTarget->scaleFactor);
if (dispatchEntry->hasForegroundTarget()) {
incrementPendingForegroundDispatchesLocked(eventEntry);
}
@@ -1961,14 +1983,26 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
firstMotionSample = & motionEntry->firstSample;
}
+ PointerCoords scaledCoords[MAX_POINTERS];
+ const PointerCoords* usingCoords = firstMotionSample->pointerCoords;
+
// Set the X and Y offset depending on the input source.
- float xOffset, yOffset;
+ float xOffset, yOffset, scaleFactor;
if (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER) {
- xOffset = dispatchEntry->xOffset;
- yOffset = dispatchEntry->yOffset;
+ scaleFactor = dispatchEntry->scaleFactor;
+ xOffset = dispatchEntry->xOffset * scaleFactor;
+ yOffset = dispatchEntry->yOffset * scaleFactor;
+ if (scaleFactor != 1.0f) {
+ for (size_t i = 0; i < motionEntry->pointerCount; i++) {
+ scaledCoords[i] = firstMotionSample->pointerCoords[i];
+ scaledCoords[i].scale(scaleFactor);
+ }
+ usingCoords = scaledCoords;
+ }
} else {
xOffset = 0.0f;
yOffset = 0.0f;
+ scaleFactor = 1.0f;
}
// Update the connection's input state.
@@ -1977,11 +2011,9 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
// Publish the motion event and the first motion sample.
status = connection->inputPublisher.publishMotionEvent(motionEntry->deviceId,
motionEntry->source, action, flags, motionEntry->edgeFlags, motionEntry->metaState,
- xOffset, yOffset,
- motionEntry->xPrecision, motionEntry->yPrecision,
+ xOffset, yOffset, motionEntry->xPrecision, motionEntry->yPrecision,
motionEntry->downTime, firstMotionSample->eventTime,
- motionEntry->pointerCount, motionEntry->pointerIds,
- firstMotionSample->pointerCoords);
+ motionEntry->pointerCount, motionEntry->pointerIds, usingCoords);
if (status) {
LOGE("channel '%s' ~ Could not publish motion event, "
@@ -1996,7 +2028,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
MotionSample* nextMotionSample = firstMotionSample->next;
for (; nextMotionSample != NULL; nextMotionSample = nextMotionSample->next) {
status = connection->inputPublisher.appendMotionSample(
- nextMotionSample->eventTime, nextMotionSample->pointerCoords);
+ nextMotionSample->eventTime, usingCoords);
if (status == NO_MEMORY) {
#if DEBUG_DISPATCH_CYCLE
LOGD("channel '%s' ~ Shared memory buffer full. Some motion samples will "
@@ -2234,18 +2266,21 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
}
int32_t xOffset, yOffset;
+ float scaleFactor;
const InputWindow* window = getWindowLocked(connection->inputChannel);
if (window) {
xOffset = -window->frameLeft;
yOffset = -window->frameTop;
+ scaleFactor = window->scaleFactor;
} else {
xOffset = 0;
yOffset = 0;
+ scaleFactor = 1.0f;
}
DispatchEntry* cancelationDispatchEntry =
mAllocator.obtainDispatchEntry(cancelationEventEntry, // increments ref
- 0, xOffset, yOffset);
+ 0, xOffset, yOffset, scaleFactor);
connection->outboundQueue.enqueueAtTail(cancelationDispatchEntry);
mAllocator.releaseEventEntry(cancelationEventEntry);
@@ -3244,7 +3279,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
const InputWindow& window = mWindows[i];
dump.appendFormat(INDENT2 "%d: name='%s', paused=%s, hasFocus=%s, hasWallpaper=%s, "
"visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, "
- "frame=[%d,%d][%d,%d], "
+ "frame=[%d,%d][%d,%d], scale=%f, "
"touchableRegion=",
i, window.name.string(),
toString(window.paused),
@@ -3255,7 +3290,8 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
window.layoutParamsFlags, window.layoutParamsType,
window.layer,
window.frameLeft, window.frameTop,
- window.frameRight, window.frameBottom);
+ window.frameRight, window.frameBottom,
+ window.scaleFactor);
dumpRegion(dump, window.touchableRegion);
dump.appendFormat(", ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
window.ownerPid, window.ownerUid,
@@ -3803,13 +3839,14 @@ InputDispatcher::MotionEntry* InputDispatcher::Allocator::obtainMotionEntry(nsec
InputDispatcher::DispatchEntry* InputDispatcher::Allocator::obtainDispatchEntry(
EventEntry* eventEntry,
- int32_t targetFlags, float xOffset, float yOffset) {
+ int32_t targetFlags, float xOffset, float yOffset, float scaleFactor) {
DispatchEntry* entry = mDispatchEntryPool.alloc();
entry->eventEntry = eventEntry;
eventEntry->refCount += 1;
entry->targetFlags = targetFlags;
entry->xOffset = xOffset;
entry->yOffset = yOffset;
+ entry->scaleFactor = scaleFactor;
entry->inProgress = false;
entry->headMotionSample = NULL;
entry->tailMotionSample = NULL;
diff --git a/services/input/InputDispatcher.h b/services/input/InputDispatcher.h
index af0153b..96ece32 100644
--- a/services/input/InputDispatcher.h
+++ b/services/input/InputDispatcher.h
@@ -132,6 +132,10 @@ struct InputTarget {
// (ignored for KeyEvents)
float xOffset, yOffset;
+ // Scaling factor to apply to MotionEvent as it is delivered.
+ // (ignored for KeyEvents)
+ float scaleFactor;
+
// The subset of pointer ids to include in motion events dispatched to this input target
// if FLAG_SPLIT is set.
BitSet32 pointerIds;
@@ -474,6 +478,7 @@ private:
int32_t targetFlags;
float xOffset;
float yOffset;
+ float scaleFactor;
// True if dispatch has started.
bool inProgress;
@@ -602,7 +607,7 @@ private:
nsecs_t downTime, uint32_t pointerCount,
const int32_t* pointerIds, const PointerCoords* pointerCoords);
DispatchEntry* obtainDispatchEntry(EventEntry* eventEntry,
- int32_t targetFlags, float xOffset, float yOffset);
+ int32_t targetFlags, float xOffset, float yOffset, float scaleFactor);
CommandEntry* obtainCommandEntry(Command command);
void releaseInjectionState(InjectionState* injectionState);
diff --git a/services/input/InputWindow.cpp b/services/input/InputWindow.cpp
index b552f6d..ccea9e4 100644
--- a/services/input/InputWindow.cpp
+++ b/services/input/InputWindow.cpp
@@ -29,8 +29,7 @@ bool InputWindow::touchableRegionContainsPoint(int32_t x, int32_t y) const {
}
bool InputWindow::frameContainsPoint(int32_t x, int32_t y) const {
- return x >= frameLeft && x <= frameRight
- && y >= frameTop && y <= frameBottom;
+ return x <= frameRight || y <= frameBottom;
}
bool InputWindow::isTrustedOverlay() const {
diff --git a/services/input/InputWindow.h b/services/input/InputWindow.h
index 208353d..cde7294 100644
--- a/services/input/InputWindow.h
+++ b/services/input/InputWindow.h
@@ -133,6 +133,7 @@ struct InputWindow {
int32_t frameTop;
int32_t frameRight;
int32_t frameBottom;
+ float scaleFactor;
SkRegion touchableRegion;
bool visible;
bool canReceiveKeys;
@@ -146,6 +147,11 @@ struct InputWindow {
bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
bool frameContainsPoint(int32_t x, int32_t y) const;
+ /* These use the globalScale to convert a given screen offset to the
+ * corresponding location within the window.
+ */
+ int32_t displayToWindowX(int32_t x) const;
+
/* Returns true if the window is of a trusted type that is allowed to silently
* overlay other windows for the purpose of implementing the secure views feature.
* Trusted overlays, such as IME windows, can partly obscure other windows without causing