diff --git a/CHANGELOG.md b/CHANGELOG.md index 282a8dd6..b6d84a55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,8 @@ - On X11, prevent stealing input focus when creating a new window. Only steal input focus when entering fullscreen mode. - On Wayland, add support for set_cursor_visible and set_cursor_grab. -- On Wayland, fixed DeviceEvents for relative mouse movement is not always produced +- On Wayland, fixed DeviceEvents for relative mouse movement is not always produced. +- Removed `derivative` crate dependency. - On Wayland, add support for set_cursor_icon. # 0.20.0 Alpha 3 (2019-08-14) diff --git a/Cargo.toml b/Cargo.toml index 3e8161db..5720ae7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ lazy_static = "1" libc = "0.2" log = "0.4" serde = { version = "1", optional = true, features = ["serde_derive"] } -derivative = "1.0.2" raw-window-handle = "0.2" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 4a85a2ca..ba8e910f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -121,8 +121,6 @@ extern crate log; #[macro_use] extern crate serde; #[macro_use] -extern crate derivative; -#[macro_use] #[cfg(any(target_os = "ios", target_os = "windows"))] extern crate bitflags; #[cfg(any(target_os = "macos", target_os = "ios"))] diff --git a/src/monitor.rs b/src/monitor.rs index 8e085a58..106c3e52 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -52,12 +52,17 @@ impl Iterator for AvailableMonitorsIter { /// - [`MonitorHandle::video_modes`][monitor_get]. /// /// [monitor_get]: ../monitor/struct.MonitorHandle.html#method.video_modes -#[derive(Derivative)] -#[derivative(Clone, Debug = "transparent", PartialEq, Eq, Hash)] +#[derive(Clone, PartialEq, Eq, Hash)] pub struct VideoMode { pub(crate) video_mode: platform_impl::VideoMode, } +impl std::fmt::Debug for VideoMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.video_mode.fmt(f) + } +} + impl PartialOrd for VideoMode { fn partial_cmp(&self, other: &VideoMode) -> Option { Some(self.cmp(other)) diff --git a/src/platform_impl/macos/monitor.rs b/src/platform_impl/macos/monitor.rs index c9408890..7688e31a 100644 --- a/src/platform_impl/macos/monitor.rs +++ b/src/platform_impl/macos/monitor.rs @@ -22,17 +22,46 @@ use core_video_sys::{ CVDisplayLinkGetNominalOutputVideoRefreshPeriod, CVDisplayLinkRelease, }; -#[derive(Derivative)] -#[derivative(Debug, Clone, PartialEq, Hash)] +#[derive(Clone)] pub struct VideoMode { pub(crate) size: (u32, u32), pub(crate) bit_depth: u16, pub(crate) refresh_rate: u16, pub(crate) monitor: MonitorHandle, - #[derivative(Debug = "ignore", PartialEq = "ignore", Hash = "ignore")] pub(crate) native_mode: NativeDisplayMode, } +impl PartialEq for VideoMode { + fn eq(&self, other: &Self) -> bool { + self.size == other.size + && self.bit_depth == other.bit_depth + && self.refresh_rate == other.refresh_rate + && self.monitor == other.monitor + } +} + +impl Eq for VideoMode {} + +impl std::hash::Hash for VideoMode { + fn hash(&self, state: &mut H) { + self.size.hash(state); + self.bit_depth.hash(state); + self.refresh_rate.hash(state); + self.monitor.hash(state); + } +} + +impl std::fmt::Debug for VideoMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("VideoMode") + .field("size", &self.size) + .field("bit_depth", &self.bit_depth) + .field("refresh_rate", &self.refresh_rate) + .field("monitor", &self.monitor) + .finish() + } +} + pub struct NativeDisplayMode(pub ffi::CGDisplayModeRef); unsafe impl Send for NativeDisplayMode {} diff --git a/src/platform_impl/windows/monitor.rs b/src/platform_impl/windows/monitor.rs index cc2e1646..6705f334 100644 --- a/src/platform_impl/windows/monitor.rs +++ b/src/platform_impl/windows/monitor.rs @@ -21,17 +21,46 @@ use crate::{ }, }; -#[derive(Derivative)] -#[derivative(Debug, Clone, Eq, PartialEq, Hash)] +#[derive(Clone)] pub struct VideoMode { pub(crate) size: (u32, u32), pub(crate) bit_depth: u16, pub(crate) refresh_rate: u16, pub(crate) monitor: MonitorHandle, - #[derivative(Debug = "ignore", PartialEq = "ignore", Hash = "ignore")] pub(crate) native_video_mode: wingdi::DEVMODEW, } +impl PartialEq for VideoMode { + fn eq(&self, other: &Self) -> bool { + self.size == other.size + && self.bit_depth == other.bit_depth + && self.refresh_rate == other.refresh_rate + && self.monitor == other.monitor + } +} + +impl Eq for VideoMode {} + +impl std::hash::Hash for VideoMode { + fn hash(&self, state: &mut H) { + self.size.hash(state); + self.bit_depth.hash(state); + self.refresh_rate.hash(state); + self.monitor.hash(state); + } +} + +impl std::fmt::Debug for VideoMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("VideoMode") + .field("size", &self.size) + .field("bit_depth", &self.bit_depth) + .field("refresh_rate", &self.refresh_rate) + .field("monitor", &self.monitor) + .finish() + } +} + impl VideoMode { pub fn size(&self) -> PhysicalSize { self.size.into()