mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Remove T from EventLoopTargetWindow (#3081)
Co-authored-by: nerditation <12248559+nerditation@users.noreply.github.com>
This commit is contained in:
committed by
Kirill Chibisov
parent
cd5c1fb724
commit
84d9bfd59e
@@ -1,24 +1,30 @@
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
use super::runner;
|
||||
use crate::event::Event;
|
||||
use crate::event_loop::EventLoopClosed;
|
||||
use crate::platform_impl::platform::r#async::Channel;
|
||||
|
||||
pub struct EventLoopProxy<T: 'static> {
|
||||
runner: Channel<runner::Shared<T>, T>,
|
||||
// used to wake the event loop handler, not to actually pass data
|
||||
runner: Channel<runner::Shared, ()>,
|
||||
sender: Sender<T>,
|
||||
}
|
||||
|
||||
impl<T: 'static> EventLoopProxy<T> {
|
||||
pub fn new(runner: runner::Shared<T>) -> Self {
|
||||
pub fn new(runner: runner::Shared, sender: Sender<T>) -> Self {
|
||||
Self {
|
||||
runner: Channel::new(runner, |runner, event| {
|
||||
runner.send_event(Event::UserEvent(event))
|
||||
})
|
||||
.unwrap(),
|
||||
sender,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed<T>> {
|
||||
self.runner.send(event);
|
||||
self.sender.send(event).unwrap();
|
||||
self.runner.send(());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -27,6 +33,7 @@ impl<T: 'static> Clone for EventLoopProxy<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
runner: self.runner.clone(),
|
||||
sender: self.sender.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user