diff --git a/src/backend/drm/atomic/mod.rs b/src/backend/drm/atomic/mod.rs index 507abd3..38e2e71 100644 --- a/src/backend/drm/atomic/mod.rs +++ b/src/backend/drm/atomic/mod.rs @@ -20,6 +20,7 @@ use std::cell::RefCell; use std::collections::HashMap; +use std::fmt; use std::os::unix::io::{AsRawFd, RawFd}; use std::rc::Rc; use std::sync::{ @@ -59,6 +60,25 @@ pub struct AtomicDrmDevice { logger: ::slog::Logger, } +// DeviceHandler does not implement Debug, so we have to impl Debug manually +impl fmt::Debug for AtomicDrmDevice { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut debug = f.debug_struct("AtomicDrmDevice"); + + debug + .field("dev", &self.dev) + .field("dev_id", &self.dev_id) + .field("active", &self.active) + .field("backends", &self.backends) + .field("handler", &"..."); + + #[cfg(feature = "backend_session")] + debug.field("links", &self.links); + + debug.field("logger", &self.logger).finish() + } +} + type OldState = ( Vec<(connector::Handle, PropertyValueSet)>, Vec<(crtc::Handle, PropertyValueSet)>, @@ -73,6 +93,7 @@ type Mapping = ( HashMap>, ); +#[derive(Debug)] pub(in crate::backend::drm) struct Dev { fd: A, privileged: bool, diff --git a/src/backend/drm/atomic/session.rs b/src/backend/drm/atomic/session.rs index 5b7cfbc..d58e9ba 100644 --- a/src/backend/drm/atomic/session.rs +++ b/src/backend/drm/atomic/session.rs @@ -25,6 +25,7 @@ use crate::{ /// [`SessionObserver`](SessionObserver) /// linked to the [`AtomicDrmDevice`](AtomicDrmDevice) /// it was created from. +#[derive(Debug)] pub struct AtomicDrmDeviceObserver { dev: WeakArc>, dev_id: dev_t, diff --git a/src/backend/drm/atomic/surface.rs b/src/backend/drm/atomic/surface.rs index 96c08ef..9946858 100644 --- a/src/backend/drm/atomic/surface.rs +++ b/src/backend/drm/atomic/surface.rs @@ -36,6 +36,7 @@ pub struct Planes { pub cursor: plane::Handle, } +#[derive(Debug)] pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal { pub(super) dev: Arc>, pub(in crate::backend::drm) crtc: crtc::Handle, @@ -1003,6 +1004,7 @@ impl AtomicDrmSurfaceInternal { } /// Open raw crtc utilizing atomic mode-setting +#[derive(Debug)] pub struct AtomicDrmSurface( pub(in crate::backend::drm) Arc>, ); diff --git a/src/backend/drm/common/fallback.rs b/src/backend/drm/common/fallback.rs index c9d9f39..b853001 100644 --- a/src/backend/drm/common/fallback.rs +++ b/src/backend/drm/common/fallback.rs @@ -36,12 +36,14 @@ use drm::{ use nix::libc::c_void; use nix::libc::dev_t; use std::env; +use std::fmt; use std::os::unix::io::{AsRawFd, RawFd}; #[cfg(feature = "use_system_lib")] use wayland_server::Display; /// [`Device`](::backend::drm::Device) Wrapper to assist fallback /// in case initialization of the preferred device type fails. +#[derive(Debug)] pub enum FallbackDevice { /// Variant for successful initialization of the preferred device Preference(D1), @@ -129,6 +131,7 @@ where /// [`Surface`](::backend::drm::Surface) Wrapper to assist fallback /// in case initialization of the preferred device type fails. +#[derive(Debug)] pub enum FallbackSurface { /// Variant for successful initialization of the preferred device Preference(S1), diff --git a/src/backend/drm/egl/mod.rs b/src/backend/drm/egl/mod.rs index dac507f..36633ac 100644 --- a/src/backend/drm/egl/mod.rs +++ b/src/backend/drm/egl/mod.rs @@ -15,6 +15,7 @@ use drm::SystemError as DrmError; use nix::libc::dev_t; use std::cell::RefCell; use std::collections::HashMap; +use std::fmt; use std::os::unix::io::{AsRawFd, RawFd}; use std::rc::Rc; use std::sync::{Arc, Weak as WeakArc}; @@ -69,6 +70,32 @@ where links: Vec, } +// BackendRef does not implement debug, so we have to impl Debug manually +impl fmt::Debug for EglDevice +where + B: Backend::Surface, Error = <::Surface as Surface>::Error> + + fmt::Debug + + 'static, + D: Device + NativeDisplay + fmt::Debug + 'static, + ::Surface: NativeSurface::Surface as Surface>::Error>, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut debug = f.debug_struct("EglDevice"); + + debug + .field("dev", &self.dev) + .field("logger", &self.logger) + .field("default_attributes", &self.default_attributes) + .field("default_requirements", &self.default_requirements) + .field("backends", &"..."); + + #[cfg(feature = "backend_session")] + debug.field("links", &self.links); + + debug.finish() + } +} + impl AsRawFd for EglDevice where B: Backend::Surface, Error = <::Surface as Surface>::Error> diff --git a/src/backend/drm/egl/session.rs b/src/backend/drm/egl/session.rs index f8ab7ab..2465beb 100644 --- a/src/backend/drm/egl/session.rs +++ b/src/backend/drm/egl/session.rs @@ -23,6 +23,7 @@ use crate::{ /// [`SessionObserver`](SessionObserver) /// linked to the [`EglDevice`](EglDevice) it was /// created from. +#[derive(Debug)] pub struct EglDeviceObserver { backends: Weak>>>>, } diff --git a/src/backend/drm/egl/surface.rs b/src/backend/drm/egl/surface.rs index 2b852fb..4967300 100644 --- a/src/backend/drm/egl/surface.rs +++ b/src/backend/drm/egl/surface.rs @@ -14,8 +14,10 @@ use crate::backend::graphics::PixelFormat; use crate::backend::graphics::{CursorBackend, SwapBuffersError}; /// Egl surface for rendering +#[derive(Debug)] pub struct EglSurface(pub(super) Arc>); +#[derive(Debug)] pub(super) struct EglSurfaceInternal where N: native::NativeSurface + Surface, diff --git a/src/backend/drm/eglstream/egl.rs b/src/backend/drm/eglstream/egl.rs index 861e5e1..5e836a0 100644 --- a/src/backend/drm/eglstream/egl.rs +++ b/src/backend/drm/eglstream/egl.rs @@ -31,6 +31,7 @@ use std::sync::Arc; /// Egl Device backend type /// /// See [`Backend`](::backend::egl::native::Backend). +#[derive(Debug)] pub struct EglStreamDeviceBackend { _userdata: PhantomData, } diff --git a/src/backend/drm/eglstream/mod.rs b/src/backend/drm/eglstream/mod.rs index 69f759b..869127d 100644 --- a/src/backend/drm/eglstream/mod.rs +++ b/src/backend/drm/eglstream/mod.rs @@ -28,6 +28,7 @@ use nix::libc::dev_t; use std::cell::RefCell; use std::collections::HashMap; use std::ffi::CStr; +use std::fmt; use std::os::unix::fs::MetadataExt; use std::os::unix::io::{AsRawFd, RawFd}; use std::rc::{Rc, Weak}; @@ -90,6 +91,22 @@ pub struct EglStreamDevice { links: Vec, } +// SurfaceInternalRef does not implement debug, so we have to impl Debug manually +impl fmt::Debug for EglStreamDevice { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut debug = f.debug_struct("EglStreamDevice"); + debug + .field("dev", &self.dev) + .field("raw", &self.raw) + .field("backends", &"...") + .field("logger", &self.logger); + + #[cfg(feature = "backend_session")] + debug.field("links", &self.links); + debug.finish() + } +} + impl EglStreamDevice { /// Try to create a new [`EglStreamDevice`] from an open device. /// diff --git a/src/backend/drm/eglstream/session.rs b/src/backend/drm/eglstream/session.rs index a85cc5c..ca845cc 100644 --- a/src/backend/drm/eglstream/session.rs +++ b/src/backend/drm/eglstream/session.rs @@ -19,6 +19,7 @@ use drm::control::{crtc, Device as ControlDevice}; /// [`SessionObserver`](SessionObserver) /// linked to the [`EglStreamDevice`](EglStreamDevice) it was /// created from. +#[derive(Debug)] pub struct EglStreamDeviceObserver { backends: Weak>>>>, logger: ::slog::Logger, diff --git a/src/backend/drm/eglstream/surface.rs b/src/backend/drm/eglstream/surface.rs index 0d26d88..a7d86ea 100644 --- a/src/backend/drm/eglstream/surface.rs +++ b/src/backend/drm/eglstream/surface.rs @@ -30,10 +30,12 @@ use crate::backend::graphics::CursorBackend; // We do not want to mark the whole surface as `Send` in case we screw up somewhere else // and because S needs to be `Send` as well for this to work. +#[derive(Debug)] pub(super) struct StreamHandle(pub(super) EGLStreamKHR); // EGLStreamKHR can be moved between threads unsafe impl Send for StreamHandle {} +#[derive(Debug)] pub(in crate::backend::drm) struct EglStreamSurfaceInternal { pub(in crate::backend::drm) crtc: S, pub(in crate::backend::drm) cursor: Mutex>, @@ -205,6 +207,7 @@ impl CursorBackend for EglStreamSurfaceInternal { } /// egl stream surface for rendering +#[derive(Debug)] pub struct EglStreamSurface( pub(in crate::backend::drm) Arc>, ); diff --git a/src/backend/egl/context.rs b/src/backend/egl/context.rs index 9b16651..f62e14a 100644 --- a/src/backend/egl/context.rs +++ b/src/backend/egl/context.rs @@ -10,6 +10,7 @@ use std::ptr; use std::sync::{atomic::Ordering, Arc}; /// EGL context for rendering +#[derive(Debug)] pub struct EGLContext { context: ffi::egl::types::EGLContext, display: Arc, diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index 0e960cd..fc26adf 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -24,10 +24,12 @@ use std::ffi::CStr; use std::marker::PhantomData; use std::mem::MaybeUninit; +use std::fmt; use std::ops::Deref; /// Wrapper around [`ffi::EGLDisplay`](ffi::egl::types::EGLDisplay) to ensure display is only destroyed /// once all resources bound to it have been dropped. +#[derive(Debug)] pub struct EGLDisplayHandle { /// ffi EGLDisplay ptr pub handle: ffi::egl::types::EGLDisplay, @@ -54,6 +56,7 @@ impl Drop for EGLDisplayHandle { } /// [`EGLDisplay`] represents an initialised EGL environment +#[derive(Debug)] pub struct EGLDisplay> { native: RefCell, pub(crate) display: Arc, @@ -454,6 +457,17 @@ pub struct EGLBufferReader { gl: gl_ffi::Gles2, } +// Gles2 does not implement debug, so we have to impl Debug manually +#[cfg(feature = "use_system_lib")] +impl fmt::Debug for EGLBufferReader { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("EGLBufferReader") + .field("display", &self.display) + .field("wayland", &self.wayland) + .finish() + } +} + #[cfg(feature = "use_system_lib")] impl EGLBufferReader { fn new(display: Arc, wayland: *mut wl_display) -> Self { diff --git a/src/backend/egl/mod.rs b/src/backend/egl/mod.rs index 047bd64..a6d1ea3 100644 --- a/src/backend/egl/mod.rs +++ b/src/backend/egl/mod.rs @@ -269,6 +269,21 @@ pub struct EGLImages { gl: gl_ffi::Gles2, } +// Gles2 does not implement debug, so we have to impl Debug manually +#[cfg(feature = "wayland_frontend")] +impl fmt::Debug for EGLImages { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Point") + .field("display", &self.display) + .field("width", &self.width) + .field("height", &self.height) + .field("y_inverted", &self.y_inverted) + .field("format", &self.format) + .field("images", &self.images) + .finish() + } +} + #[cfg(feature = "wayland_frontend")] impl EGLImages { /// Amount of planes of these `EGLImages` diff --git a/src/backend/egl/native.rs b/src/backend/egl/native.rs index 8ffce1d..1864f78 100644 --- a/src/backend/egl/native.rs +++ b/src/backend/egl/native.rs @@ -35,6 +35,7 @@ pub trait Backend { } #[cfg(feature = "backend_winit")] +#[derive(Debug)] /// Wayland backend type pub enum Wayland {} #[cfg(feature = "backend_winit")] @@ -79,10 +80,12 @@ impl Backend for Wayland { } #[cfg(feature = "backend_winit")] +#[derive(Debug)] /// Typed Xlib window for the `X11` backend pub struct XlibWindow(u64); #[cfg(feature = "backend_winit")] /// X11 backend type +#[derive(Debug)] pub enum X11 {} #[cfg(feature = "backend_winit")] impl Backend for X11 { diff --git a/src/backend/egl/surface.rs b/src/backend/egl/surface.rs index 463f95d..3f4f1f0 100644 --- a/src/backend/egl/surface.rs +++ b/src/backend/egl/surface.rs @@ -11,6 +11,7 @@ use std::sync::{ }; /// EGL surface of a given EGL context for rendering +#[derive(Debug)] pub struct EGLSurface { pub(crate) display: Arc, native: N, diff --git a/src/backend/graphics/glium.rs b/src/backend/graphics/glium.rs index 4e04f93..96f2226 100644 --- a/src/backend/graphics/glium.rs +++ b/src/backend/graphics/glium.rs @@ -8,6 +8,7 @@ use glium::{ }; use std::{ cell::{Cell, Ref, RefCell, RefMut}, + fmt, os::raw::c_void, rc::Rc, }; @@ -22,6 +23,29 @@ pub struct GliumGraphicsBackend { error_channel: Rc>>>, } +// GLGraphicsBackend is a trait, so we have to impl Debug manually +impl fmt::Debug for GliumGraphicsBackend { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + struct BackendDebug<'a, T: GLGraphicsBackend>(&'a Rc>); + impl<'a, T: GLGraphicsBackend> fmt::Debug for BackendDebug<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let b = &self.0 .0.borrow(); + f.debug_struct("GLGraphicsBackend") + .field("framebuffer_dimensions", &b.get_framebuffer_dimensions()) + .field("is_current", &b.is_current()) + .field("pixel_format", &b.get_pixel_format()) + .finish() + } + } + + f.debug_struct("GliumGraphicsBackend") + .field("context", &"...") + .field("backend", &BackendDebug(&self.backend)) + .field("error_channel", &"...") + .finish() + } +} + struct InternalBackend(RefCell, Rc>>>); impl GliumGraphicsBackend { 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/libinput/mod.rs b/src/backend/libinput/mod.rs index f14364f..6559b08 100644 --- a/src/backend/libinput/mod.rs +++ b/src/backend/libinput/mod.rs @@ -16,6 +16,7 @@ use input::event; use std::path::Path; use std::{ collections::hash_map::HashMap, + fmt, io::Error as IoError, os::unix::io::{AsRawFd, RawFd}, }; @@ -32,6 +33,7 @@ const INPUT_MAJOR: u32 = 13; /// /// Tracks input of all devices given manually or via a udev seat to a provided libinput /// context. +#[derive(Debug)] pub struct LibinputInputBackend { context: libinput::Libinput, config: LibinputConfig, @@ -273,6 +275,7 @@ impl backend::Event for event::touch::TouchFrameEvent { impl backend::TouchFrameEvent for event::touch::TouchFrameEvent {} /// Special events generated by Libinput +#[derive(Debug)] pub enum LibinputEvent { /// A new device was plugged in NewDevice(libinput::Device), @@ -284,6 +287,7 @@ pub enum LibinputEvent { /// /// This type allows you to access the list of know devices to configure them /// if relevant +#[derive(Debug)] pub struct LibinputConfig { devices: Vec, } @@ -421,6 +425,7 @@ impl From for backend::MouseButtonState { /// Wrapper for types implementing the [`Session`] trait to provide /// a [`libinput::LibinputInterface`] implementation. #[cfg(feature = "backend_session")] +#[derive(Debug)] pub struct LibinputSessionInterface(S); #[cfg(feature = "backend_session")] diff --git a/src/backend/session/auto.rs b/src/backend/session/auto.rs index 289e83b..94ff4ae 100644 --- a/src/backend/session/auto.rs +++ b/src/backend/session/auto.rs @@ -44,7 +44,7 @@ use std::{cell::RefCell, io, os::unix::io::RawFd, path::Path, rc::Rc}; use calloop::{EventSource, Poll, Readiness, Token}; /// [`Session`] using the best available interface -#[derive(Clone)] +#[derive(Debug, Clone)] pub enum AutoSession { /// Logind session #[cfg(feature = "backend_session_logind")] @@ -54,6 +54,7 @@ pub enum AutoSession { } /// [`SessionNotifier`] using the best available interface +#[derive(Debug)] pub enum AutoSessionNotifier { /// Logind session notifier #[cfg(feature = "backend_session_logind")] diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index 44ff53d..f55fd07 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -49,6 +49,7 @@ use nix::{ }; use std::{ cell::RefCell, + fmt, io::Error as IoError, os::unix::io::RawFd, path::Path, @@ -70,15 +71,30 @@ struct LogindSessionImpl { logger: ::slog::Logger, } +// DBusConnection does not implement debug, so we have to impl Debug manually +impl fmt::Debug for LogindSessionImpl { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("LogindSessionImpl ") + .field("session_id", &self.session_id) + .field("conn", &"...") + .field("session_path", &self.session_path) + .field("active", &self.active) + .field("signaler", &self.signaler) + .field("seat", &self.seat) + .field("logger", &self.logger) + .finish() + } +} + /// [`Session`] via the logind dbus interface -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct LogindSession { internal: Weak, seat: String, } /// [`SessionNotifier`] via the logind dbus interface -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct LogindSessionNotifier { internal: Rc, } diff --git a/src/backend/session/direct.rs b/src/backend/session/direct.rs index 3eaae76..0c2a080 100644 --- a/src/backend/session/direct.rs +++ b/src/backend/session/direct.rs @@ -57,6 +57,7 @@ use nix::{ Error as NixError, Result as NixResult, }; use std::{ + fmt, os::unix::io::RawFd, path::Path, sync::{ @@ -142,6 +143,7 @@ fn is_tty_device(dev: dev_t, path: Option<&Path>) -> bool { } /// [`Session`] via the virtual terminal direct kernel interface +#[derive(Debug)] pub struct DirectSession { tty: RawFd, active: Arc, @@ -160,6 +162,26 @@ pub struct DirectSessionNotifier { source: Option, } +impl fmt::Debug for DirectSessionNotifier { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Point") + .field("tty", &self.tty) + .field("active", &self.active) + .field("signaler", &self.signaler) + .field("signal", &self.signal) + .field("logger", &self.logger) + // Signal deos not implement Debug` + .field( + "source", + &match self.source { + Some(_) => "Some(..)", + None => "None", + }, + ) + .finish() + } +} + impl DirectSession { /// Tries to create a new session via the legacy virtual terminal interface. /// diff --git a/src/backend/udev.rs b/src/backend/udev.rs index ffae665..2b6cab0 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,18 @@ pub struct UdevBackend { logger: ::slog::Logger, } +// MonitorSocket does not implement debug, so we have to impl Debug manually +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 +195,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..48e5d1c 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,30 @@ enum Window { }, } +// WlEglSurface does not implement debug, so we have to impl Debug manually +impl fmt::Debug for Window { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Window::Wayland { display, context, .. } => f + .debug_struct("Window::Wayland") + .field("display", &display) + .field("context", &context) + .field("surface", &"...") + .finish(), + Window::X11 { + display, + context, + surface, + } => f + .debug_struct("Window::X11") + .field("display", &display) + .field("context", &context) + .field("surface", &surface) + .finish(), + } + } +} + impl Window { fn window(&self) -> Ref<'_, WinitWindow> { match *self { @@ -74,6 +99,7 @@ impl Window { } } +#[derive(Debug)] struct WindowSize { physical_size: PhysicalSize, scale_factor: f64, @@ -81,6 +107,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 +118,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 +254,7 @@ where } /// Specific events generated by Winit +#[derive(Debug)] pub enum WinitEvent { /// The window has been resized Resized { @@ -358,8 +387,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 +416,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 +455,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 +493,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 +517,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 +560,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 +603,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 +622,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 +644,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 { diff --git a/src/signaling.rs b/src/signaling.rs index 6a12a2e..2e41121 100644 --- a/src/signaling.rs +++ b/src/signaling.rs @@ -21,10 +21,12 @@ use std::{ any::Any, cell::RefCell, collections::VecDeque, + fmt, rc::{Rc, Weak}, }; /// A signaler, main type for signaling +#[derive(Debug)] pub struct Signaler { inner: Rc>, } @@ -88,6 +90,7 @@ impl Default for Signaler { /// Dropping it will disable and drop the callback it is associated to. /// If you don't plan to ever disable the callback, you can use the `leak` /// method to safely get rid of this value. +#[derive(Debug)] pub struct SignalToken { signal: Rc, } @@ -108,6 +111,17 @@ struct SignalInner { pending_events: RefCell>, } +// WeakCallback does not implement debug, so we have to impl Debug manually +impl fmt::Debug for SignalInner { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SignalInner") + .field("callbacks::len()", &self.callbacks.borrow().len()) + .field("pending_callbacks::len()", &self.pending_callbacks.borrow().len()) + .field("pending_events", &self.pending_events) + .finish() + } +} + impl SignalInner { fn new() -> SignalInner { SignalInner { diff --git a/src/utils/signaling.rs b/src/utils/signaling.rs index c88d921..28c925b 100644 --- a/src/utils/signaling.rs +++ b/src/utils/signaling.rs @@ -1,5 +1,6 @@ use std::{rc::Rc, cell::RefCell}; +#[derive(Debug)] struct SignalerInner { closures: RefCell>> } @@ -12,6 +13,7 @@ impl SignalerInner { } } +#[derive(Debug)] pub struct Signaler { inner: Rc> } diff --git a/src/wayland/compositor/mod.rs b/src/wayland/compositor/mod.rs index 43aeca7..a1d419c 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -68,7 +68,7 @@ //! surfaces. See the documentation of the [`roles`](::wayland::compositor::roles) submodule //! for a detailed explanation. -use std::{cell::RefCell, rc::Rc, sync::Mutex}; +use std::{cell::RefCell, fmt, rc::Rc, sync::Mutex}; mod handlers; pub mod roles; @@ -89,6 +89,7 @@ use wayland_server::{ /// Description of which part of a surface /// should be considered damaged and needs to be redrawn +#[derive(Debug)] pub enum Damage { /// The whole surface must be considered damaged (this is the default) Full, @@ -100,12 +101,13 @@ pub enum Damage { Buffer(Rectangle), } -#[derive(Copy, Clone, Default)] +#[derive(Debug, Copy, Clone, Default)] struct Marker { _r: ::std::marker::PhantomData, } /// New buffer assignation for a surface +#[derive(Debug)] pub enum BufferAssignment { /// The surface no longer has a buffer attached to it Removed, @@ -170,6 +172,22 @@ pub struct SurfaceAttributes { pub user_data: UserDataMap, } +// UserDataMap does not implement debug, so we have to impl Debug manually +impl fmt::Debug for SurfaceAttributes { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SurfaceAttributes") + .field("buffer", &self.buffer) + .field("buffer_scale", &self.buffer_scale) + .field("buffer_transform", &self.buffer_transform) + .field("opaque_region", &self.opaque_region) + .field("input_region", &self.input_region) + .field("damage", &self.damage) + .field("frame_callback", &self.frame_callback) + .field("user_data", &"...") + .finish() + } +} + impl Default for SurfaceAttributes { fn default() -> SurfaceAttributes { SurfaceAttributes { @@ -259,6 +277,7 @@ impl RegionAttributes { /// access data associated with the [`wl_surface`](wayland_server::protocol::wl_surface) /// and [`wl_region`](wayland_server::protocol::wl_region) managed /// by the `CompositorGlobal` that provided it. +#[derive(Debug)] pub struct CompositorToken { _role: ::std::marker::PhantomData<*mut R>, } @@ -516,6 +535,7 @@ where /// The global provided by smithay cannot process these events for you, so /// they are forwarded directly via your provided implementation, and are /// described by this global. +#[derive(Debug)] pub enum SurfaceEvent { /// The double-buffered state has been validated by the client /// diff --git a/src/wayland/compositor/tree.rs b/src/wayland/compositor/tree.rs index e25a81c..7b20878 100644 --- a/src/wayland/compositor/tree.rs +++ b/src/wayland/compositor/tree.rs @@ -28,6 +28,7 @@ pub enum Location { } /// Possible actions to do after handling a node diring tree traversal +#[derive(Debug)] pub enum TraversalAction { /// Traverse its children as well, providing them the data T DoChildren(T), diff --git a/src/wayland/data_device/mod.rs b/src/wayland/data_device/mod.rs index ab128e6..d223e56 100644 --- a/src/wayland/data_device/mod.rs +++ b/src/wayland/data_device/mod.rs @@ -78,6 +78,7 @@ pub use self::data_source::{with_source_metadata, SourceMetadata}; pub use self::server_dnd_grab::ServerDndEvent; /// Events that are generated by interactions of the clients with the data device +#[derive(Debug)] pub enum DataDeviceEvent { /// A client has set the selection NewSelection(Option), @@ -108,7 +109,7 @@ pub enum DataDeviceEvent { } /// The role applied to surfaces used as DnD icons -#[derive(Default)] +#[derive(Debug, Default)] pub struct DnDIconRole; enum Selection { diff --git a/src/wayland/data_device/server_dnd_grab.rs b/src/wayland/data_device/server_dnd_grab.rs index 8672acc..22af98f 100644 --- a/src/wayland/data_device/server_dnd_grab.rs +++ b/src/wayland/data_device/server_dnd_grab.rs @@ -11,6 +11,7 @@ use crate::wayland::Serial; use super::{DataDeviceData, SeatData}; /// Event generated by the interactions of clients with a server initiated drag'n'drop +#[derive(Debug)] pub enum ServerDndEvent { /// The client chose an action Action(DndAction), diff --git a/src/wayland/dmabuf/mod.rs b/src/wayland/dmabuf/mod.rs index 7ebb0c7..5a152f1 100644 --- a/src/wayland/dmabuf/mod.rs +++ b/src/wayland/dmabuf/mod.rs @@ -76,6 +76,7 @@ use wayland_protocols::unstable::linux_dmabuf::v1::server::{ use wayland_server::{protocol::wl_buffer, Display, Filter, Global, Main}; /// Representation of a Dmabuf format, as advertized to the client +#[derive(Debug)] pub struct Format { /// The format identifier. pub format: ::drm::buffer::format::PixelFormat, @@ -89,6 +90,7 @@ pub struct Format { } /// A plane send by the client +#[derive(Debug)] pub struct Plane { /// The file descriptor pub fd: RawFd, @@ -115,6 +117,7 @@ bitflags! { } /// The complete information provided by the client to create a dmabuf buffer +#[derive(Debug)] pub struct BufferInfo { /// The submitted planes pub planes: Vec, diff --git a/src/wayland/explicit_synchronization/mod.rs b/src/wayland/explicit_synchronization/mod.rs index 9b5d59b..0a8012f 100644 --- a/src/wayland/explicit_synchronization/mod.rs +++ b/src/wayland/explicit_synchronization/mod.rs @@ -86,6 +86,7 @@ use wayland_server::{protocol::wl_surface::WlSurface, Display, Filter, Global, M use crate::wayland::compositor::{CompositorToken, SurfaceAttributes}; /// An object to signal end of use of a buffer +#[derive(Debug)] pub struct ExplicitBufferRelease { release: ZwpLinuxBufferReleaseV1, } @@ -111,6 +112,7 @@ impl ExplicitBufferRelease { /// The client is not required to fill both. `acquire` being `None` means that you don't need to wait /// before acessing the buffer, `release` being `None` means that the client does not require additionnal /// signaling that you are finished (you still need to send `wl_buffer.release`). +#[derive(Debug)] pub struct ExplicitSyncState { /// An acquire `dma_fence` object, that you should wait on before accessing the contents of the /// buffer associated with the surface. @@ -143,6 +145,7 @@ impl ESUserData { } /// Possible errors you can send to an ill-behaving clients +#[derive(Debug)] pub enum ExplicitSyncError { /// An invalid file descriptor was sent by the client for an acquire fence InvalidFence, diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 8906e7e..876bedd 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -80,6 +80,7 @@ impl From for u32 { /// /// The counter will wrap around on overflow, ensuring it can run for as long /// as needed. +#[derive(Debug)] pub struct SerialCounter { // TODO: replace with an AtomicU32 when stabilized serial: AtomicUsize, diff --git a/src/wayland/output/mod.rs b/src/wayland/output/mod.rs index 73b199a..05dfda1 100644 --- a/src/wayland/output/mod.rs +++ b/src/wayland/output/mod.rs @@ -65,7 +65,7 @@ use wayland_server::{ /// /// This should only describe the characteristics of the video driver, /// not taking into account any global scaling. -#[derive(Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq)] pub struct Mode { /// The width in pixels pub width: i32, @@ -78,6 +78,7 @@ pub struct Mode { } /// The physical properties of an output +#[derive(Debug)] pub struct PhysicalProperties { /// The width in millimeters pub width: i32, @@ -91,6 +92,7 @@ pub struct PhysicalProperties { pub model: String, } +#[derive(Debug)] struct Inner { name: String, log: ::slog::Logger, @@ -155,6 +157,7 @@ impl Inner { /// /// This handle is stored in the event loop, and allows you to notify clients /// about any change in the properties of this output. +#[derive(Debug)] pub struct Output { inner: Arc>, } diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index 4242ae9..8ad7c5f 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -3,6 +3,7 @@ use crate::wayland::Serial; use std::{ cell::RefCell, default::Default, + fmt, io::{Error as IoError, Write}, ops::Deref as _, os::unix::io::AsRawFd, @@ -119,6 +120,23 @@ struct KbdInternal { focus_hook: Box)>, } +// focus_hook does not implement debug, so we have to impl Debug manually +impl fmt::Debug for KbdInternal { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("KbdInternal") + .field("known_kbds", &self.known_kbds) + .field("focus", &self.focus) + .field("pressed_keys", &self.pressed_keys) + .field("mods_state", &self.mods_state) + .field("keymap", &self.keymap.get_raw_ptr()) + .field("state", &self.state.get_raw_ptr()) + .field("repeat_rate", &self.repeat_rate) + .field("repeat_delay", &self.repeat_delay) + .field("focus_hook", &"...") + .finish() + } +} + // This is OK because all parts of `xkb` will remain on the // same thread unsafe impl Send for KbdInternal {} @@ -267,6 +285,7 @@ where }) } +#[derive(Debug)] struct KbdRc { internal: RefCell, keymap: String, @@ -284,7 +303,7 @@ struct KbdRc { /// - process key inputs from the input backend, allowing them to be caught at the compositor-level /// or forwarded to the client. See the documentation of the [`KeyboardHandle::input`] method for /// details. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct KeyboardHandle { arc: Rc, } diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index a36c964..9c2c982 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -40,7 +40,7 @@ //! These methods return handles that can be cloned and sent across thread, so you can keep one around //! in your event-handling code to forward inputs to your clients. -use std::{cell::RefCell, ops::Deref as _, rc::Rc}; +use std::{cell::RefCell, fmt, ops::Deref as _, rc::Rc}; mod keyboard; mod pointer; @@ -60,6 +60,7 @@ use wayland_server::{ Display, Filter, Global, Main, UserDataMap, }; +#[derive(Debug)] struct Inner { pointer: Option, keyboard: Option, @@ -73,6 +74,18 @@ pub(crate) struct SeatRc { name: String, } +// UserDataMap does not implement debug, so we have to impl Debug manually +impl fmt::Debug for SeatRc { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SeatRc") + .field("inner", &self.inner) + .field("user_data", &"...") + .field("log", &self.log) + .field("name", &self.name) + .finish() + } +} + impl Inner { fn compute_caps(&self) -> wl_seat::Capability { let mut caps = wl_seat::Capability::empty(); @@ -103,7 +116,7 @@ impl Inner { /// This is an handle to the inner logic, it can be cloned. /// /// See module-level documentation for details of use. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct Seat { pub(crate) arc: Rc, } diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index 14754b0..d09837f 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -1,4 +1,4 @@ -use std::{cell::RefCell, ops::Deref as _, rc::Rc}; +use std::{cell::RefCell, fmt, ops::Deref as _, rc::Rc}; use wayland_server::{ protocol::{ @@ -12,14 +12,14 @@ use crate::wayland::compositor::{roles::Role, CompositorToken}; use crate::wayland::Serial; /// The role representing a surface set as the pointer cursor -#[derive(Default, Copy, Clone)] +#[derive(Debug, Default, Copy, Clone)] pub struct CursorImageRole { /// Location of the hotspot of the pointer in the surface pub hotspot: (i32, i32), } /// Possible status of a cursor as requested by clients -#[derive(Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub enum CursorImageStatus { /// The cursor should be hidden Hidden, @@ -35,6 +35,17 @@ enum GrabStatus { Borrowed, } +// PointerGrab is a trait, so we have to impl Debug manually +impl fmt::Debug for GrabStatus { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + GrabStatus::None => f.debug_tuple("GrabStatus::None").finish(), + GrabStatus::Active(serial, _) => f.debug_tuple("GrabStatus::Active").field(&serial).finish(), + GrabStatus::Borrowed => f.debug_tuple("GrabStatus::Borrowed").finish(), + } + } +} + struct PointerInternal { known_pointers: Vec, focus: Option<(WlSurface, (f64, f64))>, @@ -45,6 +56,21 @@ struct PointerInternal { image_callback: Box, } +// image_callback does not implement debug, so we have to impl Debug manually +impl fmt::Debug for PointerInternal { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Point") + .field("known_pointers", &self.known_pointers) + .field("focus", &self.focus) + .field("pending_focus", &self.pending_focus) + .field("location", &self.location) + .field("grab", &self.grab) + .field("pressed_buttons", &self.pressed_buttons) + .field("image_callback", &"...") + .finish() + } +} + impl PointerInternal { fn new(token: CompositorToken, mut cb: F) -> PointerInternal where @@ -125,7 +151,7 @@ impl PointerInternal { /// /// When sending events using this handle, they will be intercepted by a pointer /// grab if any is active. See the [`PointerGrab`] trait for details. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct PointerHandle { inner: Rc>, } @@ -233,7 +259,7 @@ impl PointerHandle { } /// Data about the event that started the grab. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct GrabStartData { /// The focused surface and its location, if any, at the start of the grab. /// @@ -287,6 +313,7 @@ pub trait PointerGrab { /// This inner handle is accessed from inside a pointer grab logic, and directly /// sends event to the client +#[derive(Debug)] pub struct PointerInnerHandle<'a> { inner: &'a mut PointerInternal, } diff --git a/src/wayland/shell/legacy/mod.rs b/src/wayland/shell/legacy/mod.rs index ea7c33d..518b6cf 100644 --- a/src/wayland/shell/legacy/mod.rs +++ b/src/wayland/shell/legacy/mod.rs @@ -77,6 +77,7 @@ use wayland_server::{ mod wl_handlers; /// Metadata associated with the `wl_surface` role +#[derive(Debug)] pub struct ShellSurfaceRole { /// Title of the surface pub title: String, @@ -86,6 +87,7 @@ pub struct ShellSurfaceRole { } /// A handle to a shell surface +#[derive(Debug)] pub struct ShellSurface { wl_surface: wl_surface::WlSurface, shell_surface: wl_shell_surface::WlShellSurface, @@ -169,6 +171,7 @@ where } /// Possible kinds of shell surface of the `wl_shell` protocol +#[derive(Debug)] pub enum ShellSurfaceKind { /// Toplevel, a regular window displayed somewhere in the compositor space Toplevel, @@ -222,6 +225,7 @@ pub enum ShellSurfaceKind { } /// A request triggered by a `wl_shell_surface` +#[derive(Debug)] pub enum ShellRequest { /// A new shell surface was created /// @@ -275,6 +279,7 @@ pub enum ShellRequest { /// /// This state allows you to retrieve a list of surfaces /// currently known to the shell global. +#[derive(Debug)] pub struct ShellState { known_surfaces: Vec>, } diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 2d358f7..4fea174 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -109,6 +109,7 @@ mod xdg_handlers; mod zxdgv6_handlers; /// Metadata associated with the `xdg_surface` role +#[derive(Debug)] pub struct XdgSurfaceRole { /// Pending state as requested by the client /// @@ -177,6 +178,7 @@ impl PositionerState { } /// Contents of the pending state of a shell surface, depending on its role +#[derive(Debug)] pub enum XdgSurfacePendingState { /// This a regular, toplevel surface /// @@ -196,6 +198,7 @@ pub enum XdgSurfacePendingState { } /// State of a regular toplevel surface +#[derive(Debug)] pub struct ToplevelState { /// Parent of this surface /// @@ -233,6 +236,7 @@ impl Clone for ToplevelState { } /// The pending state of a popup surface +#[derive(Debug)] pub struct PopupState { /// Parent of this popup surface pub parent: Option, @@ -326,6 +330,7 @@ where /// /// This state allows you to retrieve a list of surfaces /// currently known to the shell global. +#[derive(Debug)] pub struct ShellState { known_toplevels: Vec>, known_popups: Vec>, @@ -350,6 +355,7 @@ where * User interaction */ +#[derive(Debug)] enum ShellClientKind { Xdg(xdg_wm_base::XdgWmBase), ZxdgV6(zxdg_shell_v6::ZxdgShellV6), @@ -377,6 +383,7 @@ fn make_shell_client_data() -> ShellClientData { /// /// You can use this handle to access a storage for any /// client-specific data you wish to associate with it. +#[derive(Debug)] pub struct ShellClient { kind: ShellClientKind, _token: CompositorToken, @@ -481,13 +488,14 @@ where } } -#[derive(Clone)] +#[derive(Debug, Clone)] pub(crate) enum ToplevelKind { Xdg(xdg_toplevel::XdgToplevel), ZxdgV6(zxdg_toplevel_v6::ZxdgToplevelV6), } /// A handle to a toplevel surface +#[derive(Debug)] pub struct ToplevelSurface { wl_surface: wl_surface::WlSurface, shell_surface: ToplevelKind, @@ -650,6 +658,7 @@ where } } +#[derive(Debug)] pub(crate) enum PopupKind { Xdg(xdg_popup::XdgPopup), ZxdgV6(zxdg_popup_v6::ZxdgPopupV6), @@ -659,6 +668,7 @@ pub(crate) enum PopupKind { /// /// This is an unified abstraction over the popup surfaces /// of both `wl_shell` and `xdg_shell`. +#[derive(Debug)] pub struct PopupSurface { wl_surface: wl_surface::WlSurface, shell_surface: PopupKind, @@ -818,6 +828,7 @@ where } /// A configure message for toplevel surfaces +#[derive(Debug)] pub struct ToplevelConfigure { /// A suggestion for a new size for the surface pub size: Option<(i32, i32)>, @@ -835,6 +846,7 @@ pub struct ToplevelConfigure { } /// A configure message for popup surface +#[derive(Debug)] pub struct PopupConfigure { /// The position chosen for this popup relative to /// its parent @@ -855,6 +867,7 @@ pub struct PopupConfigure { /// for you directly. /// /// Depending on what you want to do, you might ignore some of them +#[derive(Debug)] pub enum XdgRequest { /// A new shell client was instantiated NewClient { diff --git a/src/wayland/shm/mod.rs b/src/wayland/shm/mod.rs index b86e945..47c3b40 100644 --- a/src/wayland/shm/mod.rs +++ b/src/wayland/shm/mod.rs @@ -82,7 +82,7 @@ use wayland_server::{ mod pool; -#[derive(Clone)] +#[derive(Debug, Clone)] /// Internal data storage of `ShmGlobal` /// /// This type is only visible as type parameter of