@@ -1491,13 +1491,11 @@ std::vector<InputTarget> InputDispatcher::DispatcherTouchState::findOutsideTarge
14911491 if (info.inputConfig .test (WindowInfo::InputConfig::WATCH_OUTSIDE_TOUCH)) {
14921492 std::bitset<MAX_POINTER_ID + 1 > pointerIds;
14931493 pointerIds.set (pointerId);
1494- DispatcherTouchState::addPointerWindowTarget (windowHandle,
1495- InputTarget::DispatchMode::OUTSIDE,
1496- ftl::Flags<InputTarget::Flags>(),
1497- pointerIds,
1498- /* firstDownTimeInTarget=*/ std::nullopt ,
1499- connections, windowInfos, dump,
1500- outsideTargets);
1494+ addPointerWindowTarget (windowHandle, InputTarget::DispatchMode::OUTSIDE,
1495+ ftl::Flags<InputTarget::Flags>(), pointerIds,
1496+ /* firstDownTimeInTarget=*/ std::nullopt ,
1497+ /* pointerDisplayId=*/ std::nullopt , connections, windowInfos,
1498+ dump, outsideTargets);
15011499 }
15021500 }
15031501 return outsideTargets;
@@ -2612,12 +2610,12 @@ InputDispatcher::DispatcherTouchState::findTouchedWindowTargets(
26122610
26132611 const TouchedWindow& touchedWindow =
26142612 tempTouchState.getTouchedWindow (oldTouchedWindowHandle);
2615- DispatcherTouchState::
2616- addPointerWindowTarget (oldTouchedWindowHandle ,
2617- InputTarget::DispatchMode::SLIPPERY_EXIT ,
2618- ftl::Flags<InputTarget::Flags>(), pointerIds ,
2619- touchedWindow. getDownTimeInTarget (entry. deviceId ) ,
2620- connections, windowInfos, dump, targets);
2613+ addPointerWindowTarget (oldTouchedWindowHandle,
2614+ InputTarget::DispatchMode::SLIPPERY_EXIT ,
2615+ ftl::Flags<InputTarget::Flags>(), pointerIds ,
2616+ touchedWindow. getDownTimeInTarget (entry. deviceId ) ,
2617+ /* pointerDisplayId= */ std:: nullopt , connections, windowInfos ,
2618+ dump, targets);
26212619
26222620 // Make a slippery entrance into the new window.
26232621
@@ -2666,12 +2664,11 @@ InputDispatcher::DispatcherTouchState::findTouchedWindowTargets(
26662664 std::bitset<MAX_POINTER_ID + 1 > pointerIds;
26672665 pointerIds.set (entry.pointerProperties [0 ].id );
26682666 for (const TouchedWindow& touchedWindow : hoveringWindows) {
2669- DispatcherTouchState::addPointerWindowTarget (touchedWindow.windowHandle ,
2670- touchedWindow.dispatchMode ,
2671- touchedWindow.targetFlags , pointerIds,
2672- touchedWindow.getDownTimeInTarget (
2673- entry.deviceId ),
2674- connections, windowInfos, dump, targets);
2667+ addPointerWindowTarget (touchedWindow.windowHandle , touchedWindow.dispatchMode ,
2668+ touchedWindow.targetFlags , pointerIds,
2669+ touchedWindow.getDownTimeInTarget (entry.deviceId ),
2670+ /* pointerDisplayId=*/ std::nullopt , connections, windowInfos,
2671+ dump, targets);
26752672 }
26762673 }
26772674
@@ -2724,13 +2721,11 @@ InputDispatcher::DispatcherTouchState::findTouchedWindowTargets(
27242721 if (touchingPointers.empty ()) {
27252722 continue ;
27262723 }
2727- DispatcherTouchState::addPointerWindowTarget (touchedWindow.windowHandle ,
2728- touchedWindow.dispatchMode ,
2729- touchedWindow.targetFlags ,
2730- getPointerIds (touchingPointers),
2731- touchedWindow.getDownTimeInTarget (
2732- entry.deviceId ),
2733- connections, windowInfos, dump, targets);
2724+ addPointerWindowTarget (touchedWindow.windowHandle , touchedWindow.dispatchMode ,
2725+ touchedWindow.targetFlags , getPointerIds (touchingPointers),
2726+ touchedWindow.getDownTimeInTarget (entry.deviceId ),
2727+ /* pointerDisplayId=*/ displayId, connections, windowInfos, dump,
2728+ targets);
27342729 }
27352730
27362731 // During targeted injection, only allow owned targets to receive events
@@ -2933,8 +2928,9 @@ void InputDispatcher::DispatcherTouchState::addPointerWindowTarget(
29332928 const sp<android::gui::WindowInfoHandle>& windowHandle,
29342929 InputTarget::DispatchMode dispatchMode, ftl::Flags<InputTarget::Flags> targetFlags,
29352930 std::bitset<MAX_POINTER_ID + 1 > pointerIds, std::optional<nsecs_t > firstDownTimeInTarget,
2936- const ConnectionManager& connections, const DispatcherWindowInfo& windowInfos,
2937- std::function<void ()> dump, std::vector<InputTarget>& inputTargets) {
2931+ std::optional<ui::LogicalDisplayId> pointerDisplayId, const ConnectionManager& connections,
2932+ const DispatcherWindowInfo& windowInfos, std::function<void ()> dump,
2933+ std::vector<InputTarget>& inputTargets) {
29382934 if (pointerIds.none ()) {
29392935 for (const auto & target : inputTargets) {
29402936 LOG (INFO) << " Target: " << target;
@@ -2969,7 +2965,8 @@ void InputDispatcher::DispatcherTouchState::addPointerWindowTarget(
29692965 }
29702966 inputTargets.push_back (
29712967 createInputTarget (connection, windowHandle, dispatchMode, targetFlags,
2972- windowInfos.getRawTransform (*windowHandle->getInfo ()),
2968+ windowInfos.getRawTransform (*windowHandle->getInfo (),
2969+ pointerDisplayId),
29732970 firstDownTimeInTarget));
29742971 it = inputTargets.end () - 1 ;
29752972 }
@@ -4172,8 +4169,9 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
41724169 DispatcherTouchState::
41734170 addPointerWindowTarget (window, InputTarget::DispatchMode::AS_IS,
41744171 ftl::Flags<InputTarget::Flags>(), pointerIds,
4175- motionEntry.downTime , mConnectionManager ,
4176- mWindowInfos ,
4172+ motionEntry.downTime ,
4173+ /* pointerDisplayId=*/ std::nullopt ,
4174+ mConnectionManager , mWindowInfos ,
41774175 std::bind_front (&InputDispatcher::
41784176 logDispatchStateLocked,
41794177 this ),
@@ -4259,6 +4257,7 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked(
42594257 DispatcherTouchState::
42604258 addPointerWindowTarget (windowHandle, InputTarget::DispatchMode::AS_IS,
42614259 targetFlags, pointerIds, motionEntry.downTime ,
4260+ /* pointerDisplayId=*/ std::nullopt ,
42624261 mConnectionManager , mWindowInfos ,
42634262 std::bind_front (&InputDispatcher::
42644263 logDispatchStateLocked,
@@ -5171,13 +5170,24 @@ ui::Transform InputDispatcher::DispatcherWindowInfo::getDisplayTransform(
51715170}
51725171
51735172ui::Transform InputDispatcher::DispatcherWindowInfo::getRawTransform (
5174- const android::gui::WindowInfo& windowInfo) const {
5173+ const android::gui::WindowInfo& windowInfo,
5174+ std::optional<ui::LogicalDisplayId> pointerDisplayId) const {
5175+ // TODO(b/383092013): Handle TOPOLOGY_AWARE window flag.
5176+ // For now, we assume all windows are topology-aware and can handle cross-display streams.
5177+ if (com::android::input::flags::connected_displays_cursor () && pointerDisplayId.has_value () &&
5178+ *pointerDisplayId != windowInfo.displayId ) {
5179+ // Sending pointer to a different display than the window. This is a
5180+ // cross-display drag gesture, so always use the new display's transform.
5181+ return getDisplayTransform (*pointerDisplayId);
5182+ }
51755183 // If the window has a cloneLayerStackTransform, always use it as the transform for the "getRaw"
5176- // APIs. If not, fall back to using the DisplayInfo transform of the window's display.
5177- return (input_flags::use_cloned_screen_coordinates_as_raw () &&
5178- windowInfo.cloneLayerStackTransform )
5179- ? *windowInfo.cloneLayerStackTransform
5180- : getDisplayTransform (windowInfo.displayId );
5184+ // APIs. If not, fall back to using the DisplayInfo transform of the window's display
5185+ bool useClonedScreenCoordinates = (input_flags::use_cloned_screen_coordinates_as_raw () &&
5186+ windowInfo.cloneLayerStackTransform );
5187+ if (useClonedScreenCoordinates) {
5188+ return *windowInfo.cloneLayerStackTransform ;
5189+ }
5190+ return getDisplayTransform (windowInfo.displayId );
51815191}
51825192
51835193ui::LogicalDisplayId InputDispatcher::DispatcherWindowInfo::getPrimaryDisplayId (
@@ -7100,7 +7110,8 @@ void InputDispatcher::DispatcherTouchState::slipWallpaperTouch(
71007110 oldTouchedWindow.targetFlags ,
71017111 getPointerIds (pointers),
71027112 oldTouchedWindow.getDownTimeInTarget (deviceId),
7103- connections, windowInfos, dump, targets);
7113+ /* pointerDisplayId=*/ std::nullopt , connections,
7114+ windowInfos, dump, targets);
71047115 state.removeTouchingPointerFromWindow (deviceId, pointerProperties.id , oldWallpaper);
71057116 }
71067117
0 commit comments