diff --git a/src/backend/input.rs b/src/backend/input.rs index 24625d5..330aafe 100644 --- a/src/backend/input.rs +++ b/src/backend/input.rs @@ -87,6 +87,7 @@ pub trait Event { /// that is not used by an [`InputBackend`] implementation. Initialization is not /// possible, making accidental use impossible and enabling a lot of possible /// compiler optimizations. +#[derive(Debug)] pub enum UnusedEvent {} impl Event for UnusedEvent { @@ -537,6 +538,7 @@ pub trait InputBackend: Sized { } /// Different events that can be generated by an input backend +#[derive(Debug)] pub enum InputEvent { /// A new seat has been created NewSeat(Seat), diff --git a/src/backend/udev.rs b/src/backend/udev.rs index ffae665..45fe192 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -43,6 +43,7 @@ use nix::sys::stat::{dev_t, stat}; use std::{ collections::HashMap, ffi::OsString, + fmt, io::Result as IoResult, os::unix::io::{AsRawFd, RawFd}, path::{Path, PathBuf}, @@ -62,6 +63,17 @@ pub struct UdevBackend { logger: ::slog::Logger, } +impl fmt::Debug for UdevBackend { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use udev::AsRaw; + f.debug_struct("UdevBackend") + .field("devices", &self.devices) + .field("monitor", &format!("MonitorSocket ({:?})", self.monitor.as_raw())) + .field("logger", &self.logger) + .finish() + } +} + impl AsRawFd for UdevBackend { fn as_raw_fd(&self) -> RawFd { self.monitor.as_raw_fd() @@ -182,6 +194,7 @@ impl EventSource for UdevBackend { } /// Events generated by the [`UdevBackend`], notifying you of changes in system devices +#[derive(Debug)] pub enum UdevEvent { /// A new device has been detected Added { diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 9896cf7..995c6fd 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -16,6 +16,7 @@ use nix::libc::c_void; use std::{ cell::{Ref, RefCell}, convert::TryInto, + fmt, rc::Rc, time::Instant, }; @@ -65,6 +66,16 @@ enum Window { }, } +impl fmt::Debug for Window { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Window::Wayland { .. } => f.debug_tuple("Window::Wayland"), + Window::X11 { .. } => f.debug_tuple("Window::X11"), + } + .finish() + } +} + impl Window { fn window(&self) -> Ref<'_, WinitWindow> { match *self { @@ -74,6 +85,7 @@ impl Window { } } +#[derive(Debug)] struct WindowSize { physical_size: PhysicalSize, scale_factor: f64, @@ -81,6 +93,7 @@ struct WindowSize { /// Window with an active EGL Context created by `winit`. Implements the /// [`EGLGraphicsBackend`] and [`GLGraphicsBackend`] graphics backend trait +#[derive(Debug)] pub struct WinitGraphicsBackend { window: Rc, size: Rc>, @@ -91,6 +104,7 @@ pub struct WinitGraphicsBackend { /// /// You need to call [`dispatch_new_events`](InputBackend::dispatch_new_events) /// periodically to receive any events. +#[derive(Debug)] pub struct WinitInputBackend { events_loop: EventLoop<()>, window: Rc, @@ -226,6 +240,7 @@ where } /// Specific events generated by Winit +#[derive(Debug)] pub enum WinitEvent { /// The window has been resized Resized { @@ -358,8 +373,8 @@ pub enum WinitInputError { WindowClosed, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] /// Winit-Backend internal event wrapping `winit`'s types into a [`KeyboardKeyEvent`] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct WinitKeyboardInputEvent { time: u32, key: u32, @@ -387,8 +402,8 @@ impl KeyboardKeyEvent for WinitKeyboardInputEvent { } } -#[derive(Clone)] /// Winit-Backend internal event wrapping `winit`'s types into a [`PointerMotionAbsoluteEvent`] +#[derive(Debug, Clone)] pub struct WinitMouseMovedEvent { size: Rc>, time: u32, @@ -426,8 +441,8 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent { } } -#[derive(Debug, Clone, Copy, PartialEq)] /// Winit-Backend internal event wrapping `winit`'s types into a [`PointerAxisEvent`] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct WinitMouseWheelEvent { time: u32, delta: MouseScrollDelta, @@ -464,8 +479,8 @@ impl PointerAxisEvent for WinitMouseWheelEvent { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] /// Winit-Backend internal event wrapping `winit`'s types into a [`PointerButtonEvent`] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct WinitMouseInputEvent { time: u32, button: WinitMouseButton, @@ -488,8 +503,8 @@ impl PointerButtonEvent for WinitMouseInputEvent { } } -#[derive(Clone)] /// Winit-Backend internal event wrapping `winit`'s types into a [`TouchDownEvent`] +#[derive(Debug, Clone)] pub struct WinitTouchStartedEvent { size: Rc>, time: u32, @@ -531,8 +546,8 @@ impl TouchDownEvent for WinitTouchStartedEvent { } } -#[derive(Clone)] /// Winit-Backend internal event wrapping `winit`'s types into a [`TouchMotionEvent`] +#[derive(Debug, Clone)] pub struct WinitTouchMovedEvent { size: Rc>, time: u32, @@ -574,8 +589,8 @@ impl TouchMotionEvent for WinitTouchMovedEvent { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] /// Winit-Backend internal event wrapping `winit`'s types into a `TouchUpEvent` +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct WinitTouchEndedEvent { time: u32, id: u64, @@ -593,8 +608,8 @@ impl TouchUpEvent for WinitTouchEndedEvent { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] /// Winit-Backend internal event wrapping `winit`'s types into a [`TouchCancelEvent`] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct WinitTouchCancelledEvent { time: u32, id: u64, @@ -615,6 +630,7 @@ impl TouchCancelEvent for WinitTouchCancelledEvent { /// Input config for Winit /// /// This backend does not allow any input configuration, so this type does nothing. +#[derive(Debug)] pub struct WinitInputConfig; impl InputBackend for WinitInputBackend {