Make input system aware of multiple displays.
The input system needs to know about the window that has
focus, even if it is on a secondary display. So now we
send it the list of all windows and indicate which display
they are on. We filter the list of windows as necessary
when delivering touch events.
To keep things simple, monitor input channels and input
filters are not supported except on the main display.
We also do not pass the display id to applications; it is
only used inside the input system for now.
Properly scale touch coordinates based on the viewport.
This will be needed to ensure that touch works on external
display as well as when the internal display is being used
to simulate a different resolution.
Change-Id: I1815579a52fcc852c519b5391fc7ab8767c2dc59
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index e345a5fb..e1a8dd8 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -62,11 +62,14 @@
int32_t physicalTop;
int32_t physicalRight;
int32_t physicalBottom;
+ int32_t deviceWidth;
+ int32_t deviceHeight;
DisplayViewport() :
- displayId(-1), orientation(DISPLAY_ORIENTATION_0),
+ displayId(ADISPLAY_ID_NONE), orientation(DISPLAY_ORIENTATION_0),
logicalLeft(0), logicalTop(0), logicalRight(0), logicalBottom(0),
- physicalLeft(0), physicalTop(0), physicalRight(0), physicalBottom(0) {
+ physicalLeft(0), physicalTop(0), physicalRight(0), physicalBottom(0),
+ deviceWidth(0), deviceHeight(0) {
}
bool operator==(const DisplayViewport& other) const {
@@ -79,12 +82,33 @@
&& physicalLeft == other.physicalLeft
&& physicalTop == other.physicalTop
&& physicalRight == other.physicalRight
- && physicalBottom == other.physicalBottom;
+ && physicalBottom == other.physicalBottom
+ && deviceWidth == other.deviceWidth
+ && deviceHeight == other.deviceHeight;
}
bool operator!=(const DisplayViewport& other) const {
return !(*this == other);
}
+
+ inline bool isValid() const {
+ return displayId >= 0;
+ }
+
+ void setNonDisplayViewport(int32_t width, int32_t height) {
+ displayId = ADISPLAY_ID_NONE;
+ orientation = DISPLAY_ORIENTATION_0;
+ logicalLeft = 0;
+ logicalTop = 0;
+ logicalRight = width;
+ logicalBottom = height;
+ physicalLeft = 0;
+ physicalTop = 0;
+ physicalRight = width;
+ physicalBottom = height;
+ deviceWidth = width;
+ deviceHeight = height;
+ }
};
/*
@@ -1297,18 +1321,30 @@
virtual void syncTouch(nsecs_t when, bool* outHavePointerIds) = 0;
private:
- // The surface orientation and width and height set by configureSurface().
- int32_t mSurfaceOrientation;
+ // The current viewport.
+ // The components of the viewport are specified in the display's rotated orientation.
+ DisplayViewport mViewport;
+
+ // The surface orientation, width and height set by configureSurface().
+ // The width and height are derived from the viewport but are specified
+ // in the natural orientation.
+ // The surface origin specifies how the surface coordinates should be translated
+ // to align with the logical display coordinate space.
+ // The orientation may be different from the viewport orientation as it specifies
+ // the rotation of the surface coordinates required to produce the viewport's
+ // requested orientation, so it will depend on whether the device is orientation aware.
int32_t mSurfaceWidth;
int32_t mSurfaceHeight;
-
- // The associated display viewport set by configureSurface().
- DisplayViewport mAssociatedDisplayViewport;
+ int32_t mSurfaceLeft;
+ int32_t mSurfaceTop;
+ int32_t mSurfaceOrientation;
// Translation and scaling factors, orientation-independent.
+ float mXTranslate;
float mXScale;
float mXPrecision;
+ float mYTranslate;
float mYScale;
float mYPrecision;
@@ -1369,8 +1405,6 @@
} mOrientedRanges;
// Oriented dimensions and precision.
- float mOrientedSurfaceWidth;
- float mOrientedSurfaceHeight;
float mOrientedXPrecision;
float mOrientedYPrecision;