Remove generic parameter T from EventLoopWindowTarget (#3298)

This commit is contained in:
Mads Marquart 2024-01-13 21:36:53 +01:00 committed by GitHub
parent 169cd39f93
commit 22311802b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 174 additions and 210 deletions

View file

@ -27,6 +27,7 @@ use std::{
collections::{HashMap, HashSet},
ffi::CStr,
fmt,
marker::PhantomData,
mem::MaybeUninit,
ops::Deref,
os::{
@ -142,7 +143,7 @@ impl<T> PeekableReceiver<T> {
}
}
pub struct EventLoopWindowTarget<T> {
pub struct EventLoopWindowTarget {
xconn: Arc<XConnection>,
wm_delete_window: xproto::Atom,
net_wm_ping: xproto::Atom,
@ -155,19 +156,18 @@ pub struct EventLoopWindowTarget<T> {
redraw_sender: WakeSender<WindowId>,
activation_sender: WakeSender<ActivationToken>,
device_events: Cell<DeviceEvents>,
_marker: ::std::marker::PhantomData<T>,
}
pub struct EventLoop<T: 'static> {
loop_running: bool,
event_loop: Loop<'static, EventLoopState>,
waker: calloop::ping::Ping,
event_processor: EventProcessor<T>,
event_processor: EventProcessor,
redraw_receiver: PeekableReceiver<WindowId>,
user_receiver: PeekableReceiver<T>,
activation_receiver: PeekableReceiver<ActivationToken>,
user_sender: Sender<T>,
target: Rc<RootELW<T>>,
target: Rc<RootELW>,
/// The current state of the event loop.
state: EventLoopState,
@ -307,7 +307,6 @@ impl<T: 'static> EventLoop<T> {
control_flow: Cell::new(ControlFlow::default()),
exit: Cell::new(None),
windows: Default::default(),
_marker: ::std::marker::PhantomData,
ime_sender,
xconn,
wm_delete_window,
@ -328,7 +327,7 @@ impl<T: 'static> EventLoop<T> {
let target = Rc::new(RootELW {
p: super::EventLoopWindowTarget::X(window_target),
_marker: ::std::marker::PhantomData,
_marker: PhantomData,
});
let event_processor = EventProcessor {
@ -397,13 +396,13 @@ impl<T: 'static> EventLoop<T> {
}
}
pub(crate) fn window_target(&self) -> &RootELW<T> {
pub(crate) fn window_target(&self) -> &RootELW {
&self.target
}
pub fn run_on_demand<F>(&mut self, mut event_handler: F) -> Result<(), EventLoopError>
where
F: FnMut(Event<T>, &RootELW<T>),
F: FnMut(Event<T>, &RootELW),
{
if self.loop_running {
return Err(EventLoopError::AlreadyRunning);
@ -437,7 +436,7 @@ impl<T: 'static> EventLoop<T> {
pub fn pump_events<F>(&mut self, timeout: Option<Duration>, mut callback: F) -> PumpStatus
where
F: FnMut(Event<T>, &RootELW<T>),
F: FnMut(Event<T>, &RootELW),
{
if !self.loop_running {
self.loop_running = true;
@ -470,7 +469,7 @@ impl<T: 'static> EventLoop<T> {
pub fn poll_events_with_timeout<F>(&mut self, mut timeout: Option<Duration>, mut callback: F)
where
F: FnMut(Event<T>, &RootELW<T>),
F: FnMut(Event<T>, &RootELW),
{
let start = Instant::now();
@ -548,7 +547,7 @@ impl<T: 'static> EventLoop<T> {
fn single_iteration<F>(&mut self, callback: &mut F, cause: StartCause)
where
F: FnMut(Event<T>, &RootELW<T>),
F: FnMut(Event<T>, &RootELW),
{
callback(crate::event::Event::NewEvents(cause), &self.target);
@ -622,7 +621,7 @@ impl<T: 'static> EventLoop<T> {
fn drain_events<F>(&mut self, callback: &mut F)
where
F: FnMut(Event<T>, &RootELW<T>),
F: FnMut(Event<T>, &RootELW),
{
let target = &self.target;
let mut xev = MaybeUninit::uninit();
@ -673,7 +672,7 @@ impl<T> AsRawFd for EventLoop<T> {
}
}
pub(crate) fn get_xtarget<T>(target: &RootELW<T>) -> &EventLoopWindowTarget<T> {
pub(crate) fn get_xtarget(target: &RootELW) -> &EventLoopWindowTarget {
match target.p {
super::EventLoopWindowTarget::X(ref target) => target,
#[cfg(wayland_platform)]
@ -681,7 +680,7 @@ pub(crate) fn get_xtarget<T>(target: &RootELW<T>) -> &EventLoopWindowTarget<T> {
}
}
impl<T> EventLoopWindowTarget<T> {
impl EventLoopWindowTarget {
/// Returns the `XConnection` of this events loop.
#[inline]
pub(crate) fn x_connection(&self) -> &Arc<XConnection> {
@ -840,8 +839,8 @@ impl Deref for Window {
}
impl Window {
pub(crate) fn new<T>(
event_loop: &EventLoopWindowTarget<T>,
pub(crate) fn new(
event_loop: &EventLoopWindowTarget,
attribs: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes,
) -> Result<Self, RootOsError> {