[Debug Trait] wayland

wayland/compositor
wayland/data_device
wayland/dmabuf
wayland/explicit_synchronization
wayland/output
wayland/seat
wayland/shell
wayland/shm
This commit is contained in:
Poly 2021-02-12 22:13:38 +01:00
parent aa2a0523bf
commit e9eb698dd0
14 changed files with 119 additions and 14 deletions

View File

@ -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> {
_r: ::std::marker::PhantomData<R>,
}
/// 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,21 @@ pub struct SurfaceAttributes {
pub user_data: UserDataMap,
}
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 +276,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<R> {
_role: ::std::marker::PhantomData<*mut R>,
}
@ -516,6 +534,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
///

View File

@ -28,6 +28,7 @@ pub enum Location {
}
/// Possible actions to do after handling a node diring tree traversal
#[derive(Debug)]
pub enum TraversalAction<T> {
/// Traverse its children as well, providing them the data T
DoChildren(T),

View File

@ -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<wl_data_source::WlDataSource>),
@ -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 {

View File

@ -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),

View File

@ -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<Plane>,

View File

@ -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,

View File

@ -80,6 +80,7 @@ impl From<Serial> 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,

View File

@ -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<Mutex<Inner>>,
}

View File

@ -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,22 @@ struct KbdInternal {
focus_hook: Box<dyn FnMut(Option<&WlSurface>)>,
}
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 +284,7 @@ where
})
}
#[derive(Debug)]
struct KbdRc {
internal: RefCell<KbdInternal>,
keymap: String,
@ -284,7 +302,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<KbdRc>,
}

View File

@ -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<PointerHandle>,
keyboard: Option<KeyboardHandle>,
@ -73,6 +74,17 @@ pub(crate) struct SeatRc {
name: String,
}
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 +115,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<SeatRc>,
}

View File

@ -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,16 @@ enum GrabStatus {
Borrowed,
}
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<WlPointer>,
focus: Option<(WlSurface, (f64, f64))>,
@ -45,6 +55,20 @@ struct PointerInternal {
image_callback: Box<dyn FnMut(CursorImageStatus)>,
}
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<F, R>(token: CompositorToken<R>, mut cb: F) -> PointerInternal
where
@ -125,7 +149,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<RefCell<PointerInternal>>,
}
@ -233,7 +257,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 +311,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,
}

View File

@ -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<R> {
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<R> {
/// A new shell surface was created
///
@ -275,6 +279,7 @@ pub enum ShellRequest<R> {
///
/// This state allows you to retrieve a list of surfaces
/// currently known to the shell global.
#[derive(Debug)]
pub struct ShellState<R> {
known_surfaces: Vec<ShellSurface<R>>,
}

View File

@ -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<wl_surface::WlSurface>,
@ -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<R> {
known_toplevels: Vec<ToplevelSurface<R>>,
known_popups: Vec<PopupSurface<R>>,
@ -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<R> {
kind: ShellClientKind,
_token: CompositorToken<R>,
@ -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<R> {
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<R> {
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<R> {
/// A new shell client was instantiated
NewClient {

View File

@ -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