@@ -243,14 +243,7 @@ NotifyMotionArgs PointerChoreographer::processMouseEventLocked(const NotifyMotio
243243 pc.setPosition (args.xCursorPosition , args.yCursorPosition );
244244 } else {
245245 // This is a relative mouse, so move the cursor by the specified amount.
246- const float deltaX = args.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_X);
247- const float deltaY = args.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_Y);
248- pc.move (deltaX, deltaY);
249- const auto [x, y] = pc.getPosition ();
250- newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_X, x);
251- newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_Y, y);
252- newArgs.xCursorPosition = x;
253- newArgs.yCursorPosition = y;
246+ processPointerDeviceMotionEventLocked (/* byref*/ newArgs, /* byref*/ pc);
254247 }
255248 if (canUnfadeOnDisplay (displayId)) {
256249 pc.unfade (PointerControllerInterface::Transition::IMMEDIATE);
@@ -266,24 +259,9 @@ NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMo
266259 newArgs.displayId = displayId;
267260 if (args.getPointerCount () == 1 && args.classification == MotionClassification::NONE) {
268261 // This is a movement of the mouse pointer.
269- const float deltaX = args.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_X);
270- const float deltaY = args.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_Y);
271- pc.move (deltaX, deltaY);
272- if (canUnfadeOnDisplay (displayId)) {
273- pc.unfade (PointerControllerInterface::Transition::IMMEDIATE);
274- }
275-
276- const auto [x, y] = pc.getPosition ();
277- newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_X, x);
278- newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_Y, y);
279- newArgs.xCursorPosition = x;
280- newArgs.yCursorPosition = y;
262+ processPointerDeviceMotionEventLocked (/* byref*/ newArgs, /* byref*/ pc);
281263 } else {
282264 // This is a trackpad gesture with fake finger(s) that should not move the mouse pointer.
283- if (canUnfadeOnDisplay (displayId)) {
284- pc.unfade (PointerControllerInterface::Transition::IMMEDIATE);
285- }
286-
287265 const auto [x, y] = pc.getPosition ();
288266 for (uint32_t i = 0 ; i < newArgs.getPointerCount (); i++) {
289267 newArgs.pointerCoords [i].setAxisValue (AMOTION_EVENT_AXIS_X,
@@ -294,9 +272,25 @@ NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMo
294272 newArgs.xCursorPosition = x;
295273 newArgs.yCursorPosition = y;
296274 }
275+ if (canUnfadeOnDisplay (displayId)) {
276+ pc.unfade (PointerControllerInterface::Transition::IMMEDIATE);
277+ }
297278 return newArgs;
298279}
299280
281+ void PointerChoreographer::processPointerDeviceMotionEventLocked (NotifyMotionArgs& newArgs,
282+ PointerControllerInterface& pc) {
283+ const float deltaX = newArgs.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_X);
284+ const float deltaY = newArgs.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_Y);
285+
286+ pc.move (deltaX, deltaY);
287+ const auto [x, y] = pc.getPosition ();
288+ newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_X, x);
289+ newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_Y, y);
290+ newArgs.xCursorPosition = x;
291+ newArgs.yCursorPosition = y;
292+ }
293+
300294void PointerChoreographer::processDrawingTabletEventLocked (const android::NotifyMotionArgs& args) {
301295 if (args.displayId == ui::LogicalDisplayId::INVALID) {
302296 return ;
0 commit comments