diff --git a/CHANGELOG.md b/CHANGELOG.md index ee30e9c9..d68f064d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - On iOS, add support for deferring system gestures. - On iOS, fix a crash that occurred while acquiring a monitor's name. - On iOS, fix armv7-apple-ios compile target. +- Removed the `T: Clone` requirement from the `Clone` impl of `EventLoopProxy`. # 0.20.0 Alpha 2 (2019-07-09) diff --git a/src/event_loop.rs b/src/event_loop.rs index a7a1134c..a2d90d3e 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -173,11 +173,18 @@ impl Deref for EventLoop { } /// Used to send custom events to `EventLoop`. -#[derive(Clone)] pub struct EventLoopProxy { event_loop_proxy: platform_impl::EventLoopProxy, } +impl Clone for EventLoopProxy { + fn clone(&self) -> Self { + Self { + event_loop_proxy: self.event_loop_proxy.clone(), + } + } +} + impl EventLoopProxy { /// 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 diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index bd2656ed..93238d60 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -479,12 +479,20 @@ pub enum EventLoop { X(x11::EventLoop), } -#[derive(Clone)] pub enum EventLoopProxy { X(x11::EventLoopProxy), Wayland(wayland::EventLoopProxy), } +impl Clone for EventLoopProxy { + fn clone(&self) -> Self { + match self { + EventLoopProxy::X(proxy) => EventLoopProxy::X(proxy.clone()), + EventLoopProxy::Wayland(proxy) => EventLoopProxy::Wayland(proxy.clone()), + } + } +} + impl EventLoop { pub fn new() -> EventLoop { if let Ok(env_var) = env::var(BACKEND_PREFERENCE_ENV_VAR) { diff --git a/src/platform_impl/linux/wayland/event_loop.rs b/src/platform_impl/linux/wayland/event_loop.rs index 2cdfb168..8c4cfa65 100644 --- a/src/platform_impl/linux/wayland/event_loop.rs +++ b/src/platform_impl/linux/wayland/event_loop.rs @@ -90,7 +90,6 @@ pub struct 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. -#[derive(Clone)] pub struct EventLoopProxy { user_sender: ::calloop::channel::Sender, } @@ -111,6 +110,14 @@ pub struct EventLoopWindowTarget { _marker: ::std::marker::PhantomData, } +impl Clone for EventLoopProxy { + fn clone(&self) -> Self { + EventLoopProxy { + user_sender: self.user_sender.clone(), + } + } +} + impl EventLoopProxy { pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> { self.user_sender.send(event).map_err(|_| EventLoopClosed) diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 345ebeeb..b239c571 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -66,11 +66,18 @@ pub struct EventLoop { target: Rc>, } -#[derive(Clone)] pub struct EventLoopProxy { user_sender: ::calloop::channel::Sender, } +impl Clone for EventLoopProxy { + fn clone(&self) -> Self { + EventLoopProxy { + user_sender: self.user_sender.clone(), + } + } +} + impl EventLoop { pub fn new(xconn: Arc) -> EventLoop { let root = unsafe { (xconn.xlib.XDefaultRootWindow)(xconn.display) }; diff --git a/src/platform_impl/macos/event_loop.rs b/src/platform_impl/macos/event_loop.rs index 1631daa8..32d8739c 100644 --- a/src/platform_impl/macos/event_loop.rs +++ b/src/platform_impl/macos/event_loop.rs @@ -108,7 +108,6 @@ impl EventLoop { } } -#[derive(Clone)] pub struct Proxy { sender: mpsc::Sender, source: CFRunLoopSourceRef, @@ -117,6 +116,12 @@ pub struct Proxy { unsafe impl Send for Proxy {} unsafe impl Sync for Proxy {} +impl Clone for Proxy { + fn clone(&self) -> Self { + Proxy::new(self.sender.clone()) + } +} + impl Proxy { fn new(sender: mpsc::Sender) -> Self { unsafe { diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index c84716f7..3b1052cf 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -678,13 +678,21 @@ impl EventLoopThreadExecutor { type ThreadExecFn = Box>; -#[derive(Clone)] pub struct EventLoopProxy { target_window: HWND, event_send: Sender, } unsafe impl Send for EventLoopProxy {} +impl Clone for EventLoopProxy { + fn clone(&self) -> Self { + Self { + target_window: self.target_window, + event_send: self.event_send.clone(), + } + } +} + impl EventLoopProxy { pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> { unsafe {