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
|
|
@ -231,6 +231,7 @@ unsafe extern "C" fn x_error_callback(
|
|||
0
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum EventLoop {
|
||||
#[cfg(wayland_platform)]
|
||||
Wayland(Box<wayland::EventLoop>),
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ pub(crate) enum Event {
|
|||
}
|
||||
|
||||
/// The Wayland event loop.
|
||||
#[derive(Debug)]
|
||||
pub struct EventLoop {
|
||||
/// Has `run` or `run_on_demand` been called or a call to `pump_events` that starts the loop
|
||||
loop_running: bool,
|
||||
|
|
@ -546,6 +547,7 @@ impl AsRawFd for EventLoop {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ActiveEventLoop {
|
||||
/// Event loop proxy
|
||||
event_loop_proxy: CoreEventLoopProxy,
|
||||
|
|
@ -665,6 +667,7 @@ impl rwh_06::HasDisplayHandle for ActiveEventLoop {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OwnedDisplayHandle {
|
||||
pub(crate) connection: Connection,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use sctk::reexports::calloop::ping::Ping;
|
|||
use crate::event_loop::{EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider};
|
||||
|
||||
/// A handle that can be sent across the threads and used to wake up the `EventLoop`.
|
||||
#[derive(Debug)]
|
||||
pub struct EventLoopProxy {
|
||||
ping: Ping,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::window::WindowId;
|
|||
|
||||
/// An event loop's sink to deliver events from the Wayland event callbacks
|
||||
/// to the winit's user.
|
||||
#[derive(Default)]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct EventSink {
|
||||
pub(crate) window_events: Vec<Event>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,6 +414,7 @@ impl WinitPointerDataExt for WlPointer {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PointerConstraintsState {
|
||||
pointer_constraints: ZwpPointerConstraintsV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use crate::event::DeviceEvent;
|
|||
use crate::platform_impl::wayland::state::WinitState;
|
||||
|
||||
/// Wrapper around the relative pointer.
|
||||
#[derive(Debug)]
|
||||
pub struct RelativePointerState {
|
||||
manager: ZwpRelativePointerManagerV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use crate::platform_impl::wayland;
|
|||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::window::ImePurpose;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TextInputState {
|
||||
text_input_manager: ZwpTextInputManagerV3,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ use crate::platform_impl::wayland::window::{WindowRequests, WindowState};
|
|||
use crate::platform_impl::wayland::WindowId;
|
||||
|
||||
/// Winit's Wayland state.
|
||||
#[derive(Debug)]
|
||||
pub struct WinitState {
|
||||
/// The WlRegistry.
|
||||
pub registry_state: RegistryState,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use crate::event_loop::AsyncRequestSerial;
|
|||
use crate::platform_impl::wayland::state::WinitState;
|
||||
use crate::window::{ActivationToken, WindowId};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct XdgActivationState {
|
||||
xdg_activation: XdgActivationV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ pub(crate) mod state;
|
|||
pub use state::WindowState;
|
||||
|
||||
/// The Wayland window.
|
||||
#[derive(Debug)]
|
||||
pub struct Window {
|
||||
/// Reference to the underlying SCTK window.
|
||||
window: SctkWindow,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ pub type WinitFrame = sctk::shell::xdg::fallback_frame::FallbackFrame<WinitState
|
|||
const MIN_WINDOW_SIZE: LogicalSize<u32> = LogicalSize::new(2, 1);
|
||||
|
||||
/// The state of the window which is being updated from the [`WinitState`].
|
||||
#[derive(Debug)]
|
||||
pub struct WindowState {
|
||||
/// The connection to Wayland server.
|
||||
pub handle: Arc<OwnedDisplayHandle>,
|
||||
|
|
@ -1097,7 +1098,7 @@ impl Drop for WindowState {
|
|||
}
|
||||
|
||||
/// The state of the cursor grabs.
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct GrabState {
|
||||
/// The grab mode requested by the user.
|
||||
user_grab_mode: CursorGrabMode,
|
||||
|
|
|
|||
|
|
@ -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