Properly implement Debug for Window and EventLoop types (#3297)
For EventLoop, EventLoopBuilder, EventLoopProxy and by requiring it as a supertrait of Window and ActiveEventLoop. It is especially useful for user to be able to know that Window is Debug.
This commit is contained in:
parent
39c0862198
commit
be1baf164c
43 changed files with 152 additions and 42 deletions
|
|
@ -39,6 +39,7 @@ impl From<io::Error> for DndDataParseError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Dnd {
|
||||
xconn: Arc<XConnection>,
|
||||
// Populated by XdndEnter event handler
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ pub const MAX_MOD_REPLAY_LEN: usize = 32;
|
|||
/// The X11 documentation states: "Keycodes lie in the inclusive range `[8, 255]`".
|
||||
const KEYCODE_OFFSET: u8 = 8;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EventProcessor {
|
||||
pub dnd: Dnd,
|
||||
pub ime_receiver: ImeReceiver,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ mod context;
|
|||
mod inner;
|
||||
mod input_method;
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::mpsc::{Receiver, Sender};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -56,6 +57,12 @@ pub(crate) struct Ime {
|
|||
inner: Box<ImeInner>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Ime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Ime").finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl Ime {
|
||||
pub fn new(
|
||||
xconn: Arc<XConnection>,
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ type X11rbConnection = x11rb::xcb_ffi::XCBConnection;
|
|||
|
||||
type X11Source = Generic<BorrowedFd<'static>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct WakeSender<T> {
|
||||
sender: Sender<T>,
|
||||
waker: Ping,
|
||||
|
|
@ -91,6 +92,7 @@ impl<T> WakeSender<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct PeekableReceiver<T> {
|
||||
recv: Receiver<T>,
|
||||
first: Option<T>,
|
||||
|
|
@ -127,6 +129,7 @@ impl<T> PeekableReceiver<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ActiveEventLoop {
|
||||
xconn: Arc<XConnection>,
|
||||
wm_delete_window: xproto::Atom,
|
||||
|
|
@ -144,6 +147,7 @@ pub struct ActiveEventLoop {
|
|||
device_events: Cell<DeviceEvents>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EventLoop {
|
||||
loop_running: bool,
|
||||
event_loop: Loop<'static, EventLoopState>,
|
||||
|
|
@ -157,6 +161,7 @@ pub struct EventLoop {
|
|||
|
||||
type ActivationToken = (WindowId, crate::event_loop::AsyncRequestSerial);
|
||||
|
||||
#[derive(Debug)]
|
||||
struct EventLoopState {
|
||||
/// The latest readiness state for the x11 file descriptor
|
||||
x11_readiness: Readiness,
|
||||
|
|
@ -762,7 +767,7 @@ impl Deref for DeviceInfo<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct EventLoopProxy {
|
||||
ping: Ping,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ use crate::window::{
|
|||
WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Window(Arc<UnownedWindow>);
|
||||
|
||||
impl Deref for Window {
|
||||
|
|
@ -411,6 +412,7 @@ impl SharedState {
|
|||
unsafe impl Send for UnownedWindow {}
|
||||
unsafe impl Sync for UnownedWindow {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UnownedWindow {
|
||||
pub(crate) xconn: Arc<XConnection>, // never changes
|
||||
xwindow: xproto::Window, // never changes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue