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
mod command;
mod command_code;
mod key;
mod mouse_button;
mod utils;
pub mod traits;

pub use command::*;
pub use command_code::*;
pub use key::*;
pub use mouse_button::*;
pub use traits::*;

/// Identifies a backend implementation.
pub enum Backend {
    None,
    LinuxWayland,
    LinuxX11,
    MacOS,
    Windows,
}

#[cfg(target_os = "linux")]
mod linux_common;

#[cfg(all(target_os = "linux", not(x11)))]
mod linux_wayland;
#[cfg(all(target_os = "linux", not(x11)))]
pub use linux_wayland::{Context, Error};
#[cfg(all(target_os = "linux", not(x11)))]
pub const BACKEND: Backend = Backend::LinuxWayland;

#[cfg(all(target_os = "linux", x11))]
mod linux_x11;
#[cfg(all(target_os = "linux", x11))]
pub use linux_x11::{Context, Error};
#[cfg(all(target_os = "linux", x11))]
pub const BACKEND: Backend = Backend::LinuxX11;

#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
pub use macos::{Context, Error};
#[cfg(target_os = "macos")]
pub const BACKEND: Backend = Backend::MacOS;

#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "windows")]
pub use windows::{Context, Error};
#[cfg(target_os = "windows")]
pub const BACKEND: Backend = Backend::Windows;

#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
pub struct Context;
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
pub struct Error;
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
pub const BACKEND: Backend = Backend::None;