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
|
|
@ -13,6 +13,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
#[path = "util/fill.rs"]
|
#[path = "util/fill.rs"]
|
||||||
mod fill;
|
mod fill;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct WindowData {
|
struct WindowData {
|
||||||
window: Box<dyn Window>,
|
window: Box<dyn Window>,
|
||||||
color: u32,
|
color: u32,
|
||||||
|
|
@ -24,7 +25,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
struct Application {
|
struct Application {
|
||||||
parent_window_id: Option<WindowId>,
|
parent_window_id: Option<WindowId>,
|
||||||
windows: HashMap<WindowId, WindowData>,
|
windows: HashMap<WindowId, WindowData>,
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
event_loop.run_app(ControlFlowDemo::default())
|
event_loop.run_app(ControlFlowDemo::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
struct ControlFlowDemo {
|
struct ControlFlowDemo {
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
request_redraw: bool,
|
request_redraw: bool,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Application state and event handling.
|
/// Application state and event handling.
|
||||||
|
#[derive(Debug)]
|
||||||
struct Application {
|
struct Application {
|
||||||
window: Option<Box<dyn Window>>,
|
window: Option<Box<dyn Window>>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ fn main() -> std::process::ExitCode {
|
||||||
#[path = "util/fill.rs"]
|
#[path = "util/fill.rs"]
|
||||||
mod fill;
|
mod fill;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
struct PumpDemo {
|
struct PumpDemo {
|
||||||
window: Option<Box<dyn Window>>,
|
window: Option<Box<dyn Window>>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
#[path = "util/fill.rs"]
|
#[path = "util/fill.rs"]
|
||||||
mod fill;
|
mod fill;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
struct App {
|
struct App {
|
||||||
idx: usize,
|
idx: usize,
|
||||||
window_id: Option<WindowId>,
|
window_id: Option<WindowId>,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use winit::window::{Window, WindowAttributes, WindowId};
|
||||||
#[path = "util/fill.rs"]
|
#[path = "util/fill.rs"]
|
||||||
mod fill;
|
mod fill;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
struct App {
|
struct App {
|
||||||
window: Option<Box<dyn Window>>,
|
window: Option<Box<dyn Window>>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
#[path = "util/fill.rs"]
|
#[path = "util/fill.rs"]
|
||||||
mod fill;
|
mod fill;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct XEmbedDemo {
|
pub struct XEmbedDemo {
|
||||||
parent_window_id: u32,
|
parent_window_id: u32,
|
||||||
window: Option<Box<dyn Window>>,
|
window: Option<Box<dyn Window>>,
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ use crate::window::{CustomCursor, CustomCursorSource, Theme, Window, WindowAttri
|
||||||
/// [`EventLoopProxy`] allows you to wake up an `EventLoop` from another thread.
|
/// [`EventLoopProxy`] allows you to wake up an `EventLoop` from another thread.
|
||||||
///
|
///
|
||||||
/// [`Window`]: crate::window::Window
|
/// [`Window`]: crate::window::Window
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
pub(crate) event_loop: platform_impl::EventLoop,
|
pub(crate) event_loop: platform_impl::EventLoop,
|
||||||
pub(crate) _marker: PhantomData<*mut ()>, // Not Send nor Sync
|
pub(crate) _marker: PhantomData<*mut ()>, // Not Send nor Sync
|
||||||
|
|
@ -54,7 +55,7 @@ pub struct EventLoop {
|
||||||
/// easier. But note that constructing multiple event loops is not supported.
|
/// easier. But note that constructing multiple event loops is not supported.
|
||||||
///
|
///
|
||||||
/// This can be created using [`EventLoop::builder`].
|
/// This can be created using [`EventLoop::builder`].
|
||||||
#[derive(Default, PartialEq, Eq, Hash)]
|
#[derive(Default, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct EventLoopBuilder {
|
pub struct EventLoopBuilder {
|
||||||
pub(crate) platform_specific: platform_impl::PlatformSpecificEventLoopAttributes,
|
pub(crate) platform_specific: platform_impl::PlatformSpecificEventLoopAttributes,
|
||||||
}
|
}
|
||||||
|
|
@ -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()`].
|
/// Set through [`ActiveEventLoop::set_control_flow()`].
|
||||||
///
|
///
|
||||||
/// Indicates the desired behavior of the event loop after [`about_to_wait`] is called.
|
/// Indicates the desired behavior of the event loop after [`about_to_wait`] is called.
|
||||||
|
|
@ -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
|
/// Creates an [`EventLoopProxy`] that can be used to dispatch user events
|
||||||
/// to the main event loop, possibly from another thread.
|
/// to the main event loop, possibly from another thread.
|
||||||
fn create_proxy(&self) -> EventLoopProxy;
|
fn create_proxy(&self) -> EventLoopProxy;
|
||||||
|
|
@ -463,23 +452,17 @@ impl PartialEq for OwnedDisplayHandle {
|
||||||
|
|
||||||
impl Eq 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.
|
/// See [`EventLoopProxy::wake_up`] for details.
|
||||||
fn wake_up(&self);
|
fn wake_up(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Control the [`EventLoop`], possibly from a different thread, without referencing it directly.
|
/// Control the [`EventLoop`], possibly from a different thread, without referencing it directly.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct EventLoopProxy {
|
pub struct EventLoopProxy {
|
||||||
pub(crate) proxy: Arc<dyn EventLoopProxyProvider>,
|
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 {
|
impl EventLoopProxy {
|
||||||
/// Wake up the [`EventLoop`], resulting in [`ApplicationHandler::proxy_wake_up()`] being
|
/// Wake up the [`EventLoop`], resulting in [`ApplicationHandler::proxy_wake_up()`] being
|
||||||
/// called.
|
/// called.
|
||||||
|
|
|
||||||
|
|
@ -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))))
|
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 {
|
struct SharedFlagSetter {
|
||||||
flag: Arc<AtomicBool>,
|
flag: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +54,7 @@ impl SharedFlagSetter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct SharedFlag {
|
struct SharedFlag {
|
||||||
flag: Arc<AtomicBool>,
|
flag: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +83,12 @@ pub struct RedrawRequester {
|
||||||
waker: AndroidAppWaker,
|
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 {
|
impl RedrawRequester {
|
||||||
fn new(flag: &SharedFlag, waker: AndroidAppWaker) -> Self {
|
fn new(flag: &SharedFlag, waker: AndroidAppWaker) -> Self {
|
||||||
RedrawRequester { flag: flag.setter(), waker }
|
RedrawRequester { flag: flag.setter(), waker }
|
||||||
|
|
@ -96,6 +103,7 @@ impl RedrawRequester {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
pub(crate) android_app: AndroidApp,
|
pub(crate) android_app: AndroidApp,
|
||||||
window_target: ActiveEventLoop,
|
window_target: ActiveEventLoop,
|
||||||
|
|
@ -639,6 +647,12 @@ pub struct EventLoopProxy {
|
||||||
waker: AndroidAppWaker,
|
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 {
|
impl EventLoopProxy {
|
||||||
fn new(waker: AndroidAppWaker) -> Self {
|
fn new(waker: AndroidAppWaker) -> Self {
|
||||||
Self { wake_up: AtomicBool::new(false), waker }
|
Self { wake_up: AtomicBool::new(false), waker }
|
||||||
|
|
@ -652,6 +666,7 @@ impl EventLoopProxyProvider for EventLoopProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ActiveEventLoop {
|
pub struct ActiveEventLoop {
|
||||||
pub(crate) app: AndroidApp,
|
pub(crate) app: AndroidApp,
|
||||||
control_flow: Cell<ControlFlow>,
|
control_flow: Cell<ControlFlow>,
|
||||||
|
|
@ -744,6 +759,7 @@ impl rwh_06::HasDisplayHandle for OwnedDisplayHandle {
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||||
pub struct PlatformSpecificWindowAttributes;
|
pub struct PlatformSpecificWindowAttributes;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct Window {
|
pub(crate) struct Window {
|
||||||
app: AndroidApp,
|
app: AndroidApp,
|
||||||
redraw_requester: RedrawRequester,
|
redraw_requester: RedrawRequester,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::fmt;
|
||||||
use std::panic::{catch_unwind, resume_unwind, RefUnwindSafe, UnwindSafe};
|
use std::panic::{catch_unwind, resume_unwind, RefUnwindSafe, UnwindSafe};
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
@ -39,6 +40,12 @@ pub struct PanicInfo {
|
||||||
inner: Cell<Option<Box<dyn Any + Send + 'static>>>,
|
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:
|
// WARNING:
|
||||||
// As long as this struct is used through its `impl`, it is UnwindSafe.
|
// 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.)
|
// (If `get_mut` is called on `inner`, unwind safety may get broken.)
|
||||||
|
|
@ -161,6 +168,7 @@ impl rwh_06::HasDisplayHandle for ActiveEventLoop {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
/// Store a reference to the application for convenience.
|
/// Store a reference to the application for convenience.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use crate::window::{
|
||||||
WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct Window {
|
pub(crate) struct Window {
|
||||||
window: MainThreadBound<Retained<NSWindow>>,
|
window: MainThreadBound<Retained<NSWindow>>,
|
||||||
/// The window only keeps a weak reference to this, so we must keep it around here.
|
/// The window only keeps a weak reference to this, so we must keep it around here.
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ impl HasDisplayHandle for OwnedDisplayHandle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
mtm: MainThreadMarker,
|
mtm: MainThreadMarker,
|
||||||
window_target: ActiveEventLoop,
|
window_target: ActiveEventLoop,
|
||||||
|
|
|
||||||
|
|
@ -459,6 +459,7 @@ impl Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
inner: MainThreadBound<Inner>,
|
inner: MainThreadBound<Inner>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,7 @@ unsafe extern "C" fn x_error_callback(
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum EventLoop {
|
pub enum EventLoop {
|
||||||
#[cfg(wayland_platform)]
|
#[cfg(wayland_platform)]
|
||||||
Wayland(Box<wayland::EventLoop>),
|
Wayland(Box<wayland::EventLoop>),
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ pub(crate) enum Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The Wayland event loop.
|
/// The Wayland event loop.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
/// Has `run` or `run_on_demand` been called or a call to `pump_events` that starts the loop
|
/// Has `run` or `run_on_demand` been called or a call to `pump_events` that starts the loop
|
||||||
loop_running: bool,
|
loop_running: bool,
|
||||||
|
|
@ -546,6 +547,7 @@ impl AsRawFd for EventLoop {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ActiveEventLoop {
|
pub struct ActiveEventLoop {
|
||||||
/// Event loop proxy
|
/// Event loop proxy
|
||||||
event_loop_proxy: CoreEventLoopProxy,
|
event_loop_proxy: CoreEventLoopProxy,
|
||||||
|
|
@ -665,6 +667,7 @@ impl rwh_06::HasDisplayHandle for ActiveEventLoop {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct OwnedDisplayHandle {
|
pub struct OwnedDisplayHandle {
|
||||||
pub(crate) connection: Connection,
|
pub(crate) connection: Connection,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use sctk::reexports::calloop::ping::Ping;
|
||||||
use crate::event_loop::{EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider};
|
use crate::event_loop::{EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider};
|
||||||
|
|
||||||
/// A handle that can be sent across the threads and used to wake up the `EventLoop`.
|
/// A handle that can be sent across the threads and used to wake up the `EventLoop`.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoopProxy {
|
pub struct EventLoopProxy {
|
||||||
ping: Ping,
|
ping: Ping,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::window::WindowId;
|
||||||
|
|
||||||
/// An event loop's sink to deliver events from the Wayland event callbacks
|
/// An event loop's sink to deliver events from the Wayland event callbacks
|
||||||
/// to the winit's user.
|
/// to the winit's user.
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
pub struct EventSink {
|
pub struct EventSink {
|
||||||
pub(crate) window_events: Vec<Event>,
|
pub(crate) window_events: Vec<Event>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,7 @@ impl WinitPointerDataExt for WlPointer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct PointerConstraintsState {
|
pub struct PointerConstraintsState {
|
||||||
pointer_constraints: ZwpPointerConstraintsV1,
|
pointer_constraints: ZwpPointerConstraintsV1,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use crate::event::DeviceEvent;
|
||||||
use crate::platform_impl::wayland::state::WinitState;
|
use crate::platform_impl::wayland::state::WinitState;
|
||||||
|
|
||||||
/// Wrapper around the relative pointer.
|
/// Wrapper around the relative pointer.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct RelativePointerState {
|
pub struct RelativePointerState {
|
||||||
manager: ZwpRelativePointerManagerV1,
|
manager: ZwpRelativePointerManagerV1,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ use crate::platform_impl::wayland;
|
||||||
use crate::platform_impl::wayland::state::WinitState;
|
use crate::platform_impl::wayland::state::WinitState;
|
||||||
use crate::window::ImePurpose;
|
use crate::window::ImePurpose;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct TextInputState {
|
pub struct TextInputState {
|
||||||
text_input_manager: ZwpTextInputManagerV3,
|
text_input_manager: ZwpTextInputManagerV3,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ use crate::platform_impl::wayland::window::{WindowRequests, WindowState};
|
||||||
use crate::platform_impl::wayland::WindowId;
|
use crate::platform_impl::wayland::WindowId;
|
||||||
|
|
||||||
/// Winit's Wayland state.
|
/// Winit's Wayland state.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct WinitState {
|
pub struct WinitState {
|
||||||
/// The WlRegistry.
|
/// The WlRegistry.
|
||||||
pub registry_state: RegistryState,
|
pub registry_state: RegistryState,
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use crate::event_loop::AsyncRequestSerial;
|
||||||
use crate::platform_impl::wayland::state::WinitState;
|
use crate::platform_impl::wayland::state::WinitState;
|
||||||
use crate::window::{ActivationToken, WindowId};
|
use crate::window::{ActivationToken, WindowId};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct XdgActivationState {
|
pub struct XdgActivationState {
|
||||||
xdg_activation: XdgActivationV1,
|
xdg_activation: XdgActivationV1,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ pub(crate) mod state;
|
||||||
pub use state::WindowState;
|
pub use state::WindowState;
|
||||||
|
|
||||||
/// The Wayland window.
|
/// The Wayland window.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
/// Reference to the underlying SCTK window.
|
/// Reference to the underlying SCTK window.
|
||||||
window: SctkWindow,
|
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);
|
const MIN_WINDOW_SIZE: LogicalSize<u32> = LogicalSize::new(2, 1);
|
||||||
|
|
||||||
/// The state of the window which is being updated from the [`WinitState`].
|
/// The state of the window which is being updated from the [`WinitState`].
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct WindowState {
|
pub struct WindowState {
|
||||||
/// The connection to Wayland server.
|
/// The connection to Wayland server.
|
||||||
pub handle: Arc<OwnedDisplayHandle>,
|
pub handle: Arc<OwnedDisplayHandle>,
|
||||||
|
|
@ -1097,7 +1098,7 @@ impl Drop for WindowState {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The state of the cursor grabs.
|
/// The state of the cursor grabs.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
struct GrabState {
|
struct GrabState {
|
||||||
/// The grab mode requested by the user.
|
/// The grab mode requested by the user.
|
||||||
user_grab_mode: CursorGrabMode,
|
user_grab_mode: CursorGrabMode,
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ impl From<io::Error> for DndDataParseError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Dnd {
|
pub struct Dnd {
|
||||||
xconn: Arc<XConnection>,
|
xconn: Arc<XConnection>,
|
||||||
// Populated by XdndEnter event handler
|
// 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]`".
|
/// The X11 documentation states: "Keycodes lie in the inclusive range `[8, 255]`".
|
||||||
const KEYCODE_OFFSET: u8 = 8;
|
const KEYCODE_OFFSET: u8 = 8;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventProcessor {
|
pub struct EventProcessor {
|
||||||
pub dnd: Dnd,
|
pub dnd: Dnd,
|
||||||
pub ime_receiver: ImeReceiver,
|
pub ime_receiver: ImeReceiver,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ mod context;
|
||||||
mod inner;
|
mod inner;
|
||||||
mod input_method;
|
mod input_method;
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
@ -56,6 +57,12 @@ pub(crate) struct Ime {
|
||||||
inner: Box<ImeInner>,
|
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 {
|
impl Ime {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
xconn: Arc<XConnection>,
|
xconn: Arc<XConnection>,
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ type X11rbConnection = x11rb::xcb_ffi::XCBConnection;
|
||||||
|
|
||||||
type X11Source = Generic<BorrowedFd<'static>>;
|
type X11Source = Generic<BorrowedFd<'static>>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct WakeSender<T> {
|
struct WakeSender<T> {
|
||||||
sender: Sender<T>,
|
sender: Sender<T>,
|
||||||
waker: Ping,
|
waker: Ping,
|
||||||
|
|
@ -91,6 +92,7 @@ impl<T> WakeSender<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct PeekableReceiver<T> {
|
struct PeekableReceiver<T> {
|
||||||
recv: Receiver<T>,
|
recv: Receiver<T>,
|
||||||
first: Option<T>,
|
first: Option<T>,
|
||||||
|
|
@ -127,6 +129,7 @@ impl<T> PeekableReceiver<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ActiveEventLoop {
|
pub struct ActiveEventLoop {
|
||||||
xconn: Arc<XConnection>,
|
xconn: Arc<XConnection>,
|
||||||
wm_delete_window: xproto::Atom,
|
wm_delete_window: xproto::Atom,
|
||||||
|
|
@ -144,6 +147,7 @@ pub struct ActiveEventLoop {
|
||||||
device_events: Cell<DeviceEvents>,
|
device_events: Cell<DeviceEvents>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
loop_running: bool,
|
loop_running: bool,
|
||||||
event_loop: Loop<'static, EventLoopState>,
|
event_loop: Loop<'static, EventLoopState>,
|
||||||
|
|
@ -157,6 +161,7 @@ pub struct EventLoop {
|
||||||
|
|
||||||
type ActivationToken = (WindowId, crate::event_loop::AsyncRequestSerial);
|
type ActivationToken = (WindowId, crate::event_loop::AsyncRequestSerial);
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct EventLoopState {
|
struct EventLoopState {
|
||||||
/// The latest readiness state for the x11 file descriptor
|
/// The latest readiness state for the x11 file descriptor
|
||||||
x11_readiness: Readiness,
|
x11_readiness: Readiness,
|
||||||
|
|
@ -762,7 +767,7 @@ impl Deref for DeviceInfo<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct EventLoopProxy {
|
pub struct EventLoopProxy {
|
||||||
ping: Ping,
|
ping: Ping,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ use crate::window::{
|
||||||
WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct Window(Arc<UnownedWindow>);
|
pub(crate) struct Window(Arc<UnownedWindow>);
|
||||||
|
|
||||||
impl Deref for Window {
|
impl Deref for Window {
|
||||||
|
|
@ -411,6 +412,7 @@ impl SharedState {
|
||||||
unsafe impl Send for UnownedWindow {}
|
unsafe impl Send for UnownedWindow {}
|
||||||
unsafe impl Sync for UnownedWindow {}
|
unsafe impl Sync for UnownedWindow {}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct UnownedWindow {
|
pub struct UnownedWindow {
|
||||||
pub(crate) xconn: Arc<XConnection>, // never changes
|
pub(crate) xconn: Arc<XConnection>, // never changes
|
||||||
xwindow: xproto::Window, // never changes
|
xwindow: xproto::Window, // never changes
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
struct EventState {
|
struct EventState {
|
||||||
keyboard: KeyboardModifierState,
|
keyboard: KeyboardModifierState,
|
||||||
mouse: MouseButtonState,
|
mouse: MouseButtonState,
|
||||||
|
|
@ -274,6 +274,7 @@ impl EventState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
windows: Vec<(Arc<RedoxSocket>, EventState)>,
|
windows: Vec<(Arc<RedoxSocket>, EventState)>,
|
||||||
window_target: ActiveEventLoop,
|
window_target: ActiveEventLoop,
|
||||||
|
|
@ -661,6 +662,7 @@ impl EventLoop {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoopProxy {
|
pub struct EventLoopProxy {
|
||||||
user_events_sender: mpsc::SyncSender<()>,
|
user_events_sender: mpsc::SyncSender<()>,
|
||||||
pub(super) wake_socket: TimeSocket,
|
pub(super) wake_socket: TimeSocket,
|
||||||
|
|
@ -678,6 +680,7 @@ impl EventLoopProxyProvider for EventLoopProxy {
|
||||||
|
|
||||||
impl Unpin for EventLoopProxy {}
|
impl Unpin for EventLoopProxy {}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ActiveEventLoop {
|
pub struct ActiveEventLoop {
|
||||||
control_flow: Cell<ControlFlow>,
|
control_flow: Cell<ControlFlow>,
|
||||||
exit: Cell<bool>,
|
exit: Cell<bool>,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ pub(crate) use crate::cursor::{
|
||||||
};
|
};
|
||||||
pub(crate) use crate::icon::NoIcon as PlatformIcon;
|
pub(crate) use crate::icon::NoIcon as PlatformIcon;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct RedoxSocket {
|
struct RedoxSocket {
|
||||||
fd: usize,
|
fd: usize,
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +68,7 @@ impl Drop for RedoxSocket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct TimeSocket(RedoxSocket);
|
pub struct TimeSocket(RedoxSocket);
|
||||||
|
|
||||||
impl TimeSocket {
|
impl TimeSocket {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ const ORBITAL_FLAG_MAXIMIZED: char = 'm';
|
||||||
const ORBITAL_FLAG_RESIZABLE: char = 'r';
|
const ORBITAL_FLAG_RESIZABLE: char = 'r';
|
||||||
const ORBITAL_FLAG_TRANSPARENT: char = 't';
|
const ORBITAL_FLAG_TRANSPARENT: char = 't';
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
window_socket: Arc<RedoxSocket>,
|
window_socket: Arc<RedoxSocket>,
|
||||||
redraws: Arc<Mutex<VecDeque<WindowId>>>,
|
redraws: Arc<Mutex<VecDeque<WindowId>>>,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use super::super::main_thread::MainThreadMarker;
|
||||||
|
|
||||||
// Unsafe wrapper type that allows us to use `T` when it's not `Send` from other threads.
|
// Unsafe wrapper type that allows us to use `T` when it's not `Send` from other threads.
|
||||||
// `value` **must** only be accessed on the main thread.
|
// `value` **must** only be accessed on the main thread.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Wrapper<V: 'static, S: Clone + Send, E> {
|
pub struct Wrapper<V: 'static, S: Clone + Send, E> {
|
||||||
value: Value<V>,
|
value: Value<V>,
|
||||||
handler: fn(&RefCell<Option<V>>, E),
|
handler: fn(&RefCell<Option<V>>, E),
|
||||||
|
|
@ -16,6 +17,7 @@ pub struct Wrapper<V: 'static, S: Clone + Send, E> {
|
||||||
sender_handler: fn(&S, E),
|
sender_handler: fn(&S, E),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct Value<V> {
|
struct Value<V> {
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// This value must not be accessed if not on the main thread.
|
// This value must not be accessed if not on the main thread.
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ mod window_target;
|
||||||
|
|
||||||
pub(crate) use window_target::ActiveEventLoop;
|
pub(crate) use window_target::ActiveEventLoop;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
elw: ActiveEventLoop,
|
elw: ActiveEventLoop,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ use crate::event_loop::EventLoopProxyProvider;
|
||||||
use crate::platform_impl::web::event_loop::runner::WeakShared;
|
use crate::platform_impl::web::event_loop::runner::WeakShared;
|
||||||
use crate::platform_impl::web::r#async::{AtomicWaker, Wrapper};
|
use crate::platform_impl::web::r#async::{AtomicWaker, Wrapper};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoopProxy(Wrapper<WeakShared, Arc<State>, ()>);
|
pub struct EventLoopProxy(Wrapper<WeakShared, Arc<State>, ()>);
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct State {
|
struct State {
|
||||||
awoken: AtomicBool,
|
awoken: AtomicBool,
|
||||||
waker: AtomicWaker,
|
waker: AtomicWaker,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::{HashSet, VecDeque};
|
use std::collections::{HashSet, VecDeque};
|
||||||
use std::iter;
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{fmt, iter};
|
||||||
|
|
||||||
use wasm_bindgen::prelude::Closure;
|
use wasm_bindgen::prelude::Closure;
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
@ -26,6 +26,7 @@ use crate::platform_impl::platform::r#async::DispatchRunner;
|
||||||
use crate::platform_impl::platform::window::Inner;
|
use crate::platform_impl::platform::window::Inner;
|
||||||
use crate::window::WindowId;
|
use crate::window::WindowId;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Shared(Rc<Execution>);
|
pub struct Shared(Rc<Execution>);
|
||||||
|
|
||||||
impl Clone for Shared {
|
impl Clone for Shared {
|
||||||
|
|
@ -68,6 +69,12 @@ struct Execution {
|
||||||
on_visibility_change: OnEventHandle<web_sys::Event>,
|
on_visibility_change: OnEventHandle<web_sys::Event>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Execution {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("Execution").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum RunnerEnum {
|
enum RunnerEnum {
|
||||||
/// The `EventLoop` is created but not being run.
|
/// The `EventLoop` is created but not being run.
|
||||||
Pending,
|
Pending,
|
||||||
|
|
@ -96,6 +103,16 @@ struct Runner {
|
||||||
event_loop: ActiveEventLoop,
|
event_loop: ActiveEventLoop,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Runner {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("Runner")
|
||||||
|
.field("state", &self.state)
|
||||||
|
.field("app", &"<ApplicationHandler>")
|
||||||
|
.field("event_loop", &self.event_loop)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Runner {
|
impl Runner {
|
||||||
pub fn new(app: Box<dyn ApplicationHandler>, event_loop: ActiveEventLoop) -> Self {
|
pub fn new(app: Box<dyn ApplicationHandler>, event_loop: ActiveEventLoop) -> Self {
|
||||||
Runner { state: State::Init, app, event_loop }
|
Runner { state: State::Init, app, event_loop }
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use crate::platform_impl::web::event_loop::proxy::EventLoopProxy;
|
||||||
use crate::platform_impl::Window;
|
use crate::platform_impl::Window;
|
||||||
use crate::window::{CustomCursor as RootCustomCursor, CustomCursorSource, Theme, WindowId};
|
use crate::window::{CustomCursor as RootCustomCursor, CustomCursorSource, Theme, WindowId};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
struct ModifiersShared(Rc<Cell<ModifiersState>>);
|
struct ModifiersShared(Rc<Cell<ModifiersState>>);
|
||||||
|
|
||||||
impl ModifiersShared {
|
impl ModifiersShared {
|
||||||
|
|
@ -44,7 +44,7 @@ impl Clone for ModifiersShared {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ActiveEventLoop {
|
pub struct ActiveEventLoop {
|
||||||
pub(crate) runner: runner::Shared,
|
pub(crate) runner: runner::Shared,
|
||||||
modifiers: ModifiersShared,
|
modifiers: ModifiersShared,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use std::cell::Ref;
|
use std::cell::Ref;
|
||||||
|
use std::fmt;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
@ -23,6 +24,12 @@ pub struct Window {
|
||||||
inner: Dispatcher<Inner>,
|
inner: Dispatcher<Inner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Window {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("Window").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Inner {
|
pub struct Inner {
|
||||||
id: WindowId,
|
id: WindowId,
|
||||||
pub window: web_sys::Window,
|
pub window: web_sys::Window,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use std::rc::Rc;
|
||||||
use std::sync::atomic::{AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicU32, Ordering};
|
||||||
use std::sync::{Arc, Mutex, MutexGuard};
|
use std::sync::{Arc, Mutex, MutexGuard};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::{mem, panic, ptr};
|
use std::{fmt, mem, panic, ptr};
|
||||||
|
|
||||||
use windows_sys::Win32::Foundation::{
|
use windows_sys::Win32::Foundation::{
|
||||||
GetLastError, FALSE, HANDLE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_FAILED, WPARAM,
|
GetLastError, FALSE, HANDLE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_FAILED, WPARAM,
|
||||||
|
|
@ -147,12 +147,27 @@ pub struct EventLoop {
|
||||||
high_resolution_timer: Option<OwnedHandle>,
|
high_resolution_timer: Option<OwnedHandle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EventLoop {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("EventLoop").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) struct PlatformSpecificEventLoopAttributes {
|
pub(crate) struct PlatformSpecificEventLoopAttributes {
|
||||||
pub(crate) any_thread: bool,
|
pub(crate) any_thread: bool,
|
||||||
pub(crate) dpi_aware: bool,
|
pub(crate) dpi_aware: bool,
|
||||||
pub(crate) msg_hook: Option<Box<dyn FnMut(*const c_void) -> bool + 'static>>,
|
pub(crate) msg_hook: Option<Box<dyn FnMut(*const c_void) -> bool + 'static>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for PlatformSpecificEventLoopAttributes {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("PlatformSpecificEventLoopAttributes")
|
||||||
|
.field("any_thread", &self.any_thread)
|
||||||
|
.field("dpi_aware", &self.dpi_aware)
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for PlatformSpecificEventLoopAttributes {
|
impl Default for PlatformSpecificEventLoopAttributes {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { any_thread: false, dpi_aware: true, msg_hook: None }
|
Self { any_thread: false, dpi_aware: true, msg_hook: None }
|
||||||
|
|
@ -379,6 +394,7 @@ impl Drop for EventLoop {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct ActiveEventLoop(pub Rc<EventLoopRunner>);
|
pub(crate) struct ActiveEventLoop(pub Rc<EventLoopRunner>);
|
||||||
|
|
||||||
impl ActiveEventLoop {
|
impl ActiveEventLoop {
|
||||||
|
|
@ -681,6 +697,7 @@ fn wait_for_messages_impl(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct EventLoopThreadExecutor {
|
pub(crate) struct EventLoopThreadExecutor {
|
||||||
thread_id: u32,
|
thread_id: u32,
|
||||||
target_window: HWND,
|
target_window: HWND,
|
||||||
|
|
@ -731,6 +748,7 @@ impl EventLoopThreadExecutor {
|
||||||
|
|
||||||
type ThreadExecFn = Box<Box<dyn FnMut()>>;
|
type ThreadExecFn = Box<Box<dyn FnMut()>>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct EventLoopProxy {
|
pub struct EventLoopProxy {
|
||||||
target_window: HWND,
|
target_window: HWND,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::collections::VecDeque;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{mem, panic};
|
use std::{fmt, mem, panic};
|
||||||
|
|
||||||
use windows_sys::Win32::Foundation::HWND;
|
use windows_sys::Win32::Foundation::HWND;
|
||||||
|
|
||||||
|
|
@ -40,6 +40,14 @@ pub(crate) struct EventLoopRunner {
|
||||||
panic_error: Cell<Option<PanicError>>,
|
panic_error: Cell<Option<PanicError>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EventLoopRunner {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("EventLoopRunner")
|
||||||
|
.field("thread_msg_target", &self.thread_msg_target)
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type PanicError = Box<dyn Any + Send + 'static>;
|
pub type PanicError = Box<dyn Any + Send + 'static>;
|
||||||
|
|
||||||
/// See `move_state_to` function for details on how the state loop works.
|
/// See `move_state_to` function for details on how the state loop works.
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ use crate::window::{
|
||||||
WindowLevel,
|
WindowLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
/// We need to pass the window handle to the event loop thread, which means it needs to be
|
/// We need to pass the window handle to the event loop thread, which means it needs to be
|
||||||
/// Send+Sync.
|
/// Send+Sync.
|
||||||
|
|
@ -92,6 +92,7 @@ impl SyncWindowHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The Win32 implementation of the main `Window` object.
|
/// The Win32 implementation of the main `Window` object.
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct Window {
|
pub(crate) struct Window {
|
||||||
/// Main handle for the window.
|
/// Main handle for the window.
|
||||||
window: SyncWindowHandle,
|
window: SyncWindowHandle,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use std::sync::MutexGuard;
|
use std::sync::MutexGuard;
|
||||||
use std::{io, ptr};
|
use std::{fmt, io, ptr};
|
||||||
|
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use windows_sys::Win32::Foundation::{HWND, RECT};
|
use windows_sys::Win32::Foundation::{HWND, RECT};
|
||||||
|
|
@ -23,6 +23,7 @@ use crate::platform_impl::platform::{event_loop, util, Fullscreen, SelectedCurso
|
||||||
use crate::window::{Theme, WindowAttributes};
|
use crate::window::{Theme, WindowAttributes};
|
||||||
|
|
||||||
/// Contains information about states and the window that the callback is going to use.
|
/// Contains information about states and the window that the callback is going to use.
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct WindowState {
|
pub(crate) struct WindowState {
|
||||||
pub mouse: MouseProperties,
|
pub mouse: MouseProperties,
|
||||||
|
|
||||||
|
|
@ -65,7 +66,13 @@ pub struct SavedWindow {
|
||||||
pub placement: WINDOWPLACEMENT,
|
pub placement: WINDOWPLACEMENT,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
impl fmt::Debug for SavedWindow {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("SavedWindow").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub struct MouseProperties {
|
pub struct MouseProperties {
|
||||||
pub(crate) selected_cursor: SelectedCursor,
|
pub(crate) selected_cursor: SelectedCursor,
|
||||||
pub capture_count: u32,
|
pub capture_count: u32,
|
||||||
|
|
@ -129,7 +136,7 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq, Hash)]
|
||||||
pub enum ImeState {
|
pub enum ImeState {
|
||||||
Disabled,
|
Disabled,
|
||||||
Enabled,
|
Enabled,
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ impl WindowAttributes {
|
||||||
///
|
///
|
||||||
/// **Web:** The [`Window`], which is represented by a `HTMLElementCanvas`, can
|
/// **Web:** The [`Window`], which is represented by a `HTMLElementCanvas`, can
|
||||||
/// not be closed by dropping the [`Window`].
|
/// not be closed by dropping the [`Window`].
|
||||||
pub trait Window: AsAny + Send + Sync {
|
pub trait Window: AsAny + Send + Sync + fmt::Debug {
|
||||||
/// Returns an identifier unique to the window.
|
/// Returns an identifier unique to the window.
|
||||||
fn id(&self) -> WindowId;
|
fn id(&self) -> WindowId;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue