1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*

`async-winit` is free software: you can redistribute it and/or modify it under the terms of one of
the following licenses:

- The GNU Affero General Public License as published by the Free Software Foundation, either version
  3 of the License, or (at your option) any later version.
- The Patron License at https://github.com/notgull/async-winit/blob/main/LICENSE-PATRON.md, for
  sponsors and contributors, who can ignore the copyleft provisions of the GNU AGPL for this project.

`async-winit` is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
Public License and the Patron License for more details.

You should have received a copy of the GNU Affero General Public License and the corresponding Patron
License along with `async-winit`. If not, see <https://www.gnu.org/licenses/>.

*/

//! Platform specific code.

#[cfg(target_os = "android")]
pub mod android;

#[cfg(target_os = "ios")]
pub mod ios;

#[cfg(target_os = "macos")]
pub mod macos;

#[cfg(target_os = "redox")]
pub mod orbital;

#[cfg(all(
    unix,
    not(any(target_os = "android", target_os = "macos", target_os = "ios",)),
    feature = "x11"
))]
pub mod x11;

#[cfg(all(
    unix,
    not(any(target_os = "android", target_os = "macos", target_os = "ios",)),
    feature = "wayland"
))]
pub mod wayland;

#[cfg(windows)]
pub mod windows;

#[cfg(all(any(unix, windows, target_os = "redox"), not(target_os = "ios")))]
pub mod run_return;

cfg_if::cfg_if! {
    if #[cfg(target_os = "android")] {
        pub(crate) use android::PlatformSpecific;
    } else if #[cfg(target_os = "ios")] {
        pub(crate) use ios::PlatformSpecific;
    } else if #[cfg(target_os = "macos")] {
        pub(crate) use macos::PlatformSpecific;
    } else if #[cfg(target_os = "redox")] {
        pub(crate) use orbital::PlatformSpecific;
    } else if #[cfg(all(
        unix,
        not(any(target_os = "android", target_os = "macos", target_os = "ios",)),
    ))] {
        #[cfg(all(feature = "x11", not(feature = "wayland")))]
        pub(crate) use x11::PlatformSpecific;

        #[cfg(all(not(feature = "x11"), feature = "wayland"))]
        pub(crate) use wayland::PlatformSpecific;

        #[cfg(all(feature = "x11", feature = "wayland"))]
        mod free_unix;
        #[cfg(all(feature = "x11", feature = "wayland"))]
        pub(crate) use free_unix::PlatformSpecific;
    } else if #[cfg(windows)] {
        pub(crate) use windows::PlatformSpecific;
    }
}

mod __private {
    use crate::event_loop::{EventLoop, EventLoopBuilder, EventLoopWindowTarget};
    use crate::window::{Window, WindowBuilder};

    #[doc(hidden)]
    pub struct Internal(());

    macro_rules! sealed_trait {
        ($($name: ident $tname: ident)*) => {$(
            #[doc(hidden)]
            pub trait $tname {
                fn __sealed_marker(i: Internal);
            }

            impl $tname for $name {
                fn __sealed_marker(_: Internal) {}
            }
        )*}
    }

    sealed_trait! {
        EventLoopWindowTarget EventLoopWindowTargetPrivate
        EventLoop EventLoopPrivate
        EventLoopBuilder EventLoopBuilderPrivate
        Window WindowPrivate
        WindowBuilder WindowBuilderPrivate
    }
}