[Debug Trait] backend
backend/libinput backend/egl backend/drm backend/session
This commit is contained in:
parent
bb90631d65
commit
f96fcee1fd
|
@ -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,23 @@ pub struct AtomicDrmDevice<A: AsRawFd + 'static> {
|
|||
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 = (
|
||||
Vec<(connector::Handle, PropertyValueSet)>,
|
||||
Vec<(crtc::Handle, PropertyValueSet)>,
|
||||
|
@ -82,6 +100,18 @@ pub(in crate::backend::drm) struct Dev<A: AsRawFd + 'static> {
|
|||
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> {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.fd.as_raw_fd()
|
||||
|
|
|
@ -25,6 +25,7 @@ use crate::{
|
|||
/// [`SessionObserver`](SessionObserver)
|
||||
/// linked to the [`AtomicDrmDevice`](AtomicDrmDevice)
|
||||
/// it was created from.
|
||||
#[derive(Debug)]
|
||||
pub struct AtomicDrmDeviceObserver<A: AsRawFd + 'static> {
|
||||
dev: WeakArc<Dev<A>>,
|
||||
dev_id: dev_t,
|
||||
|
|
|
@ -7,6 +7,7 @@ use drm::control::{
|
|||
use drm::Device as BasicDevice;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use std::os::unix::io::{AsRawFd, RawFd};
|
||||
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)>>,
|
||||
}
|
||||
|
||||
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> {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.dev.as_raw_fd()
|
||||
|
@ -1003,6 +1018,7 @@ impl<A: AsRawFd + 'static> AtomicDrmSurfaceInternal<A> {
|
|||
}
|
||||
|
||||
/// Open raw crtc utilizing atomic mode-setting
|
||||
#[derive(Debug)]
|
||||
pub struct AtomicDrmSurface<A: AsRawFd + 'static>(
|
||||
pub(in crate::backend::drm) Arc<AtomicDrmSurfaceInternal<A>>,
|
||||
);
|
||||
|
|
|
@ -36,6 +36,7 @@ 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;
|
||||
|
@ -49,6 +50,21 @@ pub enum FallbackDevice<D1: Device + 'static, D2: Device + 'static> {
|
|||
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>(
|
||||
Box<dyn DeviceHandler<Device = FallbackDevice<D1, D2>> + 'static>,
|
||||
)
|
||||
|
@ -136,6 +152,21 @@ pub enum FallbackSurface<S1: Surface, S2: Surface> {
|
|||
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.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum EitherError<E1: std::error::Error + 'static, E2: std::error::Error + 'static> {
|
||||
|
|
|
@ -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,28 @@ where
|
|||
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>
|
||||
where
|
||||
B: Backend<Surface = <D as Device>::Surface, Error = <<D as Device>::Surface as Surface>::Error>
|
||||
|
|
|
@ -23,6 +23,7 @@ use crate::{
|
|||
/// [`SessionObserver`](SessionObserver)
|
||||
/// linked to the [`EglDevice`](EglDevice) it was
|
||||
/// created from.
|
||||
#[derive(Debug)]
|
||||
pub struct EglDeviceObserver<N: NativeSurface + Surface> {
|
||||
backends: Weak<RefCell<HashMap<crtc::Handle, WeakArc<EglSurfaceInternal<N>>>>>,
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@ use crate::backend::graphics::PixelFormat;
|
|||
use crate::backend::graphics::{CursorBackend, SwapBuffersError};
|
||||
|
||||
/// Egl surface for rendering
|
||||
#[derive(Debug)]
|
||||
pub struct EglSurface<N: native::NativeSurface + Surface>(pub(super) Arc<EglSurfaceInternal<N>>);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct EglSurfaceInternal<N>
|
||||
where
|
||||
N: native::NativeSurface + Surface,
|
||||
|
|
|
@ -31,6 +31,7 @@ use std::sync::Arc;
|
|||
/// Egl Device backend type
|
||||
///
|
||||
/// See [`Backend`](::backend::egl::native::Backend).
|
||||
#[derive(Debug)]
|
||||
pub struct EglStreamDeviceBackend<D: RawDevice + 'static> {
|
||||
_userdata: PhantomData<D>,
|
||||
}
|
||||
|
|
|
@ -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,16 @@ pub struct EglStreamDevice<D: RawDevice + ControlDevice + 'static> {
|
|||
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> {
|
||||
/// Try to create a new [`EglStreamDevice`] from an open device.
|
||||
///
|
||||
|
|
|
@ -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<S: RawSurface + 'static> {
|
||||
backends: Weak<RefCell<HashMap<crtc::Handle, WeakArc<EglStreamSurfaceInternal<S>>>>>,
|
||||
logger: ::slog::Logger,
|
||||
|
|
|
@ -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<S: RawSurface + 'static> {
|
||||
pub(in crate::backend::drm) crtc: S,
|
||||
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
|
||||
#[derive(Debug)]
|
||||
pub struct EglStreamSurface<S: RawSurface + 'static>(
|
||||
pub(in crate::backend::drm) Arc<EglStreamSurfaceInternal<S>>,
|
||||
);
|
||||
|
|
|
@ -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<EGLDisplayHandle>,
|
||||
|
|
|
@ -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<B: native::Backend, N: native::NativeDisplay<B>> {
|
||||
native: RefCell<N>,
|
||||
pub(crate) display: Arc<EGLDisplayHandle>,
|
||||
|
@ -454,6 +457,16 @@ pub struct EGLBufferReader {
|
|||
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")]
|
||||
impl EGLBufferReader {
|
||||
fn new(display: Arc<EGLDisplayHandle>, wayland: *mut wl_display) -> Self {
|
||||
|
|
|
@ -269,6 +269,20 @@ pub struct EGLImages {
|
|||
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")]
|
||||
impl EGLImages {
|
||||
/// Amount of planes of these `EGLImages`
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -11,6 +11,7 @@ use std::sync::{
|
|||
};
|
||||
|
||||
/// EGL surface of a given EGL context for rendering
|
||||
#[derive(Debug)]
|
||||
pub struct EGLSurface<N: native::NativeSurface> {
|
||||
pub(crate) display: Arc<EGLDisplayHandle>,
|
||||
native: N,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! OpenGL rendering types
|
||||
|
||||
use nix::libc::c_void;
|
||||
use std::fmt;
|
||||
|
||||
use super::{PixelFormat, SwapBuffersError};
|
||||
|
||||
|
@ -39,6 +40,15 @@ pub trait GLGraphicsBackend {
|
|||
|
||||
/// Returns the pixel format of the main framebuffer of the context.
|
||||
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`]
|
||||
|
|
|
@ -8,6 +8,7 @@ use glium::{
|
|||
};
|
||||
use std::{
|
||||
cell::{Cell, Ref, RefCell, RefMut},
|
||||
fmt,
|
||||
os::raw::c_void,
|
||||
rc::Rc,
|
||||
};
|
||||
|
@ -22,6 +23,16 @@ pub struct GliumGraphicsBackend<T: GLGraphicsBackend> {
|
|||
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>>>>);
|
||||
|
||||
impl<T: GLGraphicsBackend + 'static> GliumGraphicsBackend<T> {
|
||||
|
|
|
@ -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<libinput::Device>,
|
||||
}
|
||||
|
@ -423,6 +427,19 @@ impl From<event::pointer::ButtonState> for backend::MouseButtonState {
|
|||
#[cfg(feature = "backend_session")]
|
||||
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")]
|
||||
impl<S: Session> From<S> for LibinputSessionInterface<S> {
|
||||
fn from(session: S) -> LibinputSessionInterface<S> {
|
||||
|
|
|
@ -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")]
|
||||
|
|
|
@ -49,6 +49,7 @@ use nix::{
|
|||
};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
fmt,
|
||||
io::Error as IoError,
|
||||
os::unix::io::RawFd,
|
||||
path::Path,
|
||||
|
@ -70,15 +71,29 @@ struct LogindSessionImpl {
|
|||
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
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LogindSession {
|
||||
internal: Weak<LogindSessionImpl>,
|
||||
seat: String,
|
||||
}
|
||||
|
||||
/// [`SessionNotifier`] via the logind dbus interface
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LogindSessionNotifier {
|
||||
internal: Rc<LogindSessionImpl>,
|
||||
}
|
||||
|
|
|
@ -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<AtomicBool>,
|
||||
|
@ -160,6 +162,25 @@ pub struct DirectSessionNotifier {
|
|||
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 {
|
||||
/// Tries to create a new session via the legacy virtual terminal interface.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue