[Debug Trait] backend

backend/libinput
backend/egl
backend/drm
backend/session
This commit is contained in:
Poly 2021-02-10 03:37:17 +01:00
parent bb90631d65
commit f96fcee1fd
22 changed files with 230 additions and 3 deletions

View File

@ -20,6 +20,7 @@
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::rc::Rc; use std::rc::Rc;
use std::sync::{ use std::sync::{
@ -59,6 +60,23 @@ pub struct AtomicDrmDevice<A: AsRawFd + 'static> {
logger: ::slog::Logger, logger: ::slog::Logger,
} }
impl<A: AsRawFd + 'static> fmt::Debug for AtomicDrmDevice<A> {
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);
#[cfg(feature = "backend_session")]
debug.field("links", &self.links);
debug.field("logger", &self.logger).finish()
}
}
type OldState = ( type OldState = (
Vec<(connector::Handle, PropertyValueSet)>, Vec<(connector::Handle, PropertyValueSet)>,
Vec<(crtc::Handle, PropertyValueSet)>, Vec<(crtc::Handle, PropertyValueSet)>,
@ -82,6 +100,18 @@ pub(in crate::backend::drm) struct Dev<A: AsRawFd + 'static> {
logger: ::slog::Logger, logger: ::slog::Logger,
} }
impl<A: AsRawFd + 'static> fmt::Debug for Dev<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Dev")
.field("privileged", &self.privileged)
.field("active", &self.active)
.field("old_state", &self.old_state)
.field("prop_mapping", &self.prop_mapping)
.field("logger", &self.logger)
.finish()
}
}
impl<A: AsRawFd + 'static> AsRawFd for Dev<A> { impl<A: AsRawFd + 'static> AsRawFd for Dev<A> {
fn as_raw_fd(&self) -> RawFd { fn as_raw_fd(&self) -> RawFd {
self.fd.as_raw_fd() self.fd.as_raw_fd()

View File

@ -25,6 +25,7 @@ use crate::{
/// [`SessionObserver`](SessionObserver) /// [`SessionObserver`](SessionObserver)
/// linked to the [`AtomicDrmDevice`](AtomicDrmDevice) /// linked to the [`AtomicDrmDevice`](AtomicDrmDevice)
/// it was created from. /// it was created from.
#[derive(Debug)]
pub struct AtomicDrmDeviceObserver<A: AsRawFd + 'static> { pub struct AtomicDrmDeviceObserver<A: AsRawFd + 'static> {
dev: WeakArc<Dev<A>>, dev: WeakArc<Dev<A>>,
dev_id: dev_t, dev_id: dev_t,

View File

@ -7,6 +7,7 @@ use drm::control::{
use drm::Device as BasicDevice; use drm::Device as BasicDevice;
use std::collections::HashSet; use std::collections::HashSet;
use std::fmt;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::{atomic::Ordering, Arc, Mutex, RwLock}; use std::sync::{atomic::Ordering, Arc, Mutex, RwLock};
@ -47,6 +48,20 @@ pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal<A: AsRawFd + 'static
pub(super) test_buffer: Mutex<Option<(DumbBuffer, framebuffer::Handle)>>, pub(super) test_buffer: Mutex<Option<(DumbBuffer, framebuffer::Handle)>>,
} }
impl<A: AsRawFd + 'static> fmt::Debug for AtomicDrmSurfaceInternal<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AtomicDrmSurfaceInternal")
.field("crtc", &self.crtc)
.field("cursor", &self.cursor)
.field("planse", &self.planes)
.field("state", &self.state)
.field("pending", &self.pending)
.field("logger", &self.logger)
.field("test_buffer", &self.test_buffer)
.finish()
}
}
impl<A: AsRawFd + 'static> AsRawFd for AtomicDrmSurfaceInternal<A> { impl<A: AsRawFd + 'static> AsRawFd for AtomicDrmSurfaceInternal<A> {
fn as_raw_fd(&self) -> RawFd { fn as_raw_fd(&self) -> RawFd {
self.dev.as_raw_fd() self.dev.as_raw_fd()
@ -1003,6 +1018,7 @@ impl<A: AsRawFd + 'static> AtomicDrmSurfaceInternal<A> {
} }
/// Open raw crtc utilizing atomic mode-setting /// Open raw crtc utilizing atomic mode-setting
#[derive(Debug)]
pub struct AtomicDrmSurface<A: AsRawFd + 'static>( pub struct AtomicDrmSurface<A: AsRawFd + 'static>(
pub(in crate::backend::drm) Arc<AtomicDrmSurfaceInternal<A>>, pub(in crate::backend::drm) Arc<AtomicDrmSurfaceInternal<A>>,
); );

View File

@ -36,6 +36,7 @@ use drm::{
use nix::libc::c_void; use nix::libc::c_void;
use nix::libc::dev_t; use nix::libc::dev_t;
use std::env; use std::env;
use std::fmt;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
#[cfg(feature = "use_system_lib")] #[cfg(feature = "use_system_lib")]
use wayland_server::Display; use wayland_server::Display;
@ -49,6 +50,21 @@ pub enum FallbackDevice<D1: Device + 'static, D2: Device + 'static> {
Fallback(D2), Fallback(D2),
} }
impl<D1: Device + 'static, D2: Device + 'static> fmt::Debug for FallbackDevice<D1, D2> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FallbackDevice::Preference(d) => f
.debug_struct("FallbackDevice::Preference")
.field("device_id", &d.device_id())
.finish(),
FallbackDevice::Fallback(d) => f
.debug_struct("FallbackDevice::Preference")
.field("device_id", &d.device_id())
.finish(),
}
}
}
struct FallbackDeviceHandlerD1<E1, E2, C, S1, S2, D1, D2>( struct FallbackDeviceHandlerD1<E1, E2, C, S1, S2, D1, D2>(
Box<dyn DeviceHandler<Device = FallbackDevice<D1, D2>> + 'static>, Box<dyn DeviceHandler<Device = FallbackDevice<D1, D2>> + 'static>,
) )
@ -136,6 +152,21 @@ pub enum FallbackSurface<S1: Surface, S2: Surface> {
Fallback(S2), Fallback(S2),
} }
impl<S1: Surface, S2: Surface> fmt::Debug for FallbackSurface<S1, S2> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FallbackSurface::Preference(s) => f
.debug_struct("FallbackDevice::Preference")
.field("crtc", &s.crtc())
.finish(),
FallbackSurface::Fallback(s) => f
.debug_struct("FallbackDevice::Preference")
.field("crtc", &s.crtc())
.finish(),
}
}
}
/// Enum uniting two kinds of possible errors. /// Enum uniting two kinds of possible errors.
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum EitherError<E1: std::error::Error + 'static, E2: std::error::Error + 'static> { pub enum EitherError<E1: std::error::Error + 'static, E2: std::error::Error + 'static> {

View File

@ -15,6 +15,7 @@ use drm::SystemError as DrmError;
use nix::libc::dev_t; use nix::libc::dev_t;
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::rc::Rc; use std::rc::Rc;
use std::sync::{Arc, Weak as WeakArc}; use std::sync::{Arc, Weak as WeakArc};
@ -69,6 +70,28 @@ where
links: Vec<crate::signaling::SignalToken>, links: Vec<crate::signaling::SignalToken>,
} }
impl<B, D> fmt::Debug for EglDevice<B, D>
where
B: Backend<Surface = <D as Device>::Surface, Error = <<D as Device>::Surface as Surface>::Error>
+ 'static,
D: Device + NativeDisplay<B, Arguments = Arguments> + 'static,
<D as Device>::Surface: NativeSurface<Error = <<D as Device>::Surface as Surface>::Error>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("EglDevice");
debug
.field("logger", &self.logger)
.field("default_attributes", &self.default_attributes)
.field("default_requirements", &self.default_requirements);
#[cfg(feature = "backend_session")]
debug.field("links", &self.links);
debug.finish()
}
}
impl<B, D> AsRawFd for EglDevice<B, D> impl<B, D> AsRawFd for EglDevice<B, D>
where where
B: Backend<Surface = <D as Device>::Surface, Error = <<D as Device>::Surface as Surface>::Error> B: Backend<Surface = <D as Device>::Surface, Error = <<D as Device>::Surface as Surface>::Error>

