Skip to content

Commit 3c5dab4

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Make input system aware of multiple displays." into jb-mr1-dev
2 parents 2e7d0cb + 83d616a commit 3c5dab4

16 files changed

+352
-144
lines changed

include/androidfw/Input.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ enum {
4848
AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
4949
};
5050

51+
enum {
52+
/* Used when a motion event is not associated with any display.
53+
* Typically used for non-pointer events. */
54+
ADISPLAY_ID_NONE = -1,
55+
56+
/* The default display id. */
57+
ADISPLAY_ID_DEFAULT = 0,
58+
};
59+
5160
enum {
5261
/*
5362
* Indicates that an input device has switches.

services/input/InputDispatcher.cpp

Lines changed: 90 additions & 39 deletions
Large diffs are not rendered by default.

services/input/InputDispatcher.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,17 @@ class InputDispatcher : public InputDispatcherInterface {
511511
float xPrecision;
512512
float yPrecision;
513513
nsecs_t downTime;
514+
int32_t displayId;
514515
uint32_t pointerCount;
515516
PointerProperties pointerProperties[MAX_POINTERS];
516517
PointerCoords pointerCoords[MAX_POINTERS];
517518

518519
MotionEntry(nsecs_t eventTime,
519-
int32_t deviceId, uint32_t source, uint32_t policyFlags, int32_t action,
520-
int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags,
520+
int32_t deviceId, uint32_t source, uint32_t policyFlags,
521+
int32_t action, int32_t flags,
522+
int32_t metaState, int32_t buttonState, int32_t edgeFlags,
521523
float xPrecision, float yPrecision,
522-
nsecs_t downTime, uint32_t pointerCount,
524+
nsecs_t downTime, int32_t displayId, uint32_t pointerCount,
523525
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords);
524526
virtual void appendDescription(String8& msg) const;
525527

@@ -696,7 +698,7 @@ class InputDispatcher : public InputDispatcherInterface {
696698

697699
// Returns true if the specified source is known to have received a hover enter
698700
// motion event.
699-
bool isHovering(int32_t deviceId, uint32_t source) const;
701+
bool isHovering(int32_t deviceId, uint32_t source, int32_t displayId) const;
700702

701703
// Records tracking information for a key event that has just been published.
702704
// Returns true if the event should be delivered, false if it is inconsistent
@@ -752,6 +754,7 @@ class InputDispatcher : public InputDispatcherInterface {
752754
float xPrecision;
753755
float yPrecision;
754756
nsecs_t downTime;
757+
int32_t displayId;
755758
uint32_t pointerCount;
756759
PointerProperties pointerProperties[MAX_POINTERS];
757760
PointerCoords pointerCoords[MAX_POINTERS];
@@ -867,7 +870,7 @@ class InputDispatcher : public InputDispatcherInterface {
867870
// to transfer focus to a new application.
868871
EventEntry* mNextUnblockedEvent;
869872

870-
sp<InputWindowHandle> findTouchedWindowAtLocked(int32_t x, int32_t y);
873+
sp<InputWindowHandle> findTouchedWindowAtLocked(int32_t displayId, int32_t x, int32_t y);
871874

872875
// All registered connections mapped by channel file descriptor.
873876
KeyedVector<int, sp<Connection> > mConnectionsByFd;
@@ -899,6 +902,10 @@ class InputDispatcher : public InputDispatcherInterface {
899902
bool runCommandsLockedInterruptible();
900903
CommandEntry* postCommandLocked(Command command);
901904

905+
// Input filter processing.
906+
bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args);
907+
bool shouldSendMotionToInputFilterLocked(const NotifyMotionArgs* args);
908+
902909
// Inbound event processing.
903910
void drainInboundQueueLocked();
904911
void releasePendingEventLocked();
@@ -928,6 +935,7 @@ class InputDispatcher : public InputDispatcherInterface {
928935
bool split;
929936
int32_t deviceId; // id of the device that is currently down, others are rejected
930937
uint32_t source; // source of the device that is current down, others are rejected
938+
int32_t displayId; // id to the display that currently has a touch, others are rejected
931939
Vector<TouchedWindow> windows;
932940

933941
TouchState();

services/input/InputListener.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const {
6969
NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source,
7070
uint32_t policyFlags,
7171
int32_t action, int32_t flags, int32_t metaState, int32_t buttonState,
72-
int32_t edgeFlags, uint32_t pointerCount,
72+
int32_t edgeFlags, int32_t displayId, uint32_t pointerCount,
7373
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
7474
float xPrecision, float yPrecision, nsecs_t downTime) :
7575
eventTime(eventTime), deviceId(deviceId), source(source), policyFlags(policyFlags),
7676
action(action), flags(flags), metaState(metaState), buttonState(buttonState),
77-
edgeFlags(edgeFlags), pointerCount(pointerCount),
77+
edgeFlags(edgeFlags), displayId(displayId), pointerCount(pointerCount),
7878
xPrecision(xPrecision), yPrecision(yPrecision), downTime(downTime) {
7979
for (uint32_t i = 0; i < pointerCount; i++) {
8080
this->pointerProperties[i].copyFrom(pointerProperties[i]);
@@ -87,7 +87,8 @@ NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) :
8787
policyFlags(other.policyFlags),
8888
action(other.action), flags(other.flags),
8989
metaState(other.metaState), buttonState(other.buttonState),
90-
edgeFlags(other.edgeFlags), pointerCount(other.pointerCount),
90+
edgeFlags(other.edgeFlags), displayId(other.displayId),
91+
pointerCount(other.pointerCount),
9192
xPrecision(other.xPrecision), yPrecision(other.yPrecision), downTime(other.downTime) {
9293
for (uint32_t i = 0; i < pointerCount; i++) {
9394
pointerProperties[i].copyFrom(other.pointerProperties[i]);

services/input/InputListener.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct NotifyMotionArgs : public NotifyArgs {
8888
int32_t metaState;
8989
int32_t buttonState;
9090
int32_t edgeFlags;
91+
int32_t displayId;
9192
uint32_t pointerCount;
9293
PointerProperties pointerProperties[MAX_POINTERS];
9394
PointerCoords pointerCoords[MAX_POINTERS];
@@ -99,7 +100,7 @@ struct NotifyMotionArgs : public NotifyArgs {
99100

100101
NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags,
101102
int32_t action, int32_t flags, int32_t metaState, int32_t buttonState,
102-
int32_t edgeFlags, uint32_t pointerCount,
103+
int32_t edgeFlags, int32_t displayId, uint32_t pointerCount,
103104
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
104105
float xPrecision, float yPrecision, nsecs_t downTime);
105106

0 commit comments

Comments
 (0)