1use glib::bitflags::bitflags;
4use std::convert::TryFrom;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum ChannelType {
9 Invalid = 0,
10 Main = 1,
11 Display = 2,
12 Inputs = 3,
13 Cursor = 4,
14 Playback = 5,
15 Record = 6,
16 Tunnel = 7,
17 Smartcard = 8,
18 Usbredir = 9,
19 Port = 10,
20 Webdav = 11,
21}
22
23impl TryFrom<i32> for ChannelType {
24 type Error = i32;
25
26 fn try_from(v: i32) -> Result<Self, i32> {
27 match v {
28 x if x == ChannelType::Invalid as i32 => Ok(ChannelType::Invalid),
29 x if x == ChannelType::Main as i32 => Ok(ChannelType::Main),
30 x if x == ChannelType::Display as i32 => Ok(ChannelType::Display),
31 x if x == ChannelType::Inputs as i32 => Ok(ChannelType::Inputs),
32 x if x == ChannelType::Cursor as i32 => Ok(ChannelType::Cursor),
33 x if x == ChannelType::Playback as i32 => Ok(ChannelType::Playback),
34 x if x == ChannelType::Record as i32 => Ok(ChannelType::Record),
35 x if x == ChannelType::Tunnel as i32 => Ok(ChannelType::Tunnel),
36 x if x == ChannelType::Smartcard as i32 => Ok(ChannelType::Smartcard),
37 x if x == ChannelType::Usbredir as i32 => Ok(ChannelType::Usbredir),
38 x if x == ChannelType::Port as i32 => Ok(ChannelType::Port),
39 x if x == ChannelType::Webdav as i32 => Ok(ChannelType::Webdav),
40 x => Err(x),
41 }
42 }
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46#[non_exhaustive]
47pub enum CursorType {
48 Alpha = 0,
49 Mono = 1,
50 Color4 = 2,
51 Color8 = 3,
52 Color16 = 4,
53 Color24 = 5,
54 Color32 = 6,
55}
56
57impl TryFrom<i32> for CursorType {
58 type Error = i32;
59
60 fn try_from(v: i32) -> Result<Self, i32> {
61 match v {
62 x if x == CursorType::Alpha as i32 => Ok(CursorType::Alpha),
63 x if x == CursorType::Mono as i32 => Ok(CursorType::Mono),
64 x if x == CursorType::Color4 as i32 => Ok(CursorType::Color4),
65 x if x == CursorType::Color8 as i32 => Ok(CursorType::Color8),
66 x if x == CursorType::Color16 as i32 => Ok(CursorType::Color16),
67 x if x == CursorType::Color24 as i32 => Ok(CursorType::Color24),
68 x if x == CursorType::Color32 as i32 => Ok(CursorType::Color32),
69 x => Err(x),
70 }
71 }
72}
73
74#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75#[non_exhaustive]
76pub enum SurfaceFormat {
77 Invalid = 0,
78 _1A = 1,
79 _8A = 8,
80 _16_555 = 16,
81 _32XRGB = 32,
82 _16_565 = 80,
83 _32ARGB = 96,
84}
85
86impl TryFrom<i32> for SurfaceFormat {
87 type Error = i32;
88
89 fn try_from(v: i32) -> Result<Self, i32> {
90 match v {
91 x if x == SurfaceFormat::Invalid as i32 => Ok(SurfaceFormat::Invalid),
92 x if x == SurfaceFormat::_1A as i32 => Ok(SurfaceFormat::_1A),
93 x if x == SurfaceFormat::_8A as i32 => Ok(SurfaceFormat::_8A),
94 x if x == SurfaceFormat::_16_555 as i32 => Ok(SurfaceFormat::_16_555),
95 x if x == SurfaceFormat::_32XRGB as i32 => Ok(SurfaceFormat::_32XRGB),
96 x if x == SurfaceFormat::_16_565 as i32 => Ok(SurfaceFormat::_16_565),
97 x if x == SurfaceFormat::_32ARGB as i32 => Ok(SurfaceFormat::_32ARGB),
98 x => Err(x),
99 }
100 }
101}
102
103bitflags! {
104 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
105 pub struct KeyboardModifiersFlags: i32 {
106 const NONE = 0;
107 const SCROLL = 0b00000001;
108 const NUM = 0b00000010;
109 const CAPS = 0b00000100;
110 }
111}
112
113#[derive(Debug, Clone, Copy, PartialEq, Eq)]
114#[non_exhaustive]
115pub enum MouseButton {
116 Invalid = 0,
117 Left = 1,
118 Middle = 2,
119 Right = 3,
120 Up = 4,
121 Down = 5,
122 Side = 6,
123 Extra = 7,
124}
125
126impl TryFrom<i32> for MouseButton {
127 type Error = i32;
128
129 fn try_from(v: i32) -> Result<Self, i32> {
130 match v {
131 x if x == MouseButton::Invalid as i32 => Ok(MouseButton::Invalid),
132 x if x == MouseButton::Left as i32 => Ok(MouseButton::Left),
133 x if x == MouseButton::Middle as i32 => Ok(MouseButton::Middle),
134 x if x == MouseButton::Right as i32 => Ok(MouseButton::Right),
135 x if x == MouseButton::Up as i32 => Ok(MouseButton::Up),
136 x if x == MouseButton::Down as i32 => Ok(MouseButton::Down),
137 x if x == MouseButton::Side as i32 => Ok(MouseButton::Side),
138 x if x == MouseButton::Extra as i32 => Ok(MouseButton::Extra),
139 x => Err(x),
140 }
141 }
142}
143
144bitflags! {
145 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
146 pub struct MouseButtonMask: i32 {
147 const NONE = 0;
148 const LEFT = 0b00000001;
149 const MIDDLE = 0b00000010;
150 const RIGHT = 0b00000100;
151 const UP = 0b00001000;
152 const DOWN = 0b00010000;
153 const SIDE = 0b00100000;
154 const EXTRA = 0b01000000;
155 }
156}
157
158bitflags! {
159 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
160 pub struct MouseMode: i32 {
161 const NONE = 0;
162 const SERVER = 0b00000001;
163 const CLIENT = 0b00000010;
164 }
165}
166
167#[derive(Debug, Clone, Copy, PartialEq, Eq)]
168#[non_exhaustive]
169pub enum ClipboardFormat {
170 None = 0,
171 Utf8 = 1,
172 Png = 2,
173 Bmp = 3,
174 Tiff = 4,
175 Jpg = 5,
176 FileList = 6,
177}
178
179impl TryFrom<i32> for ClipboardFormat {
180 type Error = i32;
181
182 fn try_from(v: i32) -> Result<Self, i32> {
183 match v {
184 x if x == ClipboardFormat::None as i32 => Ok(ClipboardFormat::None),
185 x if x == ClipboardFormat::Utf8 as i32 => Ok(ClipboardFormat::Utf8),
186 x if x == ClipboardFormat::Png as i32 => Ok(ClipboardFormat::Png),
187 x if x == ClipboardFormat::Bmp as i32 => Ok(ClipboardFormat::Bmp),
188 x if x == ClipboardFormat::Tiff as i32 => Ok(ClipboardFormat::Tiff),
189 x if x == ClipboardFormat::Jpg as i32 => Ok(ClipboardFormat::Jpg),
190 x if x == ClipboardFormat::FileList as i32 => Ok(ClipboardFormat::FileList),
191 x => Err(x),
192 }
193 }
194}