add: ActiveEventLoop::create_proxy()

Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
This commit is contained in:
daxpedda 2024-06-29 17:19:09 +02:00 committed by GitHub
parent 2e93e48a3b
commit a0d69c782a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 78 additions and 71 deletions

View file

@ -34,6 +34,10 @@ pub struct ActiveEventLoop {
}
impl ActiveEventLoop {
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy::new(AppState::get_mut(self.mtm).proxy_wake_up())
}
pub fn create_custom_cursor(&self, source: CustomCursorSource) -> CustomCursor {
let _ = source.inner;
CustomCursor { inner: super::PlatformCustomCursor }
@ -134,7 +138,6 @@ fn map_user_event<A: ApplicationHandler>(
pub struct EventLoop {
mtm: MainThreadMarker,
proxy_wake_up: Arc<AtomicBool>,
window_target: RootActiveEventLoop,
}
@ -160,11 +163,8 @@ impl EventLoop {
// this line sets up the main run loop before `UIApplicationMain`
setup_control_flow_observers();
let proxy_wake_up = Arc::new(AtomicBool::new(false));
Ok(EventLoop {
mtm,
proxy_wake_up,
window_target: RootActiveEventLoop { p: ActiveEventLoop { mtm }, _marker: PhantomData },
})
}
@ -179,7 +179,7 @@ impl EventLoop {
`EventLoop::run_app` calls `UIApplicationMain` on iOS",
);
let handler = map_user_event(app, self.proxy_wake_up.clone());
let handler = map_user_event(app, AppState::get_mut(self.mtm).proxy_wake_up());
let handler = unsafe {
std::mem::transmute::<
@ -212,10 +212,6 @@ impl EventLoop {
unreachable!()
}
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy::new(self.proxy_wake_up.clone())
}
pub fn window_target(&self) -> &RootActiveEventLoop {
&self.window_target
}