mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
The proxy is intended to be Clone, thus use `Arc` for it internally and don't require backends for it to be `Clone`. Use `EventLoopProxyProvider` to hide the backend's proxy implementation details. Co-authored-by: daxpedda <daxpedda@gmail.com>
31 lines
662 B
Rust
31 lines
662 B
Rust
//! An event loop proxy.
|
|
|
|
use std::sync::Arc;
|
|
|
|
use sctk::reexports::calloop::ping::Ping;
|
|
|
|
use crate::event_loop::{EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider};
|
|
|
|
/// A handle that can be sent across the threads and used to wake up the `EventLoop`.
|
|
pub struct EventLoopProxy {
|
|
ping: Ping,
|
|
}
|
|
|
|
impl EventLoopProxyProvider for EventLoopProxy {
|
|
fn wake_up(&self) {
|
|
self.ping.ping();
|
|
}
|
|
}
|
|
|
|
impl EventLoopProxy {
|
|
pub fn new(ping: Ping) -> Self {
|
|
Self { ping }
|
|
}
|
|
}
|
|
|
|
impl From<EventLoopProxy> for CoreEventLoopProxy {
|
|
fn from(value: EventLoopProxy) -> Self {
|
|
CoreEventLoopProxy::new(Arc::new(value))
|
|
}
|
|
}
|