Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

介绍下事件的传递流程 #156

Open
tbfungeek opened this issue Feb 19, 2020 · 0 comments
Open

介绍下事件的传递流程 #156

tbfungeek opened this issue Feb 19, 2020 · 0 comments

Comments

@tbfungeek
Copy link
Owner

tbfungeek commented Feb 19, 2020

当一个事件产生的时候,事件会在底层由IOKit.framework 封装成IOHIDEvent对象。然后系统通过mach port将IOHIDEvent对象转发给SpringBoard.app。 SpringBoard.app 它有点像Android中的lancher,只接收按钮,触摸,加速等事件,SpringBoard会根据当前桌面的状态,判断应该由谁处理此次触摸事件.可能在事件产生的时候你在桌面翻页并没有应用在前台运行,这时候触发SpringBoard本身主线程runloop的source0事件源的回调,将事件交由桌面系统去消耗,如果有应用在前台运行那么会通过mach port 将IOHIDEvent 转发给对应的App.App主线程的RunLoop收到SpringBoard转发的消息后,触发Source1回调__IOHIDEventSystemClientQueueCallback。在这个方法中会触发Source0回调__UIApplicationHandleEventQueue,将IOHIDEvent转换为UIEvent.并通过UIApplication的sendEvent:方法将UIEvent传递给UIWindow.紧接着就是通过Hiting-Test查找最佳的响应者,然后将事件传递给它,进行事件处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant