From 37c1b992d923106d79f4b299b2661a5fde0892cc Mon Sep 17 00:00:00 2001 From: Linnan Li Date: Fri, 24 Nov 2023 13:05:13 +0800 Subject: PointerController: Get initial DisplayInfos from SurfaceComposerClient After the PointerController is created, if SurfaceFlinger hasn't called back to notify DisplayInfo,the PointerController won't have DisplayInfo, if the actual display exists and transforms at this time, using the display touch position will result in the wrong actual display position. Steps to reproduce the problem. 1. Switch the device to landscape. 2. Execute `adb shell settings put system show_touch 1`. 3. Touch the screen. 4. At this point, you can observe that the screen flashes an incorrect touch point location. How to fix it The addWindowInfosListener method has a parameter to get the initial position, which we use to get the current DisplayInfo at creation time. Even though this information would not exist if there were no other listeners, it doesn't matter here because the InputDispatcher was created long before the PointerController, and the InputDispatcher already added a listener, so the DisplayInfo information must exist, so we don't have to worry about this. Bug: 313033164 Test: Manual Change-Id: Ia942c85d1b2204690f69e6a2ba43cfb7542af27c Signed-off-by: Linnan Li --- libs/input/PointerController.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libs/input/PointerController.h') diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h index a8b963367f4c..8daa3a33dea4 100644 --- a/libs/input/PointerController.h +++ b/libs/input/PointerController.h @@ -79,14 +79,17 @@ public: std::string dump() override; protected: - using WindowListenerConsumer = + using WindowListenerRegisterConsumer = + std::function, std::vector>( + const sp&)>; + using WindowListenerUnregisterConsumer = std::function&)>; // Constructor used to test WindowInfosListener registration. PointerController(const sp& policy, const sp& looper, SpriteController& spriteController, bool enabled, - WindowListenerConsumer registerListener, - WindowListenerConsumer unregisterListener); + const WindowListenerRegisterConsumer& registerListener, + WindowListenerUnregisterConsumer unregisterListener); PointerController(const sp& policy, const sp& looper, SpriteController& spriteController, bool enabled); @@ -129,7 +132,7 @@ private: }; sp mDisplayInfoListener; - const WindowListenerConsumer mUnregisterWindowInfosListener; + const WindowListenerUnregisterConsumer mUnregisterWindowInfosListener; const ui::Transform& getTransformForDisplayLocked(int displayId) const REQUIRES(getLock()); -- cgit v1.2.3-59-g8ed1b