Touchpad Capture: Fix issues with Pointer Controller
Issues fixed:
- When "Show Touches" is enabled, enabling touchpad capture does not
hide the mouse cursor.
- When disabling touchpad capture, mouse cursor does not return to
location that it was at when touchpad capture was disabled. Instead,
it is reset to the center of the display.
Bug: 173806099
Fixes: 173806099
Test: manual
Test: atest inputflinger_tests
Change-Id: I3a0a429d6288073b7668abfbfab742f095de9c7f
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 04a5c4f..0b541fb 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -781,12 +781,17 @@
mOrientedRanges.clear();
}
- // Create pointer controller if needed.
+ // Create pointer controller if needed, and keep it around if Pointer Capture is enabled to
+ // preserve the cursor position.
if (mDeviceMode == DeviceMode::POINTER ||
- (mDeviceMode == DeviceMode::DIRECT && mConfig.showTouches)) {
+ (mDeviceMode == DeviceMode::DIRECT && mConfig.showTouches) ||
+ (mParameters.deviceType == Parameters::DeviceType::POINTER && mConfig.pointerCapture)) {
if (mPointerController == nullptr) {
mPointerController = getContext()->getPointerController(getDeviceId());
}
+ if (mConfig.pointerCapture) {
+ mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
+ }
} else {
mPointerController.reset();
}