summaryrefslogtreecommitdiff
path: root/libs/input/PointerController.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Synchronize pointer display change requestsPrabir Pradhan2022-05-051-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Merged-In: I578fd1aba9335e2e078d749321e55a6d05299f3b
* Allow its WindowInfosListener to outlive PointerControllerPrabir Pradhan2022-01-171-23/+55
| | | | | | | | | | | | | | | | | 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
* Reland "Change PointerController to display space"Prabir Pradhan2021-11-221-15/+75
| | | | | | | | | | | | | | 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
* Revert "Change PointerController to display space"Prabir Pradhan2021-11-171-71/+15
| | | | | | | | | | | | | 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
* Change PointerController to display spacePrabir Pradhan2021-11-161-15/+71
| | | | | | | | | | | | | | | | | | | | 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
* Switch to callback animationLiam Harrington2020-08-191-19/+5
| | | | | | | | 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
* Refactor of PointerControllerLiam Harrington2020-08-061-673/+85
| | | | | | | | | | 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
* Move PointerController enums to enum classes.Michael Wright2020-07-071-10/+11
| | | | | | | Bug: 160010896 Test: atest PointerController_test, compile Change-Id: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea Merged-In: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea
* Move PointerController from sp to shared_ptrMichael Wright2020-07-071-49/+54
| | | | | | | Bug: 160010896 Test: atest PointerController_test, manual usage Change-Id: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b Merged-In: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b
* PointerController: Add guards to ensure display is validPrabir Pradhan2020-05-281-9/+24
| | | | | | | | | | | | This change makes it so that PointerController does not ask its Policy to load any resources for any displays until a DisplayViewport is set, and verifies this with unit tests. Bug: 145699789 Bug: 146385350 Test: atest libinputservice_test Change-Id: I2e48e7ac4700e6f9fdf939a7bd0e6639b051ade6 Merged-In: I2e48e7ac4700e6f9fdf939a7bd0e6639b051ade6
* Fix mouse pointer not getting enlargedArthur Hung2019-02-261-3/+3
| | | | | | | | | | | | | | When show taps enabled, the presentation would be PRESENTATION_SPOT for drawing the spots. That would ignore loadPointerIcon when reload resources. Always load default icon when reload resources. Bug: 115395392 Test: Enable show taps and use mouse, enabled large mouse pointer manually. Change-Id: I74f2bf33c9046e8eaba7d284ca16366da6e3d221
* Support showTouches on multi-display (2/2)Arthur Hung2019-02-131-46/+78
| | | | | | | | | | | | | | | | 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
* Load correct resources for pointer icon on external screenAndrii Kulian2019-01-171-4/+4
| | | | | | | | | | | | | | | 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
* Merge "Fix/suppress libs/* google-explicit-constructor warnings" am: ↵Chih-hung Hsieh2019-01-111-1/+1
|\ | | | | | | | | | | | | | | a35900fd8e am: 0aab12591f am: 3169d6895d Change-Id: I14010d3e22cfa4a3e1a1e47a19eab3117fda0455
| * Fix/suppress libs/* google-explicit-constructor warningsChih-Hung Hsieh2019-01-101-1/+1
| | | | | | | | | | | | | | | | * Add explicit to conversion constructors/operators Bug: 28341362 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor Change-Id: I31d45e4c6ff9fa69801a14c341f2da66baf565a0
* | Support mouse pointer on external displays (2/2)Arthur Hung2019-01-091-64/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Revert "Support mouse pointer on external displays (2/3)"Andrii Kulian2018-12-171-72/+64
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 84cdf9cc3b849679e6b4f6d3ccb66270f0abad2f. Reason for revert: b/120864177 Test: Presubmit Bug: b/120864177 Change-Id: Ia65e704169527b54cf1d1d470445f96a65fa0294
* | Support mouse pointer on external displays (2/3)Andrii Kulian2018-12-101-64/+72
|/ | | | | | | | | | | | | | | | | 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
* Remove obsolete pragma statementsSiarhei Vishniakou2018-02-231-4/+0
| | | | | | | | These pragma statements used to guard against compiler warnings in Sk.. code. They are no longer necessary. Test: make Change-Id: I9f7f88276edb546ba08c7344c142eb487a04f978
* Fix doFadingAnimationLocked in sanitized builds.Ivan Lozano2017-12-191-2/+4
| | | | | | | | | | | | | | | | | The loop as constructed causes i to overflow twice when i = 0 on integer overflow sanitized builds. runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') runtime error: unsigned integer overflow: 18446744073709551615 + 1 cannot be represented in type 'size_t' (aka 'unsigned long') This refactors the loop to avoid the overflows. Bug: 30969751 Test: Compiles, device boots, enabled pointer location overlay. Change-Id: I844bb3b84b1f536c50d06fb489fcc22590d4aa98
* resolve merge conflicts of 082a1721b516 to masterMark Salyzyn2017-01-111-2/+2
|\ | | | | | | | | | | | | Test: compile Bug: 26552300 Bug: 31289077 Change-Id: I17f178f425975c1c0dbd48091d25b101956d505e
| * Replace cutils/log.h and log/logger.h with log/log.hMark Salyzyn2017-01-091-2/+2
| | | | | | | | | | | | | | Test: compile Bug: 26552300 Bug: 31289077 Change-Id: I578b15b48f0fc2807a92abbc69a377c3d2191496
* | use SkBlendModeMike Reed2016-11-021-1/+1
| | | | | | | | | | | | | | | | skbug.com/5814 Test: compile only Change-Id: Ibbaff43df1117b2ca77fd8f917f03d88cc476330 (cherry picked from commit 26edbcba8a2ed4cb300e7f87e679e3b73cec2772)
* | Hold a weak reference to PointerController when handling vsync am: ↵Vladislav Kaznacheev2016-09-131-1/+25
|\| | | | | | | | | | | | | | | 33c5903e77 am: 8728a2fe53 am: 23bb30843c Change-Id: Ifccc705f9b21fb8c24fd7fc83f99d9c58ac85b5c
| * Hold a weak reference to PointerController when handling vsyncVladislav Kaznacheev2016-09-091-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * DO NOT MERGE Remove Pointer Capture APIMichael Wright2016-05-171-29/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * DO NOT MERGE Rename PointerIcon and Pointer Capture APIsMichael Wright2016-05-171-10/+10
| | | | | | | | | | | | | | This is a response to API council feedback. Bug: 26830970 Change-Id: Ia2d284b5c1ab8365bedfdc37d129be4b8146036b
* | Remove Pointer Capture APIMichael Wright2016-06-081-29/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: I899649594c7ca8db5962fcdaa71c5b21d3aa42c3
* | Rename PointerIcon and Pointer Capture APIsMichael Wright2016-06-041-10/+10
|/ | | | | | | This is a response to API council feedback. Bug: 26830970 Change-Id: I1be541a53e3943d06640169671824f7daea15462
* Introduce pointer capture API.Jun Mukai2015-12-181-0/+29
| | | | | | | | This depends on I4189eb4d93f50c2865b7a325727be5ceebcc71f8 of frameworks/native. Bug: 5452473 Change-Id: Ie21e521f3e5c581f976dc0feb5d84bfa48b046cd
* Make public pointer icon API with custom icons.Jun Mukai2015-12-141-0/+11
| | | | | BUG: 25778347, 23804184 Change-Id: If138b97c750c912e9848412c27b65004899961eb
* Introduce accessibility large pointer icons.Jun Mukai2015-11-301-9/+24
| | | | | | | | | | | | | | | This patch does the following things: - add new graphic assets of large icons for accessibility needs (imported from ChromeOS data) - add the logic to choose the set of normal icons or accessibility icons - make InputManagerService to observe the settings change, so that it can reload the new resources This patch misses non-1x graphic though, because ChromeOS doesn't have such data. Bug: 25778857 Change-Id: Ia5f95d47f50b3f6eea555c3af8069bc6bae0b400
* Introduce animated pointer icon for STYLE_WAIT.Jun Mukai2015-11-171-6/+48
| | | | Change-Id: I893f8276e09351db6187c553f349008794b95690
* Bring DisplayEventReceiver to PointerController.Jun Mukai2015-10-301-9/+43
| | | | | | Now the fading animation of pointers is handled at vsync. Change-Id: I10fe27d9d7a0d46c4e6504ca487e80bb56e2fd98
* Use invisible icon for POINTER_ICON_STYLE_NULL.Jun Mukai2015-10-211-2/+2
| | | | Change-Id: I10d35bdc4da4817d769eb164e6f15e4618670a05
* Allow changing mouse pointer icon for the current context.Jun Mukai2015-10-151-2/+30
| | | | | | | | | | Right now, it only supports I-beam on EditText, but further rules will come in the future. The png files for the icons are from chromium. Bug: 24180385 Change-Id: I8de4ec8a5412b4830c08aa232c5083841c5c751c
* Frameworks/base: Wall Werror in libs/inputAndreas Gampe2014-11-101-0/+3
| | | | | | Enable -Wall -Werror in libs/input. Mask warnings from Skia. Change-Id: I0deeffde07fcf3a09eadec2852e9bf5666b55ee8
* Move some system services to separate directoriesAmith Yamasani2013-12-191-0/+604
Refactored the directory structure so that services can be optionally excluded. This is step 1. Will be followed by another change that makes it possible to remove services from the build. Change-Id: Ideacedfd34b5e213217ad3ff4ebb21c4a8e73f85