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:
Mads Marquart 2025-03-03 08:40:04 +01:00 committed by GitHub
parent 39c0862198
commit be1baf164c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 152 additions and 42 deletions

View file

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

View file

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

View file

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

View file

@ -414,6 +414,7 @@ impl WinitPointerDataExt for WlPointer {
}
}
#[derive(Debug)]
pub struct PointerConstraintsState {
pointer_constraints: ZwpPointerConstraintsV1,
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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