View File

@ -23,6 +23,7 @@ use crate::{
/// [`SessionObserver`](SessionObserver) /// [`SessionObserver`](SessionObserver)
/// linked to the [`EglDevice`](EglDevice) it was /// linked to the [`EglDevice`](EglDevice) it was
/// created from. /// created from.
#[derive(Debug)]
pub struct EglDeviceObserver<N: NativeSurface + Surface> { pub struct EglDeviceObserver<N: NativeSurface + Surface> {
backends: Weak<RefCell<HashMap<crtc::Handle, WeakArc<EglSurfaceInternal<N>>>>>, backends: Weak<RefCell<HashMap<crtc::Handle, WeakArc<EglSurfaceInternal<N>>>>>,
} }

View File

@ -14,8 +14,10 @@ use crate::backend::graphics::PixelFormat;
use crate::backend::graphics::{CursorBackend, SwapBuffersError}; use crate::backend::graphics::{CursorBackend, SwapBuffersError};
/// Egl surface for rendering /// Egl surface for rendering
#[derive(Debug)]
pub struct EglSurface<N: native::NativeSurface + Surface>(pub(super) Arc<EglSurfaceInternal<N>>); pub struct EglSurface<N: native::NativeSurface + Surface>(pub(super) Arc<EglSurfaceInternal<N>>);
#[derive(Debug)]
pub(super) struct EglSurfaceInternal<N> pub(super) struct EglSurfaceInternal<N>
where where
N: native::NativeSurface + Surface, N: native::NativeSurface + Surface,

View File

@ -31,6 +31,7 @@ use std::sync::Arc;
/// Egl Device backend type /// Egl Device backend type
/// ///
/// See [`Backend`](::backend::egl::native::Backend). /// See [`Backend`](::backend::egl::native::Backend).
#[derive(Debug)]
pub struct EglStreamDeviceBackend<D: RawDevice + 'static> { pub struct EglStreamDeviceBackend<D: RawDevice + 'static> {
_userdata: PhantomData<D>, _userdata: PhantomData<D>,
} }

