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
|
|
@ -4,6 +4,7 @@ use std::{
|
|||
cell::Cell,
|
||||
collections::VecDeque,
|
||||
hash::Hash,
|
||||
marker::PhantomData,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
mpsc, Arc, Mutex, RwLock,
|
||||
|
|
@ -140,7 +141,7 @@ pub struct KeyEventExtra {}
|
|||
|
||||
pub struct EventLoop<T: 'static> {
|
||||
android_app: AndroidApp,
|
||||
window_target: event_loop::EventLoopWindowTarget<T>,
|
||||
window_target: event_loop::EventLoopWindowTarget,
|
||||
redraw_flag: SharedFlag,
|
||||
user_events_sender: mpsc::Sender<T>,
|
||||
user_events_receiver: PeekableReceiver<T>, //must wake looper whenever something gets sent
|
||||
|
|
@ -187,9 +188,8 @@ impl<T: 'static> EventLoop<T> {
|
|||
&redraw_flag,
|
||||
android_app.create_waker(),
|
||||
),
|
||||
_marker: std::marker::PhantomData,
|
||||
},
|
||||
_marker: std::marker::PhantomData,
|
||||
_marker: PhantomData,
|
||||
},
|
||||
redraw_flag,
|
||||
user_events_sender,
|
||||
|
|
@ -205,7 +205,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
fn single_iteration<F>(&mut self, main_event: Option<MainEvent<'_>>, callback: &mut F)
|
||||
where
|
||||
F: FnMut(event::Event<T>, &RootELW<T>),
|
||||
F: FnMut(event::Event<T>, &RootELW),
|
||||
{
|
||||
trace!("Mainloop iteration");
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
callback: &mut F,
|
||||
) -> InputStatus
|
||||
where
|
||||
F: FnMut(event::Event<T>, &RootELW<T>),
|
||||
F: FnMut(event::Event<T>, &RootELW),
|
||||
{
|
||||
let mut input_status = InputStatus::Handled;
|
||||
match event {
|
||||
|
|
@ -482,14 +482,14 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
pub fn run<F>(mut self, event_handler: F) -> Result<(), EventLoopError>
|
||||
where
|
||||
F: FnMut(event::Event<T>, &event_loop::EventLoopWindowTarget<T>),
|
||||
F: FnMut(event::Event<T>, &event_loop::EventLoopWindowTarget),
|
||||
{
|
||||
self.run_on_demand(event_handler)
|
||||
}
|
||||
|
||||
pub fn run_on_demand<F>(&mut self, mut event_handler: F) -> Result<(), EventLoopError>
|
||||
where
|
||||
F: FnMut(event::Event<T>, &event_loop::EventLoopWindowTarget<T>),
|
||||
F: FnMut(event::Event<T>, &event_loop::EventLoopWindowTarget),
|
||||
{
|
||||
if self.loop_running {
|
||||
return Err(EventLoopError::AlreadyRunning);
|
||||
|
|
@ -512,7 +512,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
pub fn pump_events<F>(&mut self, timeout: Option<Duration>, mut callback: F) -> PumpStatus
|
||||
where
|
||||
F: FnMut(event::Event<T>, &RootELW<T>),
|
||||
F: FnMut(event::Event<T>, &RootELW),
|
||||
{
|
||||
if !self.loop_running {
|
||||
self.loop_running = true;
|
||||
|
|
@ -545,7 +545,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
fn poll_events_with_timeout<F>(&mut self, mut timeout: Option<Duration>, mut callback: F)
|
||||
where
|
||||
F: FnMut(event::Event<T>, &RootELW<T>),
|
||||
F: FnMut(event::Event<T>, &RootELW),
|
||||
{
|
||||
let start = Instant::now();
|
||||
|
||||
|
|
@ -621,7 +621,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn window_target(&self) -> &event_loop::EventLoopWindowTarget<T> {
|
||||
pub fn window_target(&self) -> &event_loop::EventLoopWindowTarget {
|
||||
&self.window_target
|
||||
}
|
||||
|
||||
|
|
@ -665,15 +665,14 @@ impl<T> EventLoopProxy<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct EventLoopWindowTarget<T: 'static> {
|
||||
pub struct EventLoopWindowTarget {
|
||||
app: AndroidApp,
|
||||
control_flow: Cell<ControlFlow>,
|
||||
exit: Cell<bool>,
|
||||
redraw_requester: RedrawRequester,
|
||||
_marker: std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: 'static> EventLoopWindowTarget<T> {
|
||||
impl EventLoopWindowTarget {
|
||||
pub fn primary_monitor(&self) -> Option<MonitorHandle> {
|
||||
Some(MonitorHandle::new(self.app.clone()))
|
||||
}
|
||||
|
|
@ -763,8 +762,8 @@ pub(crate) struct Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
pub(crate) fn new<T: 'static>(
|
||||
el: &EventLoopWindowTarget<T>,
|
||||
pub(crate) fn new(
|
||||
el: &EventLoopWindowTarget,
|
||||
_window_attrs: window::WindowAttributes,
|
||||
_: PlatformSpecificWindowBuilderAttributes,
|
||||
) -> Result<Self, error::OsError> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue