winit_wayland/event_loop/
proxy.rs

1//! An event loop proxy.
2
3use std::sync::Arc;
4
5use sctk::reexports::calloop::ping::Ping;
6use winit_core::event_loop::{EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider};
7
8/// A handle that can be sent across the threads and used to wake up the `EventLoop`.
9#[derive(Debug)]
10pub struct EventLoopProxy {
11    ping: Ping,
12}
13
14impl EventLoopProxyProvider for EventLoopProxy {
15    fn wake_up(&self) {
16        self.ping.ping();
17    }
18}
19
20impl EventLoopProxy {
21    pub fn new(ping: Ping) -> Self {
22        Self { ping }
23    }
24}
25
26impl From<EventLoopProxy> for CoreEventLoopProxy {
27    fn from(value: EventLoopProxy) -> Self {
28        CoreEventLoopProxy::new(Arc::new(value))
29    }
30}