dear_imgui_winit/platform/
event_outcome.rs1use dear_imgui_rs::{Context, NativeWindowTarget};
2use winit::window::WindowId;
3
4#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
6pub struct WinitEventForwarding {
7 pub keyboard: bool,
8 pub text: bool,
9 pub pointer: bool,
10 pub focus: bool,
11}
12
13#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
18pub struct WinitCaptureIntent {
19 pub keyboard: bool,
20 pub pointer: bool,
21 pub text_input: bool,
22}
23
24impl WinitCaptureIntent {
25 pub(crate) fn snapshot(context: &Context) -> Self {
26 let io = context.io();
27 Self {
28 keyboard: io.want_capture_keyboard(),
29 pointer: io.want_capture_mouse(),
30 text_input: io.want_text_input(),
31 }
32 }
33}
34
35#[derive(Clone, Copy, Debug, Eq, PartialEq)]
37pub struct WinitEventTarget {
38 pub window_id: WindowId,
39 pub native: NativeWindowTarget,
40}
41
42#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
44pub enum WinitPlatformAction {
45 #[default]
46 None,
47 MainCloseRequested,
49 ViewportCloseRequested,
51 GeometryChanged,
52 NativeDestroyed,
53}
54
55#[derive(Clone, Debug, Default, PartialEq)]
57pub struct WinitEventOutcome {
58 pub target: Option<WinitEventTarget>,
60 pub forwarded: WinitEventForwarding,
61 pub capture: Option<WinitCaptureIntent>,
63 pub needs_frame: bool,
65 pub platform_action: WinitPlatformAction,
66 pub pointer_release: Option<super::WinitPointerReleaseReport>,
67}
68
69impl WinitEventOutcome {
70 pub fn is_owned(&self) -> bool {
72 self.target.is_some()
73 }
74}