diff --git a/src/program.rs b/src/program.rs index ace4da74..602e8227 100644 --- a/src/program.rs +++ b/src/program.rs @@ -110,6 +110,10 @@ pub trait Program: Sized { type Flags = (P, I); type Executor = P::Executor; + fn name() -> &'static str { + std::any::type_name::() + } + fn new( (program, initialize): Self::Flags, ) -> (Self, Task) { diff --git a/winit/src/program.rs b/winit/src/program.rs index b8e9a067..b0344050 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -6,6 +6,7 @@ pub use state::State; use crate::conversion; use crate::core; +use crate::core::keyboard; use crate::core::mouse; use crate::core::renderer; use crate::core::theme; @@ -69,6 +70,9 @@ where /// The data needed to initialize your [`Program`]. type Flags; + /// Returns the unique name of the [`Program`]. + fn name() -> &'static str; + /// Initializes the [`Program`] with the flags provided to /// [`run`] as part of the [`Settings`]. /// @@ -154,6 +158,8 @@ where { use winit::event_loop::EventLoop; + debug::init(P::name()); + let boot_span = debug::boot(); let event_loop = EventLoop::with_user_event() @@ -973,6 +979,20 @@ async fn run_instance( window.state.scale_factor(), window.state.modifiers(), ) { + if matches!( + event, + core::Event::Keyboard( + keyboard::Event::KeyPressed { + modified_key: keyboard::Key::Named( + keyboard::key::Named::F12 + ), + .. + } + ) + ) { + debug::toggle_comet(); + } + events.push((id, event)); } }