Loading services/inputflinger/dispatcher/CancelationOptions.h +2 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,8 @@ struct CancelationOptions { CANCEL_POINTER_EVENTS = 1, CANCEL_NON_POINTER_EVENTS = 2, CANCEL_FALLBACK_EVENTS = 3, ftl_last = CANCEL_FALLBACK_EVENTS, CANCEL_HOVER_EVENTS = 4, ftl_last = CANCEL_HOVER_EVENTS }; // The criterion to use to determine which events should be canceled. Loading services/inputflinger/dispatcher/InputDispatcher.cpp +31 −2 Original line number Diff line number Diff line Loading @@ -746,7 +746,8 @@ std::vector<TouchedWindow> getHoveringWindowsLocked(const TouchState* oldState, } touchedWindow.dispatchMode = InputTarget::DispatchMode::AS_IS; } touchedWindow.addHoveringPointer(entry.deviceId, pointer); const auto [x, y] = resolveTouchedPosition(entry); touchedWindow.addHoveringPointer(entry.deviceId, pointer, x, y); if (canReceiveForegroundTouches(*newWindow->getInfo())) { touchedWindow.targetFlags |= InputTarget::Flags::FOREGROUND; } Loading Loading @@ -873,6 +874,8 @@ std::pair<bool /*cancelPointers*/, bool /*cancelNonPointers*/> expandCancellatio return {false, true}; case CancelationOptions::Mode::CANCEL_FALLBACK_EVENTS: return {false, true}; case CancelationOptions::Mode::CANCEL_HOVER_EVENTS: return {true, false}; } } Loading Loading @@ -2511,7 +2514,8 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked( if (isHoverAction) { // The "windowHandle" is the target of this hovering pointer. tempTouchState.addHoveringPointerToWindow(windowHandle, entry.deviceId, pointer); tempTouchState.addHoveringPointerToWindow(windowHandle, entry.deviceId, pointer, x, y); } // Set target flags. Loading Loading @@ -5437,6 +5441,31 @@ void InputDispatcher::setInputWindowsLocked( } } // Check if the hovering should stop because the window is no longer eligible to receive it // (for example, if the touchable region changed) if (const auto& it = mTouchStatesByDisplay.find(displayId); it != mTouchStatesByDisplay.end()) { TouchState& state = it->second; for (TouchedWindow& touchedWindow : state.windows) { std::vector<DeviceId> erasedDevices = touchedWindow.eraseHoveringPointersIf( [this, displayId, &touchedWindow](const PointerProperties& properties, float x, float y) REQUIRES(mLock) { const bool isStylus = properties.toolType == ToolType::STYLUS; const ui::Transform displayTransform = getTransformLocked(displayId); const bool stillAcceptsTouch = windowAcceptsTouchAt(*touchedWindow.windowHandle->getInfo(), displayId, x, y, isStylus, displayTransform); return !stillAcceptsTouch; }); for (DeviceId deviceId : erasedDevices) { CancelationOptions options(CancelationOptions::Mode::CANCEL_HOVER_EVENTS, "WindowInfo changed", traceContext.getTracker()); options.deviceId = deviceId; synthesizeCancelationEventsForWindowLocked(touchedWindow.windowHandle, options); } } } // Release information for windows that are no longer present. // This ensures that unused input channels are released promptly. // Otherwise, they might stick around until the window handle is destroyed Loading services/inputflinger/dispatcher/InputState.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -638,6 +638,8 @@ bool InputState::shouldCancelMotion(const MotionMemento& memento, return memento.source & AINPUT_SOURCE_CLASS_POINTER; case CancelationOptions::Mode::CANCEL_NON_POINTER_EVENTS: return !(memento.source & AINPUT_SOURCE_CLASS_POINTER); case CancelationOptions::Mode::CANCEL_HOVER_EVENTS: return memento.hovering; default: return false; } Loading services/inputflinger/dispatcher/TouchState.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -112,17 +112,18 @@ android::base::Result<void> TouchState::addOrUpdateWindow( } void TouchState::addHoveringPointerToWindow(const sp<WindowInfoHandle>& windowHandle, DeviceId deviceId, const PointerProperties& pointer) { DeviceId deviceId, const PointerProperties& pointer, float x, float y) { for (TouchedWindow& touchedWindow : windows) { if (touchedWindow.windowHandle == windowHandle) { touchedWindow.addHoveringPointer(deviceId, pointer); touchedWindow.addHoveringPointer(deviceId, pointer, x, y); return; } } TouchedWindow touchedWindow; touchedWindow.windowHandle = windowHandle; touchedWindow.addHoveringPointer(deviceId, pointer); touchedWindow.addHoveringPointer(deviceId, pointer, x, y); windows.push_back(touchedWindow); } Loading services/inputflinger/dispatcher/TouchState.h +2 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ struct TouchState { DeviceId deviceId, const std::vector<PointerProperties>& touchingPointers, std::optional<nsecs_t> firstDownTimeInTarget = std::nullopt); void addHoveringPointerToWindow(const sp<android::gui::WindowInfoHandle>& windowHandle, DeviceId deviceId, const PointerProperties& pointer); DeviceId deviceId, const PointerProperties& pointer, float x, float y); void removeHoveringPointer(DeviceId deviceId, int32_t pointerId); void clearHoveringPointers(DeviceId deviceId); Loading Loading
services/inputflinger/dispatcher/CancelationOptions.h +2 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,8 @@ struct CancelationOptions { CANCEL_POINTER_EVENTS = 1, CANCEL_NON_POINTER_EVENTS = 2, CANCEL_FALLBACK_EVENTS = 3, ftl_last = CANCEL_FALLBACK_EVENTS, CANCEL_HOVER_EVENTS = 4, ftl_last = CANCEL_HOVER_EVENTS }; // The criterion to use to determine which events should be canceled. Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +31 −2 Original line number Diff line number Diff line Loading @@ -746,7 +746,8 @@ std::vector<TouchedWindow> getHoveringWindowsLocked(const TouchState* oldState, } touchedWindow.dispatchMode = InputTarget::DispatchMode::AS_IS; } touchedWindow.addHoveringPointer(entry.deviceId, pointer); const auto [x, y] = resolveTouchedPosition(entry); touchedWindow.addHoveringPointer(entry.deviceId, pointer, x, y); if (canReceiveForegroundTouches(*newWindow->getInfo())) { touchedWindow.targetFlags |= InputTarget::Flags::FOREGROUND; } Loading Loading @@ -873,6 +874,8 @@ std::pair<bool /*cancelPointers*/, bool /*cancelNonPointers*/> expandCancellatio return {false, true}; case CancelationOptions::Mode::CANCEL_FALLBACK_EVENTS: return {false, true}; case CancelationOptions::Mode::CANCEL_HOVER_EVENTS: return {true, false}; } } Loading Loading @@ -2511,7 +2514,8 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked( if (isHoverAction) { // The "windowHandle" is the target of this hovering pointer. tempTouchState.addHoveringPointerToWindow(windowHandle, entry.deviceId, pointer); tempTouchState.addHoveringPointerToWindow(windowHandle, entry.deviceId, pointer, x, y); } // Set target flags. Loading Loading @@ -5437,6 +5441,31 @@ void InputDispatcher::setInputWindowsLocked( } } // Check if the hovering should stop because the window is no longer eligible to receive it // (for example, if the touchable region changed) if (const auto& it = mTouchStatesByDisplay.find(displayId); it != mTouchStatesByDisplay.end()) { TouchState& state = it->second; for (TouchedWindow& touchedWindow : state.windows) { std::vector<DeviceId> erasedDevices = touchedWindow.eraseHoveringPointersIf( [this, displayId, &touchedWindow](const PointerProperties& properties, float x, float y) REQUIRES(mLock) { const bool isStylus = properties.toolType == ToolType::STYLUS; const ui::Transform displayTransform = getTransformLocked(displayId); const bool stillAcceptsTouch = windowAcceptsTouchAt(*touchedWindow.windowHandle->getInfo(), displayId, x, y, isStylus, displayTransform); return !stillAcceptsTouch; }); for (DeviceId deviceId : erasedDevices) { CancelationOptions options(CancelationOptions::Mode::CANCEL_HOVER_EVENTS, "WindowInfo changed", traceContext.getTracker()); options.deviceId = deviceId; synthesizeCancelationEventsForWindowLocked(touchedWindow.windowHandle, options); } } } // Release information for windows that are no longer present. // This ensures that unused input channels are released promptly. // Otherwise, they might stick around until the window handle is destroyed Loading
services/inputflinger/dispatcher/InputState.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -638,6 +638,8 @@ bool InputState::shouldCancelMotion(const MotionMemento& memento, return memento.source & AINPUT_SOURCE_CLASS_POINTER; case CancelationOptions::Mode::CANCEL_NON_POINTER_EVENTS: return !(memento.source & AINPUT_SOURCE_CLASS_POINTER); case CancelationOptions::Mode::CANCEL_HOVER_EVENTS: return memento.hovering; default: return false; } Loading
services/inputflinger/dispatcher/TouchState.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -112,17 +112,18 @@ android::base::Result<void> TouchState::addOrUpdateWindow( } void TouchState::addHoveringPointerToWindow(const sp<WindowInfoHandle>& windowHandle, DeviceId deviceId, const PointerProperties& pointer) { DeviceId deviceId, const PointerProperties& pointer, float x, float y) { for (TouchedWindow& touchedWindow : windows) { if (touchedWindow.windowHandle == windowHandle) { touchedWindow.addHoveringPointer(deviceId, pointer); touchedWindow.addHoveringPointer(deviceId, pointer, x, y); return; } } TouchedWindow touchedWindow; touchedWindow.windowHandle = windowHandle; touchedWindow.addHoveringPointer(deviceId, pointer); touchedWindow.addHoveringPointer(deviceId, pointer, x, y); windows.push_back(touchedWindow); } Loading
services/inputflinger/dispatcher/TouchState.h +2 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ struct TouchState { DeviceId deviceId, const std::vector<PointerProperties>& touchingPointers, std::optional<nsecs_t> firstDownTimeInTarget = std::nullopt); void addHoveringPointerToWindow(const sp<android::gui::WindowInfoHandle>& windowHandle, DeviceId deviceId, const PointerProperties& pointer); DeviceId deviceId, const PointerProperties& pointer, float x, float y); void removeHoveringPointer(DeviceId deviceId, int32_t pointerId); void clearHoveringPointers(DeviceId deviceId); Loading