Remove generic parameter T from EventLoopWindowTarget (#3298)
This commit is contained in:
parent
169cd39f93
commit
22311802b5
37 changed files with 174 additions and 210 deletions
|
|
@ -34,12 +34,11 @@ use super::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EventLoopWindowTarget<T: 'static> {
|
||||
pub struct EventLoopWindowTarget {
|
||||
pub(super) mtm: MainThreadMarker,
|
||||
p: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: 'static> EventLoopWindowTarget<T> {
|
||||
impl EventLoopWindowTarget {
|
||||
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
|
||||
monitor::uiscreens(self.mtm)
|
||||
}
|
||||
|
|
@ -90,7 +89,7 @@ pub struct EventLoop<T: 'static> {
|
|||
mtm: MainThreadMarker,
|
||||
sender: Sender<T>,
|
||||
receiver: Receiver<T>,
|
||||
window_target: RootEventLoopWindowTarget<T>,
|
||||
window_target: RootEventLoopWindowTarget,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
@ -123,10 +122,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
sender,
|
||||
receiver,
|
||||
window_target: RootEventLoopWindowTarget {
|
||||
p: EventLoopWindowTarget {
|
||||
mtm,
|
||||
p: PhantomData,
|
||||
},
|
||||
p: EventLoopWindowTarget { mtm },
|
||||
_marker: PhantomData,
|
||||
},
|
||||
})
|
||||
|
|
@ -134,7 +130,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
pub fn run<F>(self, event_handler: F) -> !
|
||||
where
|
||||
F: FnMut(Event<T>, &RootEventLoopWindowTarget<T>),
|
||||
F: FnMut(Event<T>, &RootEventLoopWindowTarget),
|
||||
{
|
||||
unsafe {
|
||||
let application = UIApplication::shared(self.mtm);
|
||||
|
|
@ -146,7 +142,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
);
|
||||
|
||||
let event_handler = std::mem::transmute::<
|
||||
Box<dyn FnMut(Event<T>, &RootEventLoopWindowTarget<T>)>,
|
||||
Box<dyn FnMut(Event<T>, &RootEventLoopWindowTarget)>,
|
||||
Box<EventHandlerCallback<T>>,
|
||||
>(Box::new(event_handler));
|
||||
|
||||
|
|
@ -175,7 +171,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
EventLoopProxy::new(self.sender.clone())
|
||||
}
|
||||
|
||||
pub fn window_target(&self) -> &RootEventLoopWindowTarget<T> {
|
||||
pub fn window_target(&self) -> &RootEventLoopWindowTarget {
|
||||
&self.window_target
|
||||
}
|
||||
}
|
||||
|
|
@ -346,7 +342,7 @@ fn setup_control_flow_observers() {
|
|||
#[derive(Debug)]
|
||||
pub enum Never {}
|
||||
|
||||
type EventHandlerCallback<T> = dyn FnMut(Event<T>, &RootEventLoopWindowTarget<T>) + 'static;
|
||||
type EventHandlerCallback<T> = dyn FnMut(Event<T>, &RootEventLoopWindowTarget) + 'static;
|
||||
|
||||
pub trait EventHandler: Debug {
|
||||
fn handle_nonuser_event(&mut self, event: Event<Never>);
|
||||
|
|
@ -356,7 +352,7 @@ pub trait EventHandler: Debug {
|
|||
struct EventLoopHandler<T: 'static> {
|
||||
f: Box<EventHandlerCallback<T>>,
|
||||
receiver: Receiver<T>,
|
||||
event_loop: RootEventLoopWindowTarget<T>,
|
||||
event_loop: RootEventLoopWindowTarget,
|
||||
}
|
||||
|
||||
impl<T: 'static> Debug for EventLoopHandler<T> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue