summaryrefslogtreecommitdiff
path: root/libs/input/PointerController.h
AgeCommit message (Collapse)Author
2024-12-03Refactor to replace FloatPoint by vec2 Arpit Singh
Using FloatPoint requires unnecessory conversion between vec2 and FloatPoint, which is inefficient. This CL replaces FloatPoint by vec2 everywhere. Test: atest inputflinger_tests Bug: 245989146 Flag: EXEMPT refactor Change-Id: I0bf9cd35392bff424ec65bbaa43918176d31de37
2024-12-02Expose current viewport transform of PointerController Arpit Singh
This CL adds API to expose the current viewport transform of the PointerController. This will be used by Choreographer to find the target display and cursor position in the topology, when cursor moves across the displays. Test: presubmit Bug: 367660694 Flag: com.android.input.flags.connected_displays_cursor Change-Id: If4fe9fade2bf55f29db377661820ef7a8ca73ba2
2024-12-02Check if cursor has moved out of viewport bounds in CursorController Arpit Singh
This CL updates CursorController to check if and which boundary the cursor has crossed. This will be used to enable cursor moving between different connected displays. Test: atest inputflinger_tests Test: verify cursor can move between displays as expected Bug: 367660694 Flag: com.android.input.flags.connected_displays_cursor Change-Id: Ida11e897d4e6767549dcc40da5c83e4c6be178c9
2024-11-18Revert "Check if cursor has moved out of viewport bounds in Curs..." Liana Kazanova (xWF)
Revert submission 30111126-cd-cursor Reason for revert: DroidMonitor: Potential culprit for http://b/379706345 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Reverted changes: /q/submissionid:30111126-cd-cursor Change-Id: Ibff6c02be1359729802d4c85fa8dc0fdb4c75492
2024-11-18Check if cursor has moved out of viewport bounds in CursorController Arpit Singh
This CL updates CursorController to check if and which boundary the cursor has crossed. This will be used to enable cursor moving between different connected displays. Test: presubmit and manual Bug: 367660694 Flag: com.android.input.flags.connected_displays_cursor Change-Id: Ib559e0d72364f446269e73cfa1671ee9d2f715ac
2024-09-17Use integer coordinates as the cursor starting point on a display Prabir Pradhan
Ensure that the mouse cursor starts off with integer coordinates. Also, remove the unused getBounds method. Bug: 332973324 Test: atest PointerIconTest Test: Presubmit Flag: EXEMPT refactor Change-Id: Ieb26e443d047b016980001ec51002d3d40d00e91
2024-05-30Add method to set SkipScreenshot flag on cursorcontroller sprites Arpit Singh
Add a methods to be able to set ISurfaceComposerClient::eSkipScreenshot flag on MouseCursorController. This will be used to hide mouse and stylus pointers on mirrored displays when a privacy sensitive window is present on source display. Test: manual test & atest PointerControllerTest Bug: 325252005 Change-Id: Ide428e8daf96a1d919adb9d6374a9ea738f87cc5
2024-05-14Replace ADISPLAY_ID_ constants with LogicalDisplayId equivalents Siarhei Vishniakou
This will help remove ADISPLAY_ID_ constants. Bug: 339106983 Test: m checkinput Change-Id: I37e1ccf4872c0758b2817121199ef5beee7e107f
2024-05-09Use a strongly typed LogicalDisplayId for displayId(1/n) Linnan Li
Currently, we use int32_t for displayId, which is not a safe type, and it may also lead to misdefinition of types. Here, we introduce LogicalDisplayId as a strong type for displayId and move all contents of constants.h into LogicalDisplayId.h. Bug: 339106983 Test: atest inputflinger_tests Test: atest InputTests Test: presubmit Change-Id: I1c348d7f08524471391b21eaba938501506a7772 Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
2024-05-08PointerController: Cleanup after PointerChoreographer refactor Prabir Pradhan
Bug: 311416205 Test: build, presubmit Change-Id: I7a5d801f2988b37f81afe999a9143e2ff1055bc4
2024-05-07Hide touch indicators on mirrored displays if a secure window is present Arpit Singh
Utilise ISurfaceComposerClient::eSkipScreenshot to remove the tap indicators from mirrored displays when a secure window is present. End-to-end test will be added in an upcoming CL. Test: manual test & atest PointerChoreographerTest PointerControllerTest Bug: 325252005 Change-Id: I72a77b1a1b2c02a5e94f05e67d0cd39588086c81
2024-01-23PointerController: Simplify display info listener registration Prabir Pradhan
Bug: 313033164 Test: Presubmit Change-Id: I71e4943d36e0e3b5b0c9eaaaef7c8d04a82ba90d
2024-01-23PointerController: Get initial DisplayInfos from SurfaceComposerClient Linnan Li
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 <lilinnan@xiaomi.corp-partner.google.com>
2023-12-04Add setPointerIcon for PointerChoreographer (base) Byoungho Jung
To set pointer icon for mouse or stylus, we are going to use setPointerIcon with more parameters which will be useful for multi-device experience and security. Test: Manual Bug: 293587049 Change-Id: I17bb047b0bfbff6cf3a129e4fa742ec489420faf
2023-11-08Address additional comments: Pointer icon refactor for touch/stylus Prabir Pradhan
Bug: 293587049 Test: atest inputflinger_tests Change-Id: I831feaf0921dfdc389e79a88690f75fa51c43720
2023-11-08Pointer icon refactor for stylus (base) Byoungho Jung
When PointerChoreographer is enabled, PointerChoreographer can create multiple StylusPointerControllers for each stylus device. A StylusPointerController is created when the corresponding stylus sends the first hover event. It can show and hide a hover pointer on the associated display. Test: atest libinputservice_test Bug: 293587049 Change-Id: I208f09f0e0f73a6396d60f5b2bd0242dddd3c66b
2023-11-08Pointer icon refactor for touch (base) Byoungho Jung
When PointerChoreographer is enabled, PointerChoreographer can create multiple TouchPointerControllers for each touch device when 'Show taps' is enabled. A TouchPointerController is reponsible for one touch device and it can show touch spots on the associated display. Test: atest libinputservice_test Bug: 293587049 Change-Id: I1a624a6a50023c530e709cc5fc0704b0b997125b
2023-11-03Pointer icon refactor for mouse (base) Byoungho Jung
When PointerChoreographer is enabled, CursorInputMapper no longer depends on the legacy PointerController. PointerChoreographer is responsible for accumulating movements, fading/unfading pointers, and deciding display/coordinates. Test: atest libinputservice_test Bug: 293587049 Change-Id: Ie35b385a99623bbcb2e47b394b7cf2c0f7c5bc0e
2023-09-06Addressed missed comments from ag/24539449 Prabir Pradhan
The CL with Change-ID Ib6b124db4108d11260b220cc57444007b9d865a6 was submitted before all reviewers had a chance to take a look. Addressing missed comments here. Bug: 293587049 Bug: 278783893 Test: presubmit Change-Id: I2946c0216935a35af05a3f74f1e2a5bd8e23fed1
2023-08-28Allow PointerController to be disabled on creation Prabir Pradhan
Disable the legacy PointerController when the PointerChoreographer is enabled. Bug: 278783893 Test: manual Change-Id: I475f3286c83b90e161e186e62c2842e539434603
2023-08-24Introduce PointerChoreographer stage in C++ Prabir Pradhan
PointerChoreographer will be the new inputflinger component responsible for managing the pointer icons drawn on the screen. In this CL, we set up the PointerChoreographer, which will be created when the choreographer is enabled. Bug: 293587049 Bug: 278783893 Test: adb shell setprop persist.input.enable_pointer_choreographer 1; boot Change-Id: Ib6b124db4108d11260b220cc57444007b9d865a6
2023-08-18Use std::shared_ptr for SpriteController Prabir Pradhan
Remove RefBase from SpriteController, and use std::shared_ptr. We cannot migrate to std::unique_ptr because we have to post messages to the handler, which needs to have a weak reference to the object. Bug: 278783893 Test: presubmit Change-Id: I0ea4bb220e5b1866375ed39335f9035cd4bb766c
2023-05-03Add vsync id and timestamp to WindowInfosListener Patrick Williams
Bug: 279792237 Test: presubmits Change-Id: I6396800fe7673f592a79c0e9a9f43f68c6443300
2023-03-15Remove getButtonState/setButtonState from PointerController Siarhei Vishniakou
These APIs are not being used. Bug: 217579815 Test: m libinputservice_test Change-Id: I47fb5478caff7d77217c1da600c37556e6a288a8
2023-03-13Return values in PointerController's getters Prabir Pradhan
Rather than passing pointers in to get output from the functions, return values from getPosition() and getBounds(). Bug: 245989146 Bug: 21566609 Test: Build, presubmit Change-Id: Ie5b44a433c94b6c455486922f6894ccde1f1b127
2022-11-11Add dump for PointerController. Michael Wright
Just a simple dump to start, but start pushing more PointerController information into bugreports. Bug: 254277939 Test: manually inspect `dumpsys input` Change-Id: I7ca637aa8a8f1cc1188eddcf694f7c4aea7d5821
2022-06-10Change POINTER_ICON_STYLE enum to a type safe enum class Brandon Pollack
Test: Current tests all pass, this is a static type change, not a functional change. Change-Id: I8f0e8e43ea64f5abab163e4ef5444a8cb3d4fa78
2022-04-14Synchronize pointer display change requests Prabir Pradhan
Previously, when InputManagerService requests for PointerController to change the pointer display, there was no way to know when the request was completed or whether it succeeded. This could lead to a few issues: - WM's MousePositionTracker's coordinates would not be updated until the next mouse event was generated, meaning the position would be out of sync. - The creation of a virtual mouse device moves the pointer to a specific displayId. In order to test this behavior, we would need to sleep in the test code to wait for the system to update the pointer display and position, resulting in generally flaky tests. Here, we add a way to synchonize changes to the pointer display so that InputMangerService can know the current pointer display with certainty. PointerController, which is updated in the InputReader thread, is the source of truth of the pointer display. We add a policy call to notify IMS when the pointer display changes. When the pointer display is changed, the cursor position on the updated display is also updated so that the VirtualMouse#getCursorPosition() API is synchronized to the pointer display change. Bug: 216792538 Test: atest FrameworksServicesTests:InputManagerServiceTests Test: atest PointerIconTest Change-Id: I578fd1aba9335e2e078d749321e55a6d05299f3b
2022-01-17Allow its WindowInfosListener to outlive PointerController Prabir Pradhan
A strong pointer to PointerController::DisplayInfoListener is given away when the listener is registered, so PC cannot guarantee that the listener is destroyed when it is destroyed. This means the listener can outlive PC, so there is a race condition between PC's destruction and an update to the listener. While it could be argued that it is the caller's responsibility to ensure that the listener is not updated after it is unregistered, there is no way to guarantee that using strong pointers. Here, we can be defensive and protect against this case. Bug: 212672261 Test: atest libinputservice_test Change-Id: I358a725980cc8c7d6ad0483a9b2a8b8715a03424
2021-11-22Reland "Change PointerController to display space" Prabir Pradhan
02b0545d02001ad152eeaf1ff35465345cbd5d4d Changes since the first time it landed: - Unregister the WindowInfosLisntener in PointerController's destructor. Bug: 188939842 Bug: 144544464 Bug: 206817973 Test: forrest run - CtsHardwareTestsCases Change-Id: I92a3f128545e73c85d2a5079ee914e2f890c4308
2021-11-17Revert "Change PointerController to display space" Prabir Pradhan
Revert "Change PointerController to display space" Revert submission 16194643-pointer-controller-in-display-space Reason for revert: b/206817973 Reverted Changes: I764c070ad:Change PointerController to display space I5e9e19c36:Change PointerController to display space Change-Id: I615d343968b818f498e905bab7963106b4e62651
2021-11-16Change PointerController to display space Prabir Pradhan
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
2021-02-18Introduce DynamicDisplayInfo Marin Shalamanov
In this CL we introduce SurfaceContorl.getDynamicDisplayInfo which replaces the current seprate calls for supported and active display mode, supproted and active color modes and HDR capabilities. This way display capabilities can be queried atomically. Additionally this CL pipes an DisplayMode IDs from SurfaceFlinger and updates LocalDislayAdapter to use IDs instead of array indices. Test: presubmit Bug: 159590486 Bug: 175678215 Change-Id: I169e3055d07905e2330e11f158b61ffd366f97e6
2020-08-19Switch to callback animation Liam Harrington
Modified current animation logic to use callbacks from the controllers to further clean and modularize code. Test: Pixel 3XL device, atest PointerController_test, compile Change-Id: I1073bd78687cca491663c0349751dab4b30aa8e2
2020-08-06Refactor of PointerController Liam Harrington
Abstracted logic that applies to all pointer types into general PointerController class and moved implementation of logic specific to the mouse cursor and touch spots to MouseCursorController and TouchSpotController, respectively. Test: Pixel 3XL device, atest PointerController_test, compile Change-Id: Ia5825c37ca75951cc8bcd7d5102c986bd957e69f
2020-07-07Move PointerController enums to enum classes. Michael Wright
Bug: 160010896 Test: atest PointerController_test, compile Change-Id: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea Merged-In: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea
2020-07-07Move PointerController from sp to shared_ptr Michael Wright
Bug: 160010896 Test: atest PointerController_test, manual usage Change-Id: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b Merged-In: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b
2020-05-28Move setDisplayViewport to InputReader. Garfield Tan
InputReader is responsible to associate device and display so it makes sense to allow it set display viewport for pointer controller. Bug: 146385350 Test: Cursor can be associated with external freeform displays as expected. Change-Id: I00d664dd180f1e693b1900582feea8f7ff02f93c Merged-In: I00d664dd180f1e693b1900582feea8f7ff02f93c
2019-02-13Support showTouches on multi-display (2/2) Arthur Hung
Currently the PointerController would be associated with the top most freeform or external display if enable desktop mode. But for presenting spots when enable showTouches from develop options, they should be shown on the corresponding display where user touched. Also changed Vector to std::vector. Test: atest inputflinger_tests Test: Use device support multi-display and touch screen (like mojave). Enable showTaps from develop options and check if show tap spots. Bug: 120815589 Change-Id: I0854fa97813aabf005dccb8ec6fbda10106126e9
2019-01-17Load correct resources for pointer icon on external screen Andrii Kulian
When mouse pointer changes displays, it should also reload the icon from new resources. Otherwise, if the densities of the previous and new displays are different, the size of the pointer sprite will look too small or too large. - Add getDisplayContext to get the corresponding Context by displayId. - Cache system pointer icons per display, clear if display removed. - Fix icon moved to default when not resetting out of task bound. Bug: 113559891 Test: Enable mouse pointer on default display, move to other screen Change-Id: Ic42d0ec32d9c979281e13c83b9e8b57134fd4f0d
2019-01-09Support mouse pointer on external displays (2/2) Arthur Hung
Limit mouse boundary to one display viewport. Currently if desktop mode is enable, selects the topmost freeform display, or find first external display if there is no freeform display. Return the default display if desktop mode is not enable. - Add getPointerDisplayId to find the preferred display. - Limit update viewports from InputReader. - obtainPointerController would also find the associated display id. - Reload cursor resources if resolution or display changed. Bug: 113559891 Test: atest inputfliger_tests Test: ActivityView test app Change-Id: Iffd01e27f5010ccfb0481a028658b7290ca6316d
2018-12-17Revert "Support mouse pointer on external displays (2/3)" Andrii Kulian
This reverts commit 84cdf9cc3b849679e6b4f6d3ccb66270f0abad2f. Reason for revert: b/120864177 Test: Presubmit Bug: b/120864177 Change-Id: Ia65e704169527b54cf1d1d470445f96a65fa0294
2018-12-10Support mouse pointer on external displays (2/3) Andrii Kulian
Limit mouse boundary to one display viewport. Currently if desktop mode is enable, selects the topmost freeform display, or find first external display if there is no freeform display. Return the default display if desktop mode is not enable. - Add getPointerDisplayId to find the preferred display. - Limit update viewports from InputReader. Also implements updatePointerDisplay to find and associate with the specified display viewport. - Reload cursor resources if resolution or display changed. Bug: 113559891 Test: atest inputfliger_tests Test: ActivityView test app Change-Id: Ief3410a517be457dfe6f1180342bb1dc88833635
2018-11-19InputFlinger Split: Use libinputreader in InputManagerService Prabir Pradhan
This changes native InputManagerService to use the new backend library for inputflinger: libinputreader. Bug: 119264687 Test: manual: Build, run, and test input (touch, mouse) Change-Id: I619492d5492cd8444d7c2cc7af9717c19c938256
2018-07-11Refactor String8 to std::string calls Siarhei Vishniakou
DisplayViewport::uniqueId is now std::string, so change the calls appropriately. Do some additional cleanups and conversions. This almost completely removes the dependency on String8. Test: build only Bug: 111108021 Change-Id: Ibbb6ca59e9061954d4a5fb930ef03d42cb0230db
2016-09-09Hold a weak reference to PointerController when handling vsync Vladislav Kaznacheev
Currently PointerController starts listening to display events immediately (in its constructor) and never explicitly removes the callback. The reference dangling from the looper prevents the PointerController instance from being deleted when all the clients have released their references. As a result, when USB or BT mouse is disconnected, the mouse stays frozen on screen and only goes away after a 15 sec inactivity timeout. This change introduces an intermediary LooperCallback which holds only a weak reference to PointerController. The pointer now disappears immediately upon mouse disconnect. Bug: 30824220 Change-Id: I5f7208dbfa381b3e21f248cc0da402f307faa184
2016-05-17DO NOT MERGE Remove Pointer Capture API Michael Wright
The underlying implementation needs to be completely rethought. If a process crashed while you were in pointer capture mode, you were pretty much stuck in it. If the mouse happened to move outside of your bounds right before you called the API, you'd never actually get an event (whatever it was hovering over would). There's no easy way for the system to tell you when you enter or exit this mode because it doesn't actually track who the current request is from. These are all solvable, but not in the N time frame. Maybe next time. Bug: 26830970 Change-Id: I03efd63c499b86dc278491ca3284566c1965581f
2016-05-17DO NOT MERGE Rename PointerIcon and Pointer Capture APIs Michael Wright
This is a response to API council feedback. Bug: 26830970 Change-Id: Ia2d284b5c1ab8365bedfdc37d129be4b8146036b
2015-12-18Introduce pointer capture API. Jun Mukai
This depends on I4189eb4d93f50c2865b7a325727be5ceebcc71f8 of frameworks/native. Bug: 5452473 Change-Id: Ie21e521f3e5c581f976dc0feb5d84bfa48b046cd
2015-12-14Make public pointer icon API with custom icons. Jun Mukai
BUG: 25778347, 23804184 Change-Id: If138b97c750c912e9848412c27b65004899961eb