mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Do not require T: Clone
for EventLoopProxy<T>: Clone
(#1086)
* Do not require `T: Clone` for `EventLoopProxy<T>: Clone` * Update `CHANGELOG.md` * Remove the conflicting `Clone` impl * Fix match statement
This commit is contained in:
parent
8a1c5277eb
commit
73cf10e4f3
|
@ -15,6 +15,7 @@
|
||||||
- On iOS, add support for deferring system gestures.
|
- On iOS, add support for deferring system gestures.
|
||||||
- On iOS, fix a crash that occurred while acquiring a monitor's name.
|
- On iOS, fix a crash that occurred while acquiring a monitor's name.
|
||||||
- On iOS, fix armv7-apple-ios compile target.
|
- On iOS, fix armv7-apple-ios compile target.
|
||||||
|
- Removed the `T: Clone` requirement from the `Clone` impl of `EventLoopProxy<T>`.
|
||||||
|
|
||||||
# 0.20.0 Alpha 2 (2019-07-09)
|
# 0.20.0 Alpha 2 (2019-07-09)
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,18 @@ impl<T> Deref for EventLoop<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to send custom events to `EventLoop`.
|
/// Used to send custom events to `EventLoop`.
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct EventLoopProxy<T: 'static> {
|
pub struct EventLoopProxy<T: 'static> {
|
||||||
event_loop_proxy: platform_impl::EventLoopProxy<T>,
|
event_loop_proxy: platform_impl::EventLoopProxy<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: 'static> Clone for EventLoopProxy<T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
event_loop_proxy: self.event_loop_proxy.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: 'static> EventLoopProxy<T> {
|
impl<T: 'static> EventLoopProxy<T> {
|
||||||
/// Send an event to the `EventLoop` from which this proxy was created. This emits a
|
/// Send an event to the `EventLoop` from which this proxy was created. This emits a
|
||||||
/// `UserEvent(event)` event in the event loop, where `event` is the value passed to this
|
/// `UserEvent(event)` event in the event loop, where `event` is the value passed to this
|
||||||
|
|
|
@ -479,12 +479,20 @@ pub enum EventLoop<T: 'static> {
|
||||||
X(x11::EventLoop<T>),
|
X(x11::EventLoop<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub enum EventLoopProxy<T: 'static> {
|
pub enum EventLoopProxy<T: 'static> {
|
||||||
X(x11::EventLoopProxy<T>),
|
X(x11::EventLoopProxy<T>),
|
||||||
Wayland(wayland::EventLoopProxy<T>),
|
Wayland(wayland::EventLoopProxy<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: 'static> Clone for EventLoopProxy<T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
match self {
|
||||||
|
EventLoopProxy::X(proxy) => EventLoopProxy::X(proxy.clone()),
|
||||||
|
EventLoopProxy::Wayland(proxy) => EventLoopProxy::Wayland(proxy.clone()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: 'static> EventLoop<T> {
|
impl<T: 'static> EventLoop<T> {
|
||||||
pub fn new() -> EventLoop<T> {
|
pub fn new() -> EventLoop<T> {
|
||||||
if let Ok(env_var) = env::var(BACKEND_PREFERENCE_ENV_VAR) {
|
if let Ok(env_var) = env::var(BACKEND_PREFERENCE_ENV_VAR) {
|
||||||
|
|
|
@ -90,7 +90,6 @@ pub struct EventLoop<T: 'static> {
|
||||||
// A handle that can be sent across threads and used to wake up the `EventLoop`.
|
// A handle that can be sent across threads and used to wake up the `EventLoop`.
|
||||||
//
|
//
|
||||||
// We should only try and wake up the `EventLoop` if it still exists, so we hold Weak ptrs.
|
// We should only try and wake up the `EventLoop` if it still exists, so we hold Weak ptrs.
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct EventLoopProxy<T: 'static> {
|
pub struct EventLoopProxy<T: 'static> {
|
||||||
user_sender: ::calloop::channel::Sender<T>,
|
user_sender: ::calloop::channel::Sender<T>,
|
||||||
}
|
}
|
||||||
|
@ -111,6 +110,14 @@ pub struct EventLoopWindowTarget<T> {
|
||||||
_marker: ::std::marker::PhantomData<T>,
|
_marker: ::std::marker::PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: 'static> Clone for EventLoopProxy<T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
EventLoopProxy {
|
||||||
|
user_sender: self.user_sender.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: 'static> EventLoopProxy<T> {
|
impl<T: 'static> EventLoopProxy<T> {
|
||||||
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> {
|
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> {
|
||||||
self.user_sender.send(event).map_err(|_| EventLoopClosed)
|
self.user_sender.send(event).map_err(|_| EventLoopClosed)
|
||||||
|
|
|
@ -66,11 +66,18 @@ pub struct EventLoop<T: 'static> {
|
||||||
target: Rc<RootELW<T>>,
|
target: Rc<RootELW<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct EventLoopProxy<T: 'static> {
|
pub struct EventLoopProxy<T: 'static> {
|
||||||
user_sender: ::calloop::channel::Sender<T>,
|
user_sender: ::calloop::channel::Sender<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: 'static> Clone for EventLoopProxy<T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
EventLoopProxy {
|
||||||
|
user_sender: self.user_sender.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: 'static> EventLoop<T> {
|
impl<T: 'static> EventLoop<T> {
|
||||||
pub fn new(xconn: Arc<XConnection>) -> EventLoop<T> {
|
pub fn new(xconn: Arc<XConnection>) -> EventLoop<T> {
|
||||||
let root = unsafe { (xconn.xlib.XDefaultRootWindow)(xconn.display) };
|
let root = unsafe { (xconn.xlib.XDefaultRootWindow)(xconn.display) };
|
||||||
|
|
|
@ -108,7 +108,6 @@ impl<T> EventLoop<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Proxy<T> {
|
pub struct Proxy<T> {
|
||||||
sender: mpsc::Sender<T>,
|
sender: mpsc::Sender<T>,
|
||||||
source: CFRunLoopSourceRef,
|
source: CFRunLoopSourceRef,
|
||||||
|
@ -117,6 +116,12 @@ pub struct Proxy<T> {
|
||||||
unsafe impl<T> Send for Proxy<T> {}
|
unsafe impl<T> Send for Proxy<T> {}
|
||||||
unsafe impl<T> Sync for Proxy<T> {}
|
unsafe impl<T> Sync for Proxy<T> {}
|
||||||
|
|
||||||
|
impl<T> Clone for Proxy<T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Proxy::new(self.sender.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Proxy<T> {
|
impl<T> Proxy<T> {
|
||||||
fn new(sender: mpsc::Sender<T>) -> Self {
|
fn new(sender: mpsc::Sender<T>) -> Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -678,13 +678,21 @@ impl EventLoopThreadExecutor {
|
||||||
|
|
||||||
type ThreadExecFn = Box<Box<dyn FnMut()>>;
|
type ThreadExecFn = Box<Box<dyn FnMut()>>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct EventLoopProxy<T: 'static> {
|
pub struct EventLoopProxy<T: 'static> {
|
||||||
target_window: HWND,
|
target_window: HWND,
|
||||||
event_send: Sender<T>,
|
event_send: Sender<T>,
|
||||||
}
|
}
|
||||||
unsafe impl<T: Send + 'static> Send for EventLoopProxy<T> {}
|
unsafe impl<T: Send + 'static> Send for EventLoopProxy<T> {}
|
||||||
|
|
||||||
|
impl<T: 'static> Clone for EventLoopProxy<T> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
target_window: self.target_window,
|
||||||
|
event_send: self.event_send.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: 'static> EventLoopProxy<T> {
|
impl<T: 'static> EventLoopProxy<T> {
|
||||||
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> {
|
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Reference in a new issue