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
use crate::Display;
use glib::object::IsA;
use glib::ObjectExt;
#[derive(Debug, PartialEq, Eq, Ord, PartialOrd)]
pub enum Backend {
Wayland,
X11,
Win32,
MacOS,
Broadway,
}
impl Backend {
#[doc(alias = "GDK_IS_WAYLAND_DISPLAY")]
pub fn is_wayland(&self) -> bool {
matches!(self, Self::Wayland)
}
#[doc(alias = "GDK_IS_X11_DISPLAY")]
pub fn is_x11(&self) -> bool {
matches!(self, Self::X11)
}
#[doc(alias = "GDK_IS_WIN32_DISPLAY")]
pub fn is_win32(&self) -> bool {
matches!(self, Self::Win32)
}
#[doc(alias = "GDK_IS_QUARTZ_DISPLAY")]
pub fn is_macos(&self) -> bool {
matches!(self, Self::MacOS)
}
#[doc(alias = "GDK_IS_BROADWAY_DISPLAY")]
pub fn is_broadway(&self) -> bool {
matches!(self, Self::Broadway)
}
}
pub trait DisplayExtManual: 'static {
fn backend(&self) -> Backend;
}
impl<O: IsA<Display>> DisplayExtManual for O {
fn backend(&self) -> Backend {
match self.as_ref().type_().name() {
"GdkWaylandDisplay" => Backend::Wayland,
"GdkX11Display" => Backend::X11,
"GdkQuartzDisplay" => Backend::MacOS,
"GdkWin32Display" => Backend::Win32,
"GdkBroadwayDisplay" => Backend::Broadway,
e => panic!("Unsupported display backend {}", e),
}
}
}