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
use crate::PixelFormat;
type ImageData = Vec<u8>;
#[derive(Debug, Clone, Copy)]
pub struct Rect {
pub x: u16,
pub y: u16,
pub width: u16,
pub height: u16,
}
#[derive(Debug, Clone)]
pub struct Screen {
pub width: u16,
pub height: u16,
}
impl From<(u16, u16)> for Screen {
fn from(tuple: (u16, u16)) -> Self {
Self {
width: tuple.0,
height: tuple.1,
}
}
}
type SrcRect = Rect;
type DstRect = Rect;
#[non_exhaustive]
#[derive(Debug, Clone)]
pub enum VncEvent {
SetResolution(Screen),
SetPixelFormat(PixelFormat),
RawImage(Rect, ImageData),
Copy(DstRect, SrcRect),
JpegImage(Rect, ImageData),
SetCursor(Rect, ImageData),
Bell,
Text(String),
}
#[derive(Debug, Clone)]
pub struct ClientKeyEvent {
pub keycode: u32,
pub down: bool,
}
impl From<(u32, bool)> for ClientKeyEvent {
fn from(tuple: (u32, bool)) -> Self {
Self {
keycode: tuple.0,
down: tuple.1,
}
}
}
#[derive(Debug, Clone)]
pub struct ClientMouseEvent {
pub position_x: u16,
pub position_y: u16,
pub bottons: u8,
}
impl From<(u16, u16, u8)> for ClientMouseEvent {
fn from(tuple: (u16, u16, u8)) -> Self {
Self {
position_x: tuple.0,
position_y: tuple.1,
bottons: tuple.2,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone)]
pub enum X11Event {
Refresh,
KeyEvent(ClientKeyEvent),
PointerEvent(ClientMouseEvent),
CopyText(String),
}