@@ -64,9 +64,8 @@ bool isMouseOrTouchpad(uint32_t sources) {
6464 !isFromSource (sources, AINPUT_SOURCE_STYLUS));
6565}
6666
67- inline void notifyPointerDisplayChange (
68- std::optional<std::tuple<ui::LogicalDisplayId, FloatPoint>> change,
69- PointerChoreographerPolicyInterface& policy) {
67+ inline void notifyPointerDisplayChange (std::optional<std::tuple<ui::LogicalDisplayId, vec2>> change,
68+ PointerChoreographerPolicyInterface& policy) {
7069 if (!change) {
7170 return ;
7271 }
@@ -245,9 +244,9 @@ NotifyMotionArgs PointerChoreographer::processMouseEventLocked(const NotifyMotio
245244 if (MotionEvent::isValidCursorPosition (args.xCursorPosition , args.yCursorPosition )) {
246245 // This is an absolute mouse device that knows about the location of the cursor on the
247246 // display, so set the cursor position to the specified location.
248- const auto [x, y] = pc.getPosition ();
249- const float deltaX = args.xCursorPosition - x;
250- const float deltaY = args.yCursorPosition - y;
247+ const auto position = pc.getPosition ();
248+ const float deltaX = args.xCursorPosition - position. x ;
249+ const float deltaY = args.yCursorPosition - position. y ;
251250 newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
252251 newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY);
253252 pc.setPosition (args.xCursorPosition , args.yCursorPosition );
@@ -273,15 +272,15 @@ NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMo
273272 processPointerDeviceMotionEventLocked (/* byref*/ newArgs, /* byref*/ pc);
274273 } else {
275274 // This is a trackpad gesture with fake finger(s) that should not move the mouse pointer.
276- const auto [x, y] = pc.getPosition ();
275+ const auto position = pc.getPosition ();
277276 for (uint32_t i = 0 ; i < newArgs.getPointerCount (); i++) {
278277 newArgs.pointerCoords [i].setAxisValue (AMOTION_EVENT_AXIS_X,
279- args.pointerCoords [i].getX () + x);
278+ args.pointerCoords [i].getX () + position. x );
280279 newArgs.pointerCoords [i].setAxisValue (AMOTION_EVENT_AXIS_Y,
281- args.pointerCoords [i].getY () + y);
280+ args.pointerCoords [i].getY () + position. y );
282281 }
283- newArgs.xCursorPosition = x;
284- newArgs.yCursorPosition = y;
282+ newArgs.xCursorPosition = position. x ;
283+ newArgs.yCursorPosition = position. y ;
285284 }
286285
287286 // Note displayId may have changed if the cursor moved to a different display
@@ -296,33 +295,31 @@ void PointerChoreographer::processPointerDeviceMotionEventLocked(NotifyMotionArg
296295 const float deltaX = newArgs.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_X);
297296 const float deltaY = newArgs.pointerCoords [0 ].getAxisValue (AMOTION_EVENT_AXIS_RELATIVE_Y);
298297
299- FloatPoint unconsumedDelta = pc.move (deltaX, deltaY);
298+ vec2 unconsumedDelta = pc.move (deltaX, deltaY);
300299 if (com::android::input::flags::connected_displays_cursor () &&
301300 (std::abs (unconsumedDelta.x ) > 0 || std::abs (unconsumedDelta.y ) > 0 )) {
302301 handleUnconsumedDeltaLocked (pc, unconsumedDelta);
303302 // pointer may have moved to a different viewport
304303 newArgs.displayId = pc.getDisplayId ();
305304 }
306305
307- const auto [x, y] = pc.getPosition ();
308- newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_X, x);
309- newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_Y, y);
310- newArgs.xCursorPosition = x;
311- newArgs.yCursorPosition = y;
306+ const auto position = pc.getPosition ();
307+ newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_X, position. x );
308+ newArgs.pointerCoords [0 ].setAxisValue (AMOTION_EVENT_AXIS_Y, position. y );
309+ newArgs.xCursorPosition = position. x ;
310+ newArgs.yCursorPosition = position. y ;
312311}
313312
314313void PointerChoreographer::handleUnconsumedDeltaLocked (PointerControllerInterface& pc,
315- const FloatPoint & unconsumedDelta) {
314+ const vec2 & unconsumedDelta) {
316315 // Display topology is in rotated coordinate space and Pointer controller returns and expects
317316 // values in the un-rotated coordinate space. So we need to transform delta and cursor position
318317 // back to the rotated coordinate space to lookup adjacent display in the display topology.
319318 const auto & sourceDisplayTransform = pc.getDisplayTransform ();
320319 const vec2 rotatedUnconsumedDelta =
321- transformWithoutTranslation (sourceDisplayTransform,
322- {unconsumedDelta.x , unconsumedDelta.y });
323- const FloatPoint cursorPosition = pc.getPosition ();
324- const vec2 rotatedCursorPosition =
325- sourceDisplayTransform.transform (cursorPosition.x , cursorPosition.y );
320+ transformWithoutTranslation (sourceDisplayTransform, unconsumedDelta);
321+ const vec2 cursorPosition = pc.getPosition ();
322+ const vec2 rotatedCursorPosition = sourceDisplayTransform.transform (cursorPosition);
326323
327324 // To find out the boundary that cursor is crossing we are checking delta in x and y direction
328325 // respectively. This prioritizes x direction over y.
@@ -769,7 +766,7 @@ PointerChoreographer::PointerDisplayChange PointerChoreographer::updatePointerCo
769766PointerChoreographer::PointerDisplayChange
770767PointerChoreographer::calculatePointerDisplayChangeToNotify () {
771768 ui::LogicalDisplayId displayIdToNotify = ui::LogicalDisplayId::INVALID;
772- FloatPoint cursorPosition = {0 , 0 };
769+ vec2 cursorPosition = {0 , 0 };
773770 if (const auto it = mMousePointersByDisplay .find (mDefaultMouseDisplayId );
774771 it != mMousePointersByDisplay .end ()) {
775772 const auto & pointerController = it->second ;
@@ -840,7 +837,7 @@ std::optional<DisplayViewport> PointerChoreographer::getViewportForPointerDevice
840837 return std::nullopt ;
841838}
842839
843- FloatPoint PointerChoreographer::getMouseCursorPosition (ui::LogicalDisplayId displayId) {
840+ vec2 PointerChoreographer::getMouseCursorPosition (ui::LogicalDisplayId displayId) {
844841 std::scoped_lock _l (getLock ());
845842 const ui::LogicalDisplayId resolvedDisplayId = getTargetMouseDisplayLocked (displayId);
846843 if (auto it = mMousePointersByDisplay .find (resolvedDisplayId);
0 commit comments