diff --git a/consumer/src/node.rs b/consumer/src/node.rs index a9c2c1a5..2a14a998 100644 --- a/consumer/src/node.rs +++ b/consumer/src/node.rs @@ -26,10 +26,10 @@ use crate::iterators::{ }; use crate::tree::State as TreeState; -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] pub(crate) struct ParentAndIndex(pub(crate) NodeId, pub(crate) usize); -#[derive(Clone)] +#[derive(Clone, Debug)] pub(crate) struct NodeState { pub(crate) parent_and_index: Option, pub(crate) data: Arc, diff --git a/consumer/src/tree.rs b/consumer/src/tree.rs index d3c8635a..5047aa1e 100644 --- a/consumer/src/tree.rs +++ b/consumer/src/tree.rs @@ -11,7 +11,7 @@ use immutable_chunkmap::map::MapM as ChunkMap; use crate::node::{Node, NodeState, ParentAndIndex}; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct State { pub(crate) nodes: ChunkMap, pub(crate) data: TreeData, @@ -229,6 +229,7 @@ pub trait ChangeHandler { fn node_removed(&mut self, node: &Node); } +#[derive(Debug)] pub struct Tree { state: State, } diff --git a/platforms/atspi-common/src/adapter.rs b/platforms/atspi-common/src/adapter.rs index cdd79aef..9f1726cf 100644 --- a/platforms/atspi-common/src/adapter.rs +++ b/platforms/atspi-common/src/adapter.rs @@ -8,9 +8,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.chromium file. +use crate::{ + context::{ActionHandlerNoMut, ActionHandlerWrapper, AppContext, Context}, + filters::filter, + node::{NodeIdOrRoot, NodeWrapper, PlatformNode, PlatformRoot}, + util::WindowBounds, + AdapterCallback, Event, ObjectEvent, WindowEvent, +}; use accesskit::{ActionHandler, NodeId, Role, TreeUpdate}; use accesskit_consumer::{FilterResult, Node, Tree, TreeChangeHandler, TreeState}; use atspi_common::{InterfaceSet, Live, State}; +use std::fmt::{Debug, Formatter}; use std::{ collections::HashSet, sync::{ @@ -19,14 +27,6 @@ use std::{ }, }; -use crate::{ - context::{ActionHandlerNoMut, ActionHandlerWrapper, AppContext, Context}, - filters::filter, - node::{NodeIdOrRoot, NodeWrapper, PlatformNode, PlatformRoot}, - util::WindowBounds, - AdapterCallback, Event, ObjectEvent, WindowEvent, -}; - struct AdapterChangeHandler<'a> { adapter: &'a Adapter, added_nodes: HashSet, @@ -320,6 +320,16 @@ pub struct Adapter { context: Arc, } +impl Debug for Adapter { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Adapter") + .field("id", &self.id) + .field("callback", &"AdapterCallback") + .field("context", &self.context) + .finish() + } +} + impl Adapter { pub fn new( app_context: &Arc>, diff --git a/platforms/atspi-common/src/context.rs b/platforms/atspi-common/src/context.rs index 7a8f0b1c..79e5fd77 100644 --- a/platforms/atspi-common/src/context.rs +++ b/platforms/atspi-common/src/context.rs @@ -5,6 +5,7 @@ use accesskit::{ActionHandler, ActionRequest}; use accesskit_consumer::Tree; +use std::fmt::{Debug, Formatter}; use std::sync::{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard}; use crate::WindowBounds; @@ -38,6 +39,17 @@ pub(crate) struct Context { pub(crate) root_window_bounds: RwLock, } +impl Debug for Context { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Context") + .field("app_context", &self.app_context) + .field("tree", &self.tree) + .field("action_handler", &"ActionHandler") + .field("root_window_bounds", &self.root_window_bounds) + .finish() + } +} + impl Context { pub(crate) fn new( app_context: &Arc>, @@ -74,6 +86,7 @@ impl Context { } } +#[derive(Debug)] pub struct AppContext { pub(crate) name: Option, pub(crate) toolkit_name: Option, diff --git a/platforms/atspi-common/src/util.rs b/platforms/atspi-common/src/util.rs index 2632af48..d4e4c558 100644 --- a/platforms/atspi-common/src/util.rs +++ b/platforms/atspi-common/src/util.rs @@ -9,7 +9,7 @@ use atspi_common::{CoordType, Granularity}; use crate::Error; -#[derive(Clone, Copy, Default)] +#[derive(Clone, Copy, Default, Debug)] pub struct WindowBounds { pub outer: Rect, pub inner: Rect, diff --git a/platforms/macos/src/adapter.rs b/platforms/macos/src/adapter.rs index 2bd942bb..2de5dbaf 100644 --- a/platforms/macos/src/adapter.rs +++ b/platforms/macos/src/adapter.rs @@ -3,6 +3,13 @@ // the LICENSE-APACHE file) or the MIT license (found in // the LICENSE-MIT file), at your option. +use crate::{ + context::{ActionHandlerNoMut, ActionHandlerWrapper, Context}, + event::{focus_event, EventGenerator, QueuedEvents}, + filters::filter, + node::can_be_focused, + util::*, +}; use accesskit::{ ActionHandler, ActionRequest, ActivationHandler, Node as NodeProvider, NodeId, Role, Tree as TreeData, TreeUpdate, @@ -11,16 +18,9 @@ use accesskit_consumer::{FilterResult, Tree}; use objc2::rc::{Id, WeakId}; use objc2_app_kit::NSView; use objc2_foundation::{MainThreadMarker, NSArray, NSObject, NSPoint}; +use std::fmt::{Debug, Formatter}; use std::{ffi::c_void, ptr::null_mut, rc::Rc}; -use crate::{ - context::{ActionHandlerNoMut, ActionHandlerWrapper, Context}, - event::{focus_event, EventGenerator, QueuedEvents}, - filters::filter, - node::can_be_focused, - util::*, -}; - const PLACEHOLDER_ROOT_ID: NodeId = NodeId(0); enum State { @@ -38,12 +38,41 @@ enum State { Active(Rc), } +impl Debug for State { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + State::Inactive { + view, + is_view_focused, + action_handler: _, + mtm, + } => f + .debug_struct("Inactive") + .field("view", view) + .field("is_view_focused", is_view_focused) + .field("mtm", mtm) + .finish(), + State::Placeholder { + placeholder_context, + is_view_focused, + action_handler: _, + } => f + .debug_struct("Placeholder") + .field("placeholder_context", placeholder_context) + .field("is_view_focused", is_view_focused) + .finish(), + State::Active(context) => f.debug_struct("Active").field("context", context).finish(), + } + } +} + struct PlaceholderActionHandler; impl ActionHandler for PlaceholderActionHandler { fn do_action(&mut self, _request: ActionRequest) {} } +#[derive(Debug)] pub struct Adapter { state: State, } diff --git a/platforms/macos/src/context.rs b/platforms/macos/src/context.rs index ad4c3251..b3d51fa2 100644 --- a/platforms/macos/src/context.rs +++ b/platforms/macos/src/context.rs @@ -3,16 +3,16 @@ // the LICENSE-APACHE file) or the MIT license (found in // the LICENSE-MIT file), at your option. +use crate::node::PlatformNode; use accesskit::{ActionHandler, ActionRequest, NodeId}; use accesskit_consumer::Tree; use hashbrown::HashMap; use objc2::rc::{Id, WeakId}; use objc2_app_kit::*; use objc2_foundation::MainThreadMarker; +use std::fmt::Debug; use std::{cell::RefCell, rc::Rc}; -use crate::node::PlatformNode; - pub(crate) trait ActionHandlerNoMut { fn do_action(&self, request: ActionRequest); } @@ -39,6 +39,18 @@ pub(crate) struct Context { pub(crate) mtm: MainThreadMarker, } +impl Debug for Context { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Context") + .field("view", &self.view) + .field("tree", &self.tree) + .field("action_handler", &"ActionHandler") + .field("platform_nodes", &self.platform_nodes) + .field("mtm", &self.mtm) + .finish() + } +} + impl Context { pub(crate) fn new( view: WeakId, diff --git a/platforms/macos/src/node.rs b/platforms/macos/src/node.rs index 6c336432..4eb03ac8 100644 --- a/platforms/macos/src/node.rs +++ b/platforms/macos/src/node.rs @@ -348,6 +348,7 @@ pub(crate) struct PlatformNodeIvars { } declare_class!( + #[derive(Debug)] pub(crate) struct PlatformNode; unsafe impl ClassType for PlatformNode { diff --git a/platforms/unix/src/adapter.rs b/platforms/unix/src/adapter.rs index 4083d8d3..c56e6122 100644 --- a/platforms/unix/src/adapter.rs +++ b/platforms/unix/src/adapter.rs @@ -11,6 +11,7 @@ use accesskit_atspi_common::{ #[cfg(not(feature = "tokio"))] use async_channel::Sender; use atspi::InterfaceSet; +use std::fmt::{Debug, Formatter}; use std::sync::{Arc, Mutex}; #[cfg(feature = "tokio")] use tokio::sync::mpsc::UnboundedSender as Sender; @@ -71,6 +72,35 @@ pub(crate) enum AdapterState { Active(AdapterImpl), } +impl Debug for AdapterState { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + AdapterState::Inactive { + is_window_focused, + root_window_bounds, + action_handler: _, + } => f + .debug_struct("Inactive") + .field("is_window_focused", is_window_focused) + .field("root_window_bounds", root_window_bounds) + .field("action_handler", &"ActionHandler") + .finish(), + AdapterState::Pending { + is_window_focused, + root_window_bounds, + action_handler: _, + } => f + .debug_struct("Pending") + .field("is_window_focused", is_window_focused) + .field("root_window_bounds", root_window_bounds) + .field("action_handler", &"ActionHandler") + .finish(), + AdapterState::Active(r#impl) => f.debug_tuple("Active").field(r#impl).finish(), + } + } +} + +#[derive(Debug)] pub struct Adapter { messages: Sender, id: usize, diff --git a/platforms/windows/src/adapter.rs b/platforms/windows/src/adapter.rs index 8ce5a2b7..b88b7270 100644 --- a/platforms/windows/src/adapter.rs +++ b/platforms/windows/src/adapter.rs @@ -9,6 +9,7 @@ use accesskit::{ }; use accesskit_consumer::{FilterResult, Node, Tree, TreeChangeHandler}; use hashbrown::HashSet; +use std::fmt::{Debug, Formatter}; use std::sync::{atomic::Ordering, Arc}; use windows::Win32::{ Foundation::*, @@ -150,6 +151,26 @@ enum State { Active(Arc), } +impl Debug for State { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + State::Inactive { + hwnd, + is_window_focused, + action_handler: _, + } => f + .debug_struct("Inactive") + .field("hwnd", hwnd) + .field("is_window_focused", is_window_focused) + .field("action_handler", &"ActionHandler") + .finish(), + State::Placeholder(context) => f.debug_tuple("Placeholder").field(context).finish(), + State::Active(context) => f.debug_tuple("Active").field(context).finish(), + } + } +} + +#[derive(Debug)] pub struct Adapter { state: State, } diff --git a/platforms/windows/src/context.rs b/platforms/windows/src/context.rs index d22466fc..7e415875 100644 --- a/platforms/windows/src/context.rs +++ b/platforms/windows/src/context.rs @@ -5,6 +5,7 @@ use accesskit::{ActionHandler, ActionRequest, Point}; use accesskit_consumer::Tree; +use std::fmt::{Debug, Formatter}; use std::sync::{atomic::AtomicBool, Arc, Mutex, RwLock, RwLockReadGuard}; use crate::{util::*, window_handle::WindowHandle}; @@ -34,6 +35,17 @@ pub(crate) struct Context { pub(crate) is_placeholder: AtomicBool, } +impl Debug for Context { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Context") + .field("hwnd", &self.hwnd) + .field("tree", &self.tree) + .field("action_handler", &"ActionHandler") + .field("is_placeholder", &self.is_placeholder) + .finish() + } +} + impl Context { pub(crate) fn new( hwnd: WindowHandle,