cranpose_foundation/nodes/input/types.rs
1use std::{
2 cell::{Cell, RefCell},
3 rc::Rc,
4};
5
6use cranpose_ui_graphics::{Point, space::Ray};
7use web_time::Instant;
8
9use super::rotary::RotaryScrollEvent;
10
11/// Identifies one pointer of a gesture, such as one finger, as Compose's `PointerId`. The
12/// primary pointer is [`PointerId::PRIMARY`].
13#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
14pub struct PointerId(pub u64);
15
16impl PointerId {
17 /// The mouse, or the first finger of a touch.
18 pub const PRIMARY: Self = Self(0);
19
20 /// Whether this is [`PointerId::PRIMARY`].
21 pub const fn is_primary(self) -> bool {
22 self.0 == Self::PRIMARY.0
23 }
24}
25
26impl std::fmt::Display for PointerId {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 self.0.fmt(f)
29 }
30}
31
32/// When a pointer sample happened, in the clock that timed it, as Compose's
33/// `PointerInputChange.uptimeMillis`. [`PointerEvent::uptime`] gives it.
34///
35/// Times of one clock compare with each other and with no other clock, so a
36/// gesture that measures the time between two events never mixes clocks.
37#[derive(Clone, Copy, Debug, PartialEq, Eq)]
38pub enum PointerUptime {
39 /// The platform's sample time: Android's `MotionEvent` time or the
40 /// browser's event time stamp.
41 Platform {
42 /// Milliseconds in the platform's clock.
43 millis: i64,
44 },
45 /// The frame-clock time at which the shell took the event, on a platform
46 /// that gives no sample time: desktop, iOS and watchOS.
47 FrameClock {
48 /// Nanoseconds in the frame clock.
49 nanos: u64,
50 },
51 /// The time at which a handler read an event that carries neither time,
52 /// such as one built by a test and passed straight to a handler.
53 Delivery {
54 /// Nanoseconds since the first event that a handler timed this way.
55 nanos: u64,
56 },
57}
58
59impl PointerUptime {
60 /// The milliseconds from `earlier` to this time, negative when `earlier`
61 /// is the later one. `None` when the two times come from different clocks.
62 pub fn millis_since(self, earlier: Self) -> Option<i64> {
63 match (self, earlier) {
64 (Self::Platform { millis }, Self::Platform { millis: from }) => Some(millis - from),
65 (Self::FrameClock { nanos }, Self::FrameClock { nanos: from })
66 | (Self::Delivery { nanos }, Self::Delivery { nanos: from }) => {
67 Some(nanos.wrapping_sub(from) as i64 / 1_000_000)
68 }
69 _ => None,
70 }
71 }
72}
73
74fn delivery_nanos() -> u64 {
75 static EPOCH: std::sync::OnceLock<Instant> = std::sync::OnceLock::new();
76 let elapsed = EPOCH.get_or_init(Instant::now).elapsed();
77 u64::try_from(elapsed.as_nanos()).unwrap_or(u64::MAX)
78}
79
80type PostDispatchAction = Box<dyn FnOnce() -> bool>;
81
82#[derive(Clone)]
83struct DeferredPostDispatch {
84 action: Rc<RefCell<Option<PostDispatchAction>>>,
85}
86
87impl std::fmt::Debug for DeferredPostDispatch {
88 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
89 formatter
90 .debug_struct("DeferredPostDispatch")
91 .field("is_pending", &self.action.borrow().is_some())
92 .finish()
93 }
94}
95
96/// The phase of a pointer gesture that an event belongs to.
97#[derive(Clone, Copy, Debug, PartialEq, Eq)]
98pub enum PointerPhase {
99 /// The pointer went down.
100 Start,
101 /// The pointer moved, scrolled or hovered.
102 Move,
103 /// The pointer went up.
104 End,
105 /// The system canceled the gesture.
106 Cancel,
107}
108
109/// What a pointer event reports.
110#[derive(Clone, Copy, Debug, PartialEq, Eq)]
111pub enum PointerEventKind {
112 /// A pointer went down: the primary mouse button, a finger or a pen
113 /// touched. Other mouse buttons arrive as
114 /// [`ButtonDown`](Self::ButtonDown).
115 Down,
116 /// A pointer moved.
117 Move,
118 /// A pointer went up: the primary mouse button, a finger or a pen
119 /// lifted.
120 Up,
121 /// A mouse button other than the primary one went down: the right, the
122 /// middle or a side button. A click, a drag or a scroll starts only from
123 /// [`Down`](Self::Down); a handler that takes another button, such as one
124 /// that opens a menu or turns a camera, matches this. The nodes under the
125 /// pointer receive it, or, while another button is down, the nodes that
126 /// took that button's press. Those nodes receive the moves until the
127 /// last button goes up, with the buttons held in
128 /// [`PointerEvent::buttons`].
129 ButtonDown(PointerButton),
130 /// A mouse button other than the primary one went up; see
131 /// [`ButtonDown`](Self::ButtonDown).
132 ButtonUp(PointerButton),
133 /// The system canceled the gesture of the pointer.
134 Cancel,
135 /// A wheel or trackpad scroll. The delta is in [`PointerEvent::scroll_delta`].
136 Scroll,
137 /// Discrete zoom step (desktop ctrl+wheel, browser pinch-trackpad).
138 /// The multiplicative factor is carried in [`PointerEvent::zoom_delta`].
139 Zoom,
140 /// Rotary scroll (Wear OS crown / rotating bezel) during the **capture**
141 /// pass, which runs root-to-focused so ancestors can intercept the event
142 /// before the focused node sees it.
143 ///
144 /// The scroll amounts are carried in [`PointerEvent::scroll_delta`] (`y` =
145 /// vertical pixels, `x` = horizontal pixels) and the rotary uptime in
146 /// [`PointerEvent::time_ms`]; use
147 /// [`PointerEvent::rotary_scroll_event`] to read them back as a
148 /// [`RotaryScrollEvent`]. Mirrors Compose's `onPreRotaryScrollEvent`.
149 RotaryScrollPre,
150 /// Rotary scroll during the **bubble** pass, which runs focused-to-root.
151 /// Mirrors Compose's `onRotaryScrollEvent`.
152 RotaryScroll,
153 /// A pointer began to hover over the receiving node.
154 Enter,
155 /// A pointer stopped hovering over the receiving node.
156 Exit,
157}
158
159impl PointerEventKind {
160 /// Returns true for the two rotary passes.
161 pub fn is_rotary(self) -> bool {
162 matches!(self, Self::RotaryScrollPre | Self::RotaryScroll)
163 }
164}
165
166/// The kind of physical device that produced a pointer event.
167///
168/// Threaded from the platform layer (Android `MotionEvent` tool type, winit
169/// `PointerSource`/`ButtonSource`, web `PointerEvent.pointerType`) so input
170/// consumers can preserve device-specific gesture details while keeping shared
171/// direct-manipulation behavior source-independent.
172#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
173pub enum PointerSource {
174 /// A mouse or other indirect precise pointer (desktop, web `"mouse"`).
175 Mouse,
176 /// A finger on a touchscreen (Android finger, winit touch, web `"touch"`).
177 Touch,
178 /// A stylus/pen (Android stylus/eraser, winit tablet tool, web `"pen"`).
179 Stylus,
180 /// The platform did not report a device type.
181 #[default]
182 Unknown,
183}
184
185impl PointerSource {
186 /// Whether this source is a direct-touch device (finger or stylus), used
187 /// for contact-specific release and velocity semantics.
188 pub fn is_touch_like(self) -> bool {
189 matches!(self, Self::Touch | Self::Stylus)
190 }
191}
192
193/// A button of a mouse or of a similar pointing device.
194#[repr(u8)]
195#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
196pub enum PointerButton {
197 /// The main button, usually the left mouse button.
198 Primary = 0,
199 /// The secondary button, usually the right mouse button.
200 Secondary = 1,
201 /// The middle button, usually a press on the wheel.
202 Middle = 2,
203 /// The back button of a mouse.
204 Back = 3,
205 /// The forward button of a mouse.
206 Forward = 4,
207}
208
209/// A set of pointer buttons that are pressed together.
210#[derive(Clone, Copy, Debug, PartialEq, Eq)]
211pub struct PointerButtons(u8);
212
213impl PointerButtons {
214 /// The set with no button pressed.
215 pub const NONE: Self = Self(0);
216
217 /// Creates a set with no button pressed.
218 pub fn new() -> Self {
219 Self::NONE
220 }
221
222 /// Returns the set with `button` added.
223 pub fn with(mut self, button: PointerButton) -> Self {
224 self.insert(button);
225 self
226 }
227
228 /// Adds `button` to the set.
229 pub fn insert(&mut self, button: PointerButton) {
230 self.0 |= 1 << (button as u8);
231 }
232
233 /// Removes `button` from the set.
234 pub fn remove(&mut self, button: PointerButton) {
235 self.0 &= !(1 << (button as u8));
236 }
237
238 /// Whether `button` is in the set.
239 pub fn contains(&self, button: PointerButton) -> bool {
240 (self.0 & (1 << (button as u8))) != 0
241 }
242}
243
244impl Default for PointerButtons {
245 fn default() -> Self {
246 Self::NONE
247 }
248}
249
250/// Keyboard modifier keys held during an input sample.
251///
252/// Lives here (rather than up in `cranpose-ui`, where the keyboard `KeyEvent`
253/// type lives) because [`PointerEvent`] needs it too and `cranpose-foundation`
254/// sits below `cranpose-ui` in the dependency graph — this is the one crate
255/// both a key event and a pointer event can share it from. `cranpose-ui`
256/// re-exports this type rather than defining its own, so there is exactly one
257/// `Modifiers` in the framework.
258#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
259pub struct Modifiers {
260 /// Shift key is pressed.
261 pub shift: bool,
262 /// Control key is pressed (Cmd on macOS).
263 pub ctrl: bool,
264 /// Alt key is pressed (Option on macOS).
265 pub alt: bool,
266 /// Meta/Super key is pressed (Windows key, Cmd on macOS).
267 pub meta: bool,
268}
269
270impl Modifiers {
271 /// No modifiers pressed.
272 pub const NONE: Self = Self {
273 shift: false,
274 ctrl: false,
275 alt: false,
276 meta: false,
277 };
278
279 /// Shift alone.
280 pub const SHIFT: Self = Self {
281 shift: true,
282 ..Self::NONE
283 };
284
285 /// Control alone.
286 pub const CTRL: Self = Self {
287 ctrl: true,
288 ..Self::NONE
289 };
290
291 /// The platform's command key alone: Cmd on macOS, Control elsewhere,
292 /// the key [`Modifiers::command_or_ctrl`] reads.
293 pub const COMMAND: Self = Self {
294 ctrl: cfg!(not(target_os = "macos")),
295 meta: cfg!(target_os = "macos"),
296 ..Self::NONE
297 };
298
299 /// The keys held in `self` or in `other`.
300 pub const fn union(self, other: Self) -> Self {
301 Self {
302 shift: self.shift || other.shift,
303 ctrl: self.ctrl || other.ctrl,
304 alt: self.alt || other.alt,
305 meta: self.meta || other.meta,
306 }
307 }
308
309 /// Returns true if any modifier is pressed.
310 pub fn any(&self) -> bool {
311 self.shift || self.ctrl || self.alt || self.meta
312 }
313
314 /// Returns true if Ctrl (or Cmd on macOS) is pressed.
315 pub fn command_or_ctrl(&self) -> bool {
316 #[cfg(target_os = "macos")]
317 {
318 self.meta
319 }
320 #[cfg(not(target_os = "macos"))]
321 {
322 self.ctrl
323 }
324 }
325}
326
327/// Pointer event with consumption tracking for gesture disambiguation.
328///
329/// Events can be consumed by handlers (e.g., scroll) to prevent other handlers
330/// (e.g., clicks) from receiving them. This enables proper gesture disambiguation
331/// matching Jetpack Compose's event consumption pattern.
332#[derive(Clone, Debug)]
333pub struct PointerEvent {
334 /// The pointer this event belongs to. `0` is the primary pointer.
335 pub id: PointerId,
336 /// What happened to the pointer.
337 pub kind: PointerEventKind,
338 /// The phase of the gesture that the event belongs to, which follows from `kind`.
339 pub phase: PointerPhase,
340 /// Where the pointer is, in logical pixels, in the coordinates of the node that receives the
341 /// event.
342 pub position: Point,
343 /// Where the pointer is, in logical pixels, in the coordinates of the composition root.
344 pub global_position: Point,
345 /// Where the pointer is on the screen, in logical pixels, when the
346 /// platform told the shell where the window drawing this event's root
347 /// sits. `None` on platforms without window positions and for events a
348 /// test dispatches without one. A gesture that crosses windows, such as
349 /// a tab torn out of one window and dropped on another, compares this
350 /// with the windows' positions instead of translating `global_position`
351 /// itself.
352 pub screen_position: Option<Point>,
353 /// Scroll delta in logical pixels.
354 ///
355 /// This is non-zero for [`PointerEventKind::Scroll`] events and zero for
356 /// button/move events.
357 pub scroll_delta: Point,
358 /// The buttons that are pressed at the time of this event.
359 pub buttons: PointerButtons,
360 /// Platform timestamp of the input sample in milliseconds, when available.
361 ///
362 /// The time base is platform specific (e.g. Android's uptime clock); only
363 /// differences between events of the same gesture are meaningful. Gesture
364 /// velocity trackers must prefer this over the delivery time because
365 /// platforms like Android deliver input batched/frame-aligned: several
366 /// samples arrive back-to-back and delivery-time stamping makes computed
367 /// velocities wildly wrong.
368 pub time_ms: Option<i64>,
369 /// Timestamp in the animation frame-clock domain at input dispatch.
370 /// Unlike `time_ms`, this has the same origin as frame callbacks and can
371 /// anchor input-driven animations without a wall/platform clock conversion.
372 pub animation_time_nanos: Option<u64>,
373 /// The instant at which the shell received this event, taken once when the
374 /// platform handed the event over. A gesture that times its samples by
375 /// their arrival reads it where the platform gives no `time_ms`. Handling
376 /// the event later does not change it. `None` for an event built without
377 /// the shell.
378 pub received_at: Option<Instant>,
379 /// Multiplicative zoom factor for [`PointerEventKind::Zoom`] events
380 /// (`> 1.0` zooms in, `< 1.0` zooms out). `1.0` for all other events.
381 pub zoom_delta: f32,
382 /// The kind of device that produced this event (touch, mouse, stylus), when
383 /// the platform reports it. Defaults to [`PointerSource::Unknown`].
384 pub source: PointerSource,
385 /// Keyboard modifiers held at the time of this sample, when the platform
386 /// can report them.
387 ///
388 /// `None` means the platform never told the shell what the keyboard state
389 /// was — touch-only Android/iOS input has no channel for it today — and is
390 /// deliberately distinct from `Some(Modifiers::NONE)`, which means the
391 /// platform looked and nothing was held. An app that wants shift/ctrl-click
392 /// multi-select reads this field directly; it must not treat `None` as
393 /// "nothing held" or it silently drops the gesture on the platforms that
394 /// cannot yet report it instead of visibly doing nothing.
395 pub modifiers: Option<Modifiers>,
396 /// For a pointer that points along a ray in a 3D scene from somewhere
397 /// other than the window's eye (a controller, a hand, a gaze), the ray,
398 /// in the space the scene's eye stands in. A target on a mesh surface
399 /// finds the event's position where the ray meets the surface, in place
400 /// of where `global_position` shows. `None` for a pointer on the window.
401 pub ray: Option<Ray>,
402 consumed: Rc<Cell<bool>>,
403 deferred_post_dispatch: DeferredPostDispatch,
404}
405
406impl PointerEvent {
407 /// Creates an event of `kind` at `position`, in the coordinates of the receiving node, and at
408 /// `global_position`, in the coordinates of the composition root. The pointer is
409 /// [`PointerId::PRIMARY`] and the other fields have neutral values.
410 pub fn new(kind: PointerEventKind, position: Point, global_position: Point) -> Self {
411 Self {
412 id: PointerId::PRIMARY,
413 kind,
414 phase: match kind {
415 PointerEventKind::Down => PointerPhase::Start,
416 PointerEventKind::Move
417 | PointerEventKind::Enter
418 | PointerEventKind::Exit
419 | PointerEventKind::ButtonDown(_)
420 | PointerEventKind::ButtonUp(_) => PointerPhase::Move,
421 PointerEventKind::Up => PointerPhase::End,
422 PointerEventKind::Cancel => PointerPhase::Cancel,
423 PointerEventKind::Scroll
424 | PointerEventKind::Zoom
425 | PointerEventKind::RotaryScrollPre
426 | PointerEventKind::RotaryScroll => PointerPhase::Move,
427 },
428 position,
429 global_position,
430 screen_position: None,
431 scroll_delta: Point { x: 0.0, y: 0.0 },
432 buttons: PointerButtons::NONE,
433 time_ms: None,
434 animation_time_nanos: None,
435 received_at: None,
436 zoom_delta: 1.0,
437 source: PointerSource::Unknown,
438 modifiers: None,
439 ray: None,
440 consumed: Rc::new(Cell::new(false)),
441 deferred_post_dispatch: DeferredPostDispatch {
442 action: Rc::new(RefCell::new(None)),
443 },
444 }
445 }
446
447 /// Set the pointer id for this event (`0` is the primary pointer).
448 pub fn with_id(mut self, id: PointerId) -> Self {
449 self.id = id;
450 self
451 }
452
453 /// Set the ray a pointer in a 3D scene points along (see
454 /// [`PointerEvent::ray`]).
455 pub fn with_ray(mut self, ray: Ray) -> Self {
456 self.ray = Some(ray);
457 self
458 }
459
460 /// Set the multiplicative zoom factor for a [`PointerEventKind::Zoom`] event.
461 pub fn with_zoom_delta(mut self, zoom_delta: f32) -> Self {
462 self.zoom_delta = zoom_delta;
463 self
464 }
465
466 /// Set the scroll delta for this event.
467 pub fn with_scroll_delta(mut self, scroll_delta: Point) -> Self {
468 self.scroll_delta = scroll_delta;
469 self
470 }
471
472 /// Set the platform timestamp (milliseconds) for this event.
473 pub fn with_time_ms(mut self, time_ms: Option<i64>) -> Self {
474 self.time_ms = time_ms;
475 self
476 }
477
478 /// Set the timestamp in the animation frame-clock domain.
479 pub fn with_animation_time_nanos(mut self, time_nanos: u64) -> Self {
480 self.animation_time_nanos = Some(time_nanos);
481 self
482 }
483
484 /// Set the instant at which the shell received this event.
485 pub fn with_received_at(mut self, received_at: Instant) -> Self {
486 self.received_at = Some(received_at);
487 self
488 }
489
490 /// When this sample happened: the platform's sample time where the
491 /// platform gives one, else the frame-clock time at which the shell took
492 /// the event, else the time of this call. A gesture that counts taps or
493 /// measures a hold compares these, so a busy main thread that delivers
494 /// events late or in a batch does not change what the gesture was.
495 pub fn uptime(&self) -> PointerUptime {
496 match (self.time_ms, self.animation_time_nanos) {
497 (Some(millis), _) => PointerUptime::Platform { millis },
498 (None, Some(nanos)) => PointerUptime::FrameClock { nanos },
499 (None, None) => PointerUptime::Delivery {
500 nanos: delivery_nanos(),
501 },
502 }
503 }
504
505 /// Set where the pointer is on the screen, when the platform knows.
506 pub fn with_screen_position(mut self, screen_position: Option<Point>) -> Self {
507 self.screen_position = screen_position;
508 self
509 }
510
511 /// Where the pointer is in the steadiest frame the platform offers: on
512 /// the screen where it reports window positions, and in the composition
513 /// where it does not.
514 ///
515 /// Two events compared this way say how far the hand travelled even when
516 /// the window under it travelled too, which is what a drag threshold has
517 /// to measure: a press that drags a borderless window never moves within
518 /// that window, because the window follows it.
519 pub fn travelled_to(&self) -> Point {
520 self.screen_position.unwrap_or(self.global_position)
521 }
522
523 /// Set the buttons state for this event
524 pub fn with_buttons(mut self, buttons: PointerButtons) -> Self {
525 self.buttons = buttons;
526 self
527 }
528
529 /// Set the device source (touch/mouse/stylus) for this event.
530 pub fn with_source(mut self, source: PointerSource) -> Self {
531 self.source = source;
532 self
533 }
534
535 /// Set the keyboard modifiers held during this event, when the platform
536 /// can report them. See the [`modifiers`](Self::modifiers) field docs for
537 /// why this takes a concrete [`Modifiers`] rather than an `Option`: the
538 /// `None` case is the *absence* of a call to this builder, not a value it
539 /// produces.
540 pub fn with_modifiers(mut self, modifiers: Modifiers) -> Self {
541 self.modifiers = Some(modifiers);
542 self
543 }
544
545 /// Builds a rotary pointer event for one dispatch pass.
546 ///
547 /// `kind` must be [`PointerEventKind::RotaryScrollPre`] (capture) or
548 /// [`PointerEventKind::RotaryScroll`] (bubble). The rotary payload rides on
549 /// the existing `scroll_delta`/`time_ms` fields so rotary reuses the
550 /// pointer dispatch path without widening [`PointerEvent`].
551 pub fn rotary(kind: PointerEventKind, rotary: RotaryScrollEvent, position: Point) -> Self {
552 debug_assert!(
553 kind.is_rotary(),
554 "PointerEvent::rotary requires a rotary event kind"
555 );
556 Self::new(kind, position, position)
557 .with_scroll_delta(Point {
558 x: rotary.horizontal_scroll_pixels,
559 y: rotary.vertical_scroll_pixels,
560 })
561 .with_time_ms(Some(rotary.uptime_millis as i64))
562 }
563
564 /// Reads this event back as a [`RotaryScrollEvent`], or `None` when it is
565 /// not a rotary event.
566 ///
567 /// Copies three scalars out of the event; it never allocates.
568 pub fn rotary_scroll_event(&self) -> Option<RotaryScrollEvent> {
569 if !self.kind.is_rotary() {
570 return None;
571 }
572 Some(RotaryScrollEvent {
573 vertical_scroll_pixels: self.scroll_delta.y,
574 horizontal_scroll_pixels: self.scroll_delta.x,
575 uptime_millis: self.time_ms.unwrap_or(0).max(0) as u64,
576 })
577 }
578
579 /// Mark this event as consumed, preventing other handlers from processing it.
580 ///
581 /// Example: Scroll gestures consume events once dragging starts to prevent
582 /// child buttons from firing clicks.
583 pub fn consume(&self) {
584 self.consumed.set(true);
585 }
586
587 /// Check if this event has been consumed by another handler.
588 ///
589 /// Handlers should check this before processing events. For example,
590 /// clickable should not fire if the event was consumed by a scroll gesture.
591 pub fn is_consumed(&self) -> bool {
592 self.consumed.get()
593 }
594
595 /// Stores `action` to run once after every handler saw the event. It runs only when no handler
596 /// consumed the event, and when it returns `true` the event becomes consumed. A later call
597 /// replaces the stored action.
598 pub fn defer_post_dispatch_action<F>(&self, action: F)
599 where
600 F: FnOnce() -> bool + 'static,
601 {
602 *self.deferred_post_dispatch.action.borrow_mut() = Some(Box::new(action));
603 }
604
605 /// Runs the action stored by `defer_post_dispatch_action`, unless a handler consumed the event;
606 /// then the action is dropped. The shell calls this after it dispatched the event to all
607 /// targets.
608 pub fn finish_post_dispatch(&self) {
609 if self.is_consumed() {
610 self.deferred_post_dispatch.action.borrow_mut().take();
611 return;
612 }
613
614 let Some(action) = self.deferred_post_dispatch.action.borrow_mut().take() else {
615 return;
616 };
617 if action() {
618 self.consume();
619 }
620 }
621
622 /// Creates a copy of this event with a new local position, sharing the consumption state.
623 pub fn copy_with_local_position(&self, position: Point) -> Self {
624 Self {
625 id: self.id,
626 kind: self.kind,
627 phase: self.phase,
628 position,
629 global_position: self.global_position,
630 screen_position: self.screen_position,
631 scroll_delta: self.scroll_delta,
632 buttons: self.buttons,
633 time_ms: self.time_ms,
634 animation_time_nanos: self.animation_time_nanos,
635 received_at: self.received_at,
636 zoom_delta: self.zoom_delta,
637 source: self.source,
638 modifiers: self.modifiers,
639 ray: self.ray,
640 consumed: Rc::clone(&self.consumed),
641 deferred_post_dispatch: self.deferred_post_dispatch.clone(),
642 }
643 }
644}
645
646#[cfg(test)]
647#[path = "tests/types_tests.rs"]
648mod tests;