freya_core/
user_event.rs

1use std::{
2    any::Any,
3    fmt::Debug,
4};
5
6use cursor_icon::CursorIcon;
7
8use crate::prelude::AccessibilityFocusStrategy;
9
10#[derive(Debug)]
11pub enum UserEvent {
12    RequestRedraw,
13
14    /// Focus with the given strategy
15    FocusAccessibilityNode(AccessibilityFocusStrategy),
16
17    /// Set a new cursor icon.
18    SetCursorIcon(CursorIcon),
19
20    Erased(SingleThreadErasedEvent),
21}
22
23pub struct SingleThreadErasedEvent(pub Box<dyn Any>);
24
25impl Debug for SingleThreadErasedEvent {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        f.write_str("SingleThreadErasedEvent")
28    }
29}
30
31/// # Safety
32/// The values are never sent, received or accessed by other threads other than the main thread.
33/// This is needed to send `Rc<T>` and other non-Send and non-Sync values from WindowConfig
34/// to the winit EventLoop
35unsafe impl Send for SingleThreadErasedEvent {}
36unsafe impl Sync for SingleThreadErasedEvent {}