Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/child_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn main() -> Result<(), impl std::error::Error> {
#[path = "util/fill.rs"]
mod fill;

#[derive(Debug)]
struct WindowData {
window: Box<dyn Window>,
color: u32,
Expand All @@ -24,7 +25,7 @@ fn main() -> Result<(), impl std::error::Error> {
}
}

#[derive(Default)]
#[derive(Default, Debug)]
struct Application {
parent_window_id: Option<WindowId>,
windows: HashMap<WindowId, WindowData>,
Expand Down
2 changes: 1 addition & 1 deletion examples/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn main() -> Result<(), impl std::error::Error> {
event_loop.run_app(ControlFlowDemo::default())
}

#[derive(Default)]
#[derive(Default, Debug)]
struct ControlFlowDemo {
mode: Mode,
request_redraw: bool,
Expand Down
1 change: 1 addition & 0 deletions examples/dnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn main() -> Result<(), Box<dyn Error>> {
}

/// Application state and event handling.
#[derive(Debug)]
struct Application {
window: Option<Box<dyn Window>>,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/pump_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() -> std::process::ExitCode {
#[path = "util/fill.rs"]
mod fill;

#[derive(Default)]
#[derive(Default, Debug)]
struct PumpDemo {
window: Option<Box<dyn Window>>,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/run_on_demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
#[path = "util/fill.rs"]
mod fill;

#[derive(Default)]
#[derive(Default, Debug)]
struct App {
idx: usize,
window_id: Option<WindowId>,
Expand Down
2 changes: 1 addition & 1 deletion examples/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use winit::window::{Window, WindowAttributes, WindowId};
#[path = "util/fill.rs"]
mod fill;

#[derive(Default)]
#[derive(Default, Debug)]
struct App {
window: Option<Box<dyn Window>>,
}
Expand Down
1 change: 1 addition & 0 deletions examples/x11_embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fn main() -> Result<(), Box<dyn Error>> {
#[path = "util/fill.rs"]
mod fill;

#[derive(Debug)]
pub struct XEmbedDemo {
parent_window_id: u32,
window: Option<Box<dyn Window>>,
Expand Down
27 changes: 5 additions & 22 deletions src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::window::{CustomCursor, CustomCursorSource, Theme, Window, WindowAttri
/// [`EventLoopProxy`] allows you to wake up an `EventLoop` from another thread.
///
/// [`Window`]: crate::window::Window
#[derive(Debug)]
pub struct EventLoop {
pub(crate) event_loop: platform_impl::EventLoop,
pub(crate) _marker: PhantomData<*mut ()>, // Not Send nor Sync
Expand All @@ -54,7 +55,7 @@ pub struct EventLoop {
/// easier. But note that constructing multiple event loops is not supported.
///
/// This can be created using [`EventLoop::builder`].
#[derive(Default, PartialEq, Eq, Hash)]
#[derive(Default, Debug, PartialEq, Eq, Hash)]
pub struct EventLoopBuilder {
pub(crate) platform_specific: platform_impl::PlatformSpecificEventLoopAttributes,
}
Expand Down Expand Up @@ -117,18 +118,6 @@ impl EventLoopBuilder {
}
}

impl fmt::Debug for EventLoopBuilder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EventLoopBuilder").finish_non_exhaustive()
}
}

impl fmt::Debug for EventLoop {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EventLoop").finish_non_exhaustive()
}
}

/// Set through [`ActiveEventLoop::set_control_flow()`].
///
/// Indicates the desired behavior of the event loop after [`about_to_wait`] is called.
Expand Down Expand Up @@ -309,7 +298,7 @@ impl AsRawFd for EventLoop {
}
}

pub trait ActiveEventLoop: AsAny {
pub trait ActiveEventLoop: AsAny + fmt::Debug {
/// Creates an [`EventLoopProxy`] that can be used to dispatch user events
/// to the main event loop, possibly from another thread.
fn create_proxy(&self) -> EventLoopProxy;
Expand Down Expand Up @@ -463,23 +452,17 @@ impl PartialEq for OwnedDisplayHandle {

impl Eq for OwnedDisplayHandle {}

pub(crate) trait EventLoopProxyProvider: Send + Sync {
pub(crate) trait EventLoopProxyProvider: Send + Sync + fmt::Debug {
/// See [`EventLoopProxy::wake_up`] for details.
fn wake_up(&self);
}

/// Control the [`EventLoop`], possibly from a different thread, without referencing it directly.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct EventLoopProxy {
pub(crate) proxy: Arc<dyn EventLoopProxyProvider>,
}

impl fmt::Debug for EventLoopProxy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EventLoopProxy").finish_non_exhaustive()
}
}

impl EventLoopProxy {
/// Wake up the [`EventLoop`], resulting in [`ApplicationHandler::proxy_wake_up()`] being
/// called.
Expand Down
18 changes: 17 additions & 1 deletion src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn min_timeout(a: Option<Duration>, b: Option<Duration>) -> Option<Duration> {
a.map_or(b, |a_timeout| b.map_or(Some(a_timeout), |b_timeout| Some(a_timeout.min(b_timeout))))
}

#[derive(Clone)]
#[derive(Clone, Debug)]
struct SharedFlagSetter {
flag: Arc<AtomicBool>,
}
Expand All @@ -54,6 +54,7 @@ impl SharedFlagSetter {
}
}

#[derive(Debug)]
struct SharedFlag {
flag: Arc<AtomicBool>,
}
Expand Down Expand Up @@ -82,6 +83,12 @@ pub struct RedrawRequester {
waker: AndroidAppWaker,
}

impl fmt::Debug for RedrawRequester {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RedrawRequester").field("flag", &self.flag).finish_non_exhaustive()
}
}

impl RedrawRequester {
fn new(flag: &SharedFlag, waker: AndroidAppWaker) -> Self {
RedrawRequester { flag: flag.setter(), waker }
Expand All @@ -96,6 +103,7 @@ impl RedrawRequester {
}
}

#[derive(Debug)]
pub struct EventLoop {
pub(crate) android_app: AndroidApp,
window_target: ActiveEventLoop,
Expand Down Expand Up @@ -639,6 +647,12 @@ pub struct EventLoopProxy {
waker: AndroidAppWaker,
}

impl fmt::Debug for EventLoopProxy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EventLoopProxy").field("wake_up", &self.wake_up).finish_non_exhaustive()
}
}

impl EventLoopProxy {
fn new(waker: AndroidAppWaker) -> Self {
Self { wake_up: AtomicBool::new(false), waker }
Expand All @@ -652,6 +666,7 @@ impl EventLoopProxyProvider for EventLoopProxy {
}
}

#[derive(Debug)]
pub struct ActiveEventLoop {
pub(crate) app: AndroidApp,
control_flow: Cell<ControlFlow>,
Expand Down Expand Up @@ -744,6 +759,7 @@ impl rwh_06::HasDisplayHandle for OwnedDisplayHandle {
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct PlatformSpecificWindowAttributes;

#[derive(Debug)]
pub(crate) struct Window {
app: AndroidApp,
redraw_requester: RedrawRequester,
Expand Down
8 changes: 8 additions & 0 deletions src/platform_impl/apple/appkit/event_loop.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::any::Any;
use std::cell::Cell;
use std::fmt;
use std::panic::{catch_unwind, resume_unwind, RefUnwindSafe, UnwindSafe};
use std::rc::{Rc, Weak};
use std::sync::Arc;
Expand Down Expand Up @@ -39,6 +40,12 @@ pub struct PanicInfo {
inner: Cell<Option<Box<dyn Any + Send + 'static>>>,
}

impl fmt::Debug for PanicInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PanicInfo").finish_non_exhaustive()
}
}

// WARNING:
// As long as this struct is used through its `impl`, it is UnwindSafe.
// (If `get_mut` is called on `inner`, unwind safety may get broken.)
Expand Down Expand Up @@ -161,6 +168,7 @@ impl rwh_06::HasDisplayHandle for ActiveEventLoop {
}
}

#[derive(Debug)]
pub struct EventLoop {
/// Store a reference to the application for convenience.
///
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/apple/appkit/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::window::{
WindowAttributes, WindowButtons, WindowId, WindowLevel,
};

#[derive(Debug)]
pub(crate) struct Window {
window: MainThreadBound<Retained<NSWindow>>,
/// The window only keeps a weak reference to this, so we must keep it around here.
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/apple/uikit/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl HasDisplayHandle for OwnedDisplayHandle {
}
}

#[derive(Debug)]
pub struct EventLoop {
mtm: MainThreadMarker,
window_target: ActiveEventLoop,
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/apple/uikit/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ impl Inner {
}
}

#[derive(Debug)]
pub struct Window {
inner: MainThreadBound<Inner>,
}
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ unsafe extern "C" fn x_error_callback(
0
}

#[derive(Debug)]
pub enum EventLoop {
#[cfg(wayland_platform)]
Wayland(Box<wayland::EventLoop>),
Expand Down
3 changes: 3 additions & 0 deletions src/platform_impl/linux/wayland/event_loop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -546,6 +547,7 @@ impl AsRawFd for EventLoop {
}
}

#[derive(Debug)]
pub struct ActiveEventLoop {
/// Event loop proxy
event_loop_proxy: CoreEventLoopProxy,
Expand Down Expand Up @@ -665,6 +667,7 @@ impl rwh_06::HasDisplayHandle for ActiveEventLoop {
}
}

#[derive(Debug)]
pub struct OwnedDisplayHandle {
pub(crate) connection: Connection,
}
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/wayland/event_loop/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/linux/wayland/event_loop/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/wayland/seat/pointer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ impl WinitPointerDataExt for WlPointer {
}
}

#[derive(Debug)]
pub struct PointerConstraintsState {
pointer_constraints: ZwpPointerConstraintsV1,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/wayland/seat/text_input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/wayland/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/wayland/types/xdg_activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/wayland/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/platform_impl/linux/wayland/window/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/x11/dnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl From<io::Error> for DndDataParseError {
}
}

#[derive(Debug)]
pub struct Dnd {
xconn: Arc<XConnection>,
// Populated by XdndEnter event handler
Expand Down
1 change: 1 addition & 0 deletions src/platform_impl/linux/x11/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading