InputDispatcher::dispatchMotionLocked中查询派发的窗口 findTouchedWindowTargetsLocked
派发的窗口确定后, 还会添加monitor窗口addMonitoringTargetsLocked(inputTargets);
此处addMonitoringTargetsLocked添加的channel就是WindowManagerService中创建的, 如下代码:
final InputChannel inputChannel = mInputManager.monitorInput(TAG_WM);
mPointerEventDispatcher = inputChannel != null ? new PointerEventDispatcher(inputChannel) : null;
最后派发的时候,通过for循环,按照inputTargets的顺序派发,
因为monitor是最后添加的, 所以是最后派发.
系统手势SystemGesturesPointerEventListener 注册到windowmanagerservice中,
最终注册到PointerEventDispatcher中, 而PointerEventDispatcher继承InputEventReceiver,
收到onInputEvent事件后,进行手势计算。
需求:
要接收到手势后, cancel掉画面的事件
方案:
画面动作是在up事件中进行才能cancel掉, 如果是在down中进行, 无法满足需求。
手势计算并派发后,补发一个cancel事件出来, 应用收到cancel事件,进行处理。