@@ -788,38 +788,14 @@ void filterUntrustedTargets(TouchState& touchState, std::vector<InputTarget>& ta
788788 });
789789}
790790
791- /* *
792- * In general, touch should be always split between windows. Some exceptions:
793- * 1. Don't split touch if all of the below is true:
794- * (a) we have an active pointer down *and*
795- * (b) a new pointer is going down that's from the same device *and*
796- * (c) the window that's receiving the current pointer does not support split touch.
797- * 2. Don't split mouse events
798- */
799- bool shouldSplitTouch (const TouchState& touchState, const MotionEntry& entry) {
800- if (isFromSource (entry.source , AINPUT_SOURCE_MOUSE)) {
801- // We should never split mouse events
802- return false ;
803- }
804- for (const TouchedWindow& touchedWindow : touchState.windows ) {
805- if (touchedWindow.windowHandle ->getInfo ()->isSpy ()) {
806- // Spy windows should not affect whether or not touch is split.
807- continue ;
808- }
809- if (touchedWindow.windowHandle ->getInfo ()->supportsSplitTouch ()) {
810- continue ;
811- }
812- if (touchedWindow.windowHandle ->getInfo ()->inputConfig .test (
813- gui::WindowInfo::InputConfig::IS_WALLPAPER)) {
814- // Wallpaper window should not affect whether or not touch is split
815- continue ;
816- }
817-
818- if (touchedWindow.hasTouchingPointers (entry.deviceId )) {
819- return false ;
820- }
821- }
822- return true ;
791+ bool shouldSplitTouch (int32_t source) {
792+ // We should never split mouse events. This is because the events that are produced by touchpad
793+ // are sent to InputDispatcher as two fingers (for example, pinch zoom), but they need to be
794+ // dispatched to the same window. In those cases, the behaviour is also slightly different from
795+ // default because the events should be sent to the cursor position rather than the x,y values
796+ // of each of the fingers.
797+ // The "normal" (uncaptured) events produced by touchpad and by mouse have SOURCE_MOUSE.
798+ return !isFromSource (source, AINPUT_SOURCE_MOUSE);
823799}
824800
825801/* *
@@ -1528,20 +1504,8 @@ std::vector<sp<WindowInfoHandle>> InputDispatcher::DispatcherWindowInfo::findTou
15281504 const WindowInfo& info = *windowHandle->getInfo ();
15291505 if (!windowAcceptsTouchAt (info, displayId, x, y, isStylus,
15301506 getDisplayTransform (displayId))) {
1531- // Generally, we would skip any pointer that's outside of the window. However, if the
1532- // spy prevents splitting, and already has some of the pointers from this device, then
1533- // it should get more pointers from the same device, even if they are outside of that
1534- // window
1535- if (info.supportsSplitTouch ()) {
1536- continue ;
1537- }
1538-
1539- // We know that split touch is not supported. Skip this window only if it doesn't have
1540- // any touching pointers for this device already.
1541- if (!windowHasTouchingPointers (windowHandle, deviceId, touchStatesByDisplay)) {
1542- continue ;
1543- }
1544- // If it already has pointers down for this device, then give it this pointer, too.
1507+ // Skip if the pointer is outside of the window.
1508+ continue ;
15451509 }
15461510 if (!info.isSpy ()) {
15471511 // The first touched non-spy window was found, so return the spy windows touched so far.
@@ -2448,7 +2412,7 @@ InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime, const Motio
24482412 tempTouchState = *oldState;
24492413 }
24502414
2451- bool isSplit = shouldSplitTouch (tempTouchState, entry);
2415+ bool isSplit = shouldSplitTouch (entry. source );
24522416
24532417 const bool isHoverAction = (maskedAction == AMOTION_EVENT_ACTION_HOVER_MOVE ||
24542418 maskedAction == AMOTION_EVENT_ACTION_HOVER_ENTER ||
@@ -2501,42 +2465,14 @@ InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime, const Motio
25012465 LOG_IF (INFO, newTouchedWindowHandle == nullptr )
25022466 << " No new touched window at (" << std::format (" {:.1f}, {:.1f}" , x, y)
25032467 << " ) in display " << displayId;
2504- // Handle the case where we did not find a window.
2505- if (!input_flags::split_all_touches ()) {
2506- // If we are force splitting all touches, then touches outside of the window should
2507- // be dropped, even if this device already has pointers down in another window.
2508- if (newTouchedWindowHandle == nullptr ) {
2509- // Try to assign the pointer to the first foreground window we find, if there is
2510- // one.
2511- newTouchedWindowHandle =
2512- tempTouchState.getFirstForegroundWindowHandle (entry.deviceId );
2513- }
2514- }
25152468
25162469 // Verify targeted injection.
25172470 if (const auto err = verifyTargetedInjection (newTouchedWindowHandle, entry); err) {
25182471 ALOGW (" Dropping injected touch event: %s" , (*err).c_str ());
25192472 return injectionError (InputEventInjectionResult::TARGET_MISMATCH);
25202473 }
25212474
2522- // Figure out whether splitting will be allowed for this window.
2523- if (newTouchedWindowHandle != nullptr ) {
2524- if (newTouchedWindowHandle->getInfo ()->supportsSplitTouch ()) {
2525- // New window supports splitting, but we should never split mouse events.
2526- isSplit = !isFromMouse;
2527- } else if (isSplit) {
2528- // New window does not support splitting but we have already split events.
2529- // Ignore the new window.
2530- LOG (INFO) << " Skipping " << newTouchedWindowHandle->getName ()
2531- << " because it doesn't support split touch" ;
2532- newTouchedWindowHandle = nullptr ;
2533- }
2534- } else {
2535- // No window is touched, so set split to true. This will allow the next pointer down to
2536- // be delivered to a new window which supports split touch. Pointers from a mouse device
2537- // should never be split.
2538- isSplit = !isFromMouse;
2539- }
2475+ isSplit = !isFromMouse;
25402476
25412477 std::vector<sp<WindowInfoHandle>> newTouchedWindows =
25422478 mWindowInfos .findTouchedSpyWindowsAt (displayId, x, y, isStylus, entry.deviceId ,
@@ -2711,9 +2647,7 @@ InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime, const Motio
27112647 targets);
27122648
27132649 // Make a slippery entrance into the new window.
2714- if (newTouchedWindowHandle->getInfo ()->supportsSplitTouch ()) {
2715- isSplit = !isFromMouse;
2716- }
2650+ isSplit = !isFromMouse;
27172651
27182652 ftl::Flags<InputTarget::Flags> targetFlags;
27192653 if (canReceiveForegroundTouches (*newTouchedWindowHandle->getInfo ())) {
@@ -5835,18 +5769,6 @@ InputDispatcher::findTouchStateWindowAndDisplay(
58355769 const_cast <TouchedWindow*>(constTouchedWindow), displayId);
58365770}
58375771
5838- bool InputDispatcher::windowHasTouchingPointers (
5839- const sp<WindowInfoHandle>& windowHandle, DeviceId deviceId,
5840- const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay) {
5841- const auto & [touchState, touchedWindow, _] =
5842- findTouchStateWindowAndDisplay (windowHandle->getToken (), touchStatesByDisplay);
5843- if (touchState == nullptr ) {
5844- // No touching pointers at all
5845- return false ;
5846- }
5847- return touchState->hasTouchingPointers (deviceId);
5848- }
5849-
58505772bool InputDispatcher::transferTouchGesture (const sp<IBinder>& fromToken, const sp<IBinder>& toToken,
58515773 bool isDragDrop) {
58525774 if (fromToken == toToken) {
@@ -7168,13 +7090,6 @@ void InputDispatcher::onWindowInfosChanged(const gui::WindowInfosUpdate& update)
71687090 for (const auto & info : update.windowInfos ) {
71697091 handlesPerDisplay.emplace (info.displayId , std::vector<sp<WindowInfoHandle>>());
71707092 handlesPerDisplay[info.displayId ].push_back (sp<WindowInfoHandle>::make (info));
7171- if (input_flags::split_all_touches ()) {
7172- handlesPerDisplay[info.displayId ]
7173- .back ()
7174- ->editInfo ()
7175- ->setInputConfig (android::gui::WindowInfo::InputConfig::PREVENT_SPLITTING,
7176- false );
7177- }
71787093 }
71797094
71807095 { // acquire lock
0 commit comments