View File

@ -28,6 +28,7 @@ use nix::libc::dev_t;
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt;
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
@ -90,6 +91,16 @@ pub struct EglStreamDevice<D: RawDevice + ControlDevice + 'static> {
links: Vec<crate::signaling::SignalToken>, links: Vec<crate::signaling::SignalToken>,
} }
impl<D: RawDevice + ControlDevice + 'static> fmt::Debug for EglStreamDevice<D> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("EglStreamDevice");
debug.field("dev", &self.dev).field("logger", &self.logger);
#[cfg(feature = "backend_session")]
debug.field("links", &self.links);
debug.finish()
}
}
impl<D: RawDevice + ControlDevice + 'static> EglStreamDevice<D> { impl<D: RawDevice + ControlDevice + 'static> EglStreamDevice<D> {
/// Try to create a new [`EglStreamDevice`] from an open device. /// Try to create a new [`EglStreamDevice`] from an open device.
/// ///

View File

@ -19,6 +19,7 @@ use drm::control::{crtc, Device as ControlDevice};
/// [`SessionObserver`](SessionObserver) /// [`SessionObserver`](SessionObserver)
/// linked to the [`EglStreamDevice`](EglStreamDevice) it was /// linked to the [`EglStreamDevice`](EglStreamDevice) it was
/// created from. /// created from.
#[derive(Debug)]
pub struct EglStreamDeviceObserver<S: RawSurface + 'static> { pub struct EglStreamDeviceObserver<S: RawSurface + 'static> {
backends: Weak<RefCell<HashMap<crtc::Handle, WeakArc<EglStreamSurfaceInternal<S>>>>>, backends: Weak<RefCell<HashMap<crtc::Handle, WeakArc<EglStreamSurfaceInternal<S>>>>>,
logger: ::slog::Logger, logger: ::slog::Logger,

View File

@ -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 // 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. // and because S needs to be `Send` as well for this to work.
#[derive(Debug)]
pub(super) struct StreamHandle(pub(super) EGLStreamKHR); pub(super) struct StreamHandle(pub(super) EGLStreamKHR);
// EGLStreamKHR can be moved between threads // EGLStreamKHR can be moved between threads
unsafe impl Send for StreamHandle {} unsafe impl Send for StreamHandle {}
#[derive(Debug)]
pub(in crate::backend::drm) struct EglStreamSurfaceInternal<S: RawSurface + 'static> { pub(in crate::backend::drm) struct EglStreamSurfaceInternal<S: RawSurface + 'static> {
pub(in crate::backend::drm) crtc: S, pub(in crate::backend::drm) crtc: S,
pub(in crate::backend::drm) cursor: Mutex<Option<(DumbBuffer, (u32, u32))>>, pub(in crate::backend::drm) cursor: Mutex<Option<(DumbBuffer, (u32, u32))>>,
@ -205,6 +207,7 @@ impl<S: RawSurface + 'static> CursorBackend for EglStreamSurfaceInternal<S> {
} }
/// egl stream surface for rendering /// egl stream surface for rendering
#[derive(Debug)]
pub struct EglStreamSurface<S: RawSurface + 'static>( pub struct EglStreamSurface<S: RawSurface + 'static>(
pub(in crate::backend::drm) Arc<EglStreamSurfaceInternal<S>>, pub(in crate::backend::drm) Arc<EglStreamSurfaceInternal<S>>,
); );

View File

@ -10,6 +10,7 @@ use std::ptr;
use std::sync::{atomic::Ordering, Arc}; use std::sync::{atomic::Ordering, Arc};
/// EGL context for rendering /// EGL context for rendering
#[derive(Debug)]
pub struct EGLContext { pub struct EGLContext {
context: ffi::egl::types::EGLContext, context: ffi::egl::types::EGLContext,
display: Arc<EGLDisplayHandle>, display: Arc<EGLDisplayHandle>,

View File

@ -24,10 +24,12 @@ use std::ffi::CStr;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use std::fmt;
use std::ops::Deref; use std::ops::Deref;
/// Wrapper around [`ffi::EGLDisplay`](ffi::egl::types::EGLDisplay) to ensure display is only destroyed /// Wrapper around [`ffi::EGLDisplay`](ffi::egl::types::EGLDisplay) to ensure display is only destroyed
/// once all resources bound to it have been dropped. /// once all resources bound to it have been dropped.
#[derive(Debug)]
pub struct EGLDisplayHandle { pub struct EGLDisplayHandle {
/// ffi EGLDisplay ptr /// ffi EGLDisplay ptr
pub handle: ffi::egl::types::EGLDisplay, pub handle: ffi::egl::types::EGLDisplay,
@ -54,6 +56,7 @@ impl Drop for EGLDisplayHandle {
} }
/// [`EGLDisplay`] represents an initialised EGL environment /// [`EGLDisplay`] represents an initialised EGL environment
#[derive(Debug)]
pub struct EGLDisplay<B: native::Backend, N: native::NativeDisplay<B>> { pub struct EGLDisplay<B: native::Backend, N: native::NativeDisplay<B>> {
native: RefCell<N>, native: RefCell<N>,
pub(crate) display: Arc<EGLDisplayHandle>, pub(crate) display: Arc<EGLDisplayHandle>,
@ -454,6 +457,16 @@ pub struct EGLBufferReader {
gl: gl_ffi::Gles2, gl: gl_ffi::Gles2,
} }
#[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")] #[cfg(feature = "use_system_lib")]
impl EGLBufferReader { impl EGLBufferReader {
fn new(display: Arc<EGLDisplayHandle>, wayland: *mut wl_display) -> Self { fn new(display: Arc<EGLDisplayHandle>, wayland: *mut wl_display) -> Self {

View File

@ -269,6 +269,20 @@ pub struct EGLImages {
gl: gl_ffi::Gles2, gl: gl_ffi::Gles2,
} }
#[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")] #[cfg(feature = "wayland_frontend")]
impl EGLImages { impl EGLImages {
/// Amount of planes of these `EGLImages` /// Amount of planes of these `EGLImages`

View File

@ -35,6 +35,7 @@ pub trait Backend {
} }
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
#[derive(Debug)]
/// Wayland backend type /// Wayland backend type
pub enum Wayland {} pub enum Wayland {}
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
@ -79,10 +80,12 @@ impl Backend for Wayland {
} }
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
#[derive(Debug)]
/// Typed Xlib window for the `X11` backend /// Typed Xlib window for the `X11` backend
pub struct XlibWindow(u64); pub struct XlibWindow(u64);
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
/// X11 backend type /// X11 backend type
#[derive(Debug)]
pub enum X11 {} pub enum X11 {}
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
impl Backend for X11 { impl Backend for X11 {

View File

@ -11,6 +11,7 @@ use std::sync::{
}; };
/// EGL surface of a given EGL context for rendering /// EGL surface of a given EGL context for rendering
#[derive(Debug)]
pub struct EGLSurface<N: native::NativeSurface> { pub struct EGLSurface<N: native::NativeSurface> {
pub(crate) display: Arc<EGLDisplayHandle>, pub(crate) display: Arc<EGLDisplayHandle>,
native: N, native: N,

View File

@ -1,6 +1,7 @@
//! OpenGL rendering types //! OpenGL rendering types
use nix::libc::c_void; use nix::libc::c_void;
use std::fmt;
use super::{PixelFormat, SwapBuffersError}; use super::{PixelFormat, SwapBuffersError};
@ -39,6 +40,15 @@ pub trait GLGraphicsBackend {
/// Returns the pixel format of the main framebuffer of the context. /// Returns the pixel format of the main framebuffer of the context.
fn get_pixel_format(&self) -> PixelFormat; fn get_pixel_format(&self) -> PixelFormat;
/// Formats the debug value using the given formatter.
fn debug_fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("GLGraphicsBackend")
.field("framebuffer_dimensions", &self.get_framebuffer_dimensions())
.field("is_current", &self.is_current())
.field("pixel_format", &self.get_pixel_format())
.finish()
}
} }
/// Loads a Raw GLES Interface for a given [`GLGraphicsBackend`] /// Loads a Raw GLES Interface for a given [`GLGraphicsBackend`]

View File

@ -8,6 +8,7 @@ use glium::{
}; };
use std::{ use std::{
cell::{Cell, Ref, RefCell, RefMut}, cell::{Cell, Ref, RefCell, RefMut},
fmt,
os::raw::c_void, os::raw::c_void,
rc::Rc, rc::Rc,
}; };
@ -22,6 +23,16 @@ pub struct GliumGraphicsBackend<T: GLGraphicsBackend> {
error_channel: Rc<Cell<Option<Box<dyn std::error::Error>>>>, error_channel: Rc<Cell<Option<Box<dyn std::error::Error>>>>,
} }
impl<T: GLGraphicsBackend> fmt::Debug for GliumGraphicsBackend<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let backend = &self.backend.0.borrow().debug_fmt(f);
f.debug_struct("GliumGraphicsBackend")
.field("backend", backend)
.finish()
}
}
struct InternalBackend<T: GLGraphicsBackend>(RefCell<T>, Rc<Cell<Option<Box<dyn std::error::Error>>>>); struct InternalBackend<T: GLGraphicsBackend>(RefCell<T>, Rc<Cell<Option<Box<dyn std::error::Error>>>>);
impl<T: GLGraphicsBackend + 'static> GliumGraphicsBackend<T> { impl<T: GLGraphicsBackend + 'static> GliumGraphicsBackend<T> {

View File

@ -16,6 +16,7 @@ use input::event;
use std::path::Path; use std::path::Path;
use std::{ use std::{
collections::hash_map::HashMap, collections::hash_map::HashMap,
fmt,
io::Error as IoError, io::Error as IoError,
os::unix::io::{AsRawFd, RawFd}, 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 /// Tracks input of all devices given manually or via a udev seat to a provided libinput
/// context. /// context.
#[derive(Debug)]
pub struct LibinputInputBackend { pub struct LibinputInputBackend {
context: libinput::Libinput, context: libinput::Libinput,
config: LibinputConfig, config: LibinputConfig,
@ -273,6 +275,7 @@ impl backend::Event for event::touch::TouchFrameEvent {
impl backend::TouchFrameEvent for event::touch::TouchFrameEvent {} impl backend::TouchFrameEvent for event::touch::TouchFrameEvent {}
/// Special events generated by Libinput /// Special events generated by Libinput
#[derive(Debug)]
pub enum LibinputEvent { pub enum LibinputEvent {
/// A new device was plugged in /// A new device was plugged in
NewDevice(libinput::Device), NewDevice(libinput::Device),
@ -284,6 +287,7 @@ pub enum LibinputEvent {
/// ///
/// This type allows you to access the list of know devices to configure them /// This type allows you to access the list of know devices to configure them
/// if relevant /// if relevant
#[derive(Debug)]
pub struct LibinputConfig { pub struct LibinputConfig {
devices: Vec<libinput::Device>, devices: Vec<libinput::Device>,
} }
@ -423,6 +427,19 @@ impl From<event::pointer::ButtonState> for backend::MouseButtonState {
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
pub struct LibinputSessionInterface<S: Session>(S); pub struct LibinputSessionInterface<S: Session>(S);
#[cfg(feature = "backend_session")]
impl<S: Session> fmt::Debug for LibinputSessionInterface<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let sesion = &f
.debug_struct("Session")
.field("is_active", &self.0.is_active())
.field("seat", &self.0.seat())
.finish();
f.debug_tuple("LibinputSessionInterface").field(sesion).finish()
}
}
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
impl<S: Session> From<S> for LibinputSessionInterface<S> { impl<S: Session> From<S> for LibinputSessionInterface<S> {
fn from(session: S) -> LibinputSessionInterface<S> { fn from(session: S) -> LibinputSessionInterface<S> {

View File

@ -44,7 +44,7 @@ use std::{cell::RefCell, io, os::unix::io::RawFd, path::Path, rc::Rc};
use calloop::{EventSource, Poll, Readiness, Token}; use calloop::{EventSource, Poll, Readiness, Token};
/// [`Session`] using the best available interface /// [`Session`] using the best available interface
#[derive(Clone)] #[derive(Debug, Clone)]
pub enum AutoSession { pub enum AutoSession {
/// Logind session /// Logind session
#[cfg(feature = "backend_session_logind")] #[cfg(feature = "backend_session_logind")]
@ -54,6 +54,7 @@ pub enum AutoSession {
} }
/// [`SessionNotifier`] using the best available interface /// [`SessionNotifier`] using the best available interface
#[derive(Debug)]
pub enum AutoSessionNotifier { pub enum AutoSessionNotifier {
/// Logind session notifier /// Logind session notifier
#[cfg(feature = "backend_session_logind")] #[cfg(feature = "backend_session_logind")]

View File

@ -49,6 +49,7 @@ use nix::{
}; };
use std::{ use std::{
cell::RefCell, cell::RefCell,
fmt,
io::Error as IoError, io::Error as IoError,
os::unix::io::RawFd, os::unix::io::RawFd,
path::Path, path::Path,
@ -70,15 +71,29 @@ struct LogindSessionImpl {
logger: ::slog::Logger, logger: ::slog::Logger,
} }
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 /// [`Session`] via the logind dbus interface
#[derive(Clone)] #[derive(Debug, Clone)]
pub struct LogindSession { pub struct LogindSession {
internal: Weak<LogindSessionImpl>, internal: Weak<LogindSessionImpl>,
seat: String, seat: String,
} }
/// [`SessionNotifier`] via the logind dbus interface /// [`SessionNotifier`] via the logind dbus interface
#[derive(Clone)] #[derive(Debug, Clone)]
pub struct LogindSessionNotifier { pub struct LogindSessionNotifier {
internal: Rc<LogindSessionImpl>, internal: Rc<LogindSessionImpl>,
} }

View File

@ -57,6 +57,7 @@ use nix::{
Error as NixError, Result as NixResult, Error as NixError, Result as NixResult,
}; };
use std::{ use std::{
fmt,
os::unix::io::RawFd, os::unix::io::RawFd,
path::Path, path::Path,
sync::{ sync::{
@ -142,6 +143,7 @@ fn is_tty_device(dev: dev_t, path: Option<&Path>) -> bool {
} }
/// [`Session`] via the virtual terminal direct kernel interface /// [`Session`] via the virtual terminal direct kernel interface
#[derive(Debug)]
pub struct DirectSession { pub struct DirectSession {
tty: RawFd, tty: RawFd,
active: Arc<AtomicBool>, active: Arc<AtomicBool>,
@ -160,6 +162,25 @@ pub struct DirectSessionNotifier {
source: Option<Signals>, source: Option<Signals>,
} }
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)
.field(
"source",
&match self.source {
Some(_) => "Some(..)",
None => "None",
},
)
.finish()
}
}
impl DirectSession { impl DirectSession {
/// Tries to create a new session via the legacy virtual terminal interface. /// Tries to create a new session via the legacy virtual terminal interface.
/// ///