Change PointerController to display space
PointerController used to work in the logical display space, so
TouchInputMapper and CursorInputMapper would need to transform the
coordinates before interacting with it.
This CL makes PointerController work in the display space. It will
transform incoming and outgoing coordinates to stay in the display
space using the DisplayInfo provided by SurfaceFlinger. Using info
provided by SF also means that there will be better synchonization
between the pointers and display changes like rotation.
Bug: 188939842
Bug: 144544464
Test: manual: ensure mouse and touch spots work in different display
orientations and sizes set using "adb shell wm size"
Change-Id: Ic2e05f06c70f4aaf5c104af9c9723e48c545de05
Change-Id: I5e9e19c3678766985ca2193cfe045a11f812fa2b
diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h
index 97567ba..58bb014 100644
--- a/libs/input/PointerController.h
+++ b/libs/input/PointerController.h
@@ -72,6 +72,8 @@
void reloadPointerResources();
void onDisplayViewportsUpdated(std::vector<DisplayViewport>& viewports);
+ void onDisplayInfosChanged(const std::vector<gui::DisplayInfo>& displayInfos);
+
private:
friend PointerControllerContext::LooperCallback;
friend PointerControllerContext::MessageHandler;
@@ -85,9 +87,23 @@
struct Locked {
Presentation presentation;
+ std::vector<gui::DisplayInfo> mDisplayInfos;
std::unordered_map<int32_t /* displayId */, TouchSpotController> spotControllers;
} mLocked GUARDED_BY(mLock);
+ class DisplayInfoListener : public gui::WindowInfosListener {
+ public:
+ explicit DisplayInfoListener(PointerController& pc) : mPointerController(pc){};
+ void onWindowInfosChanged(const std::vector<android::gui::WindowInfo>&,
+ const std::vector<android::gui::DisplayInfo>&) override;
+
+ private:
+ PointerController& mPointerController;
+ };
+ sp<DisplayInfoListener> mDisplayInfoListener;
+
+ const ui::Transform& getTransformForDisplayLocked(int displayId) const REQUIRES(mLock);
+
PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper,
const sp<SpriteController>& spriteController);
void clearSpotsLocked();