-
Notifications
You must be signed in to change notification settings - Fork 1
/
proto.x
214 lines (194 loc) · 4.49 KB
/
proto.x
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
* XDR-based core wire protocol.
*
* Note that this is not the *entirety* of the wire protocol; see comment in
* message.c.
*
* Note also that while some messages are described as expecting a reply, the
* only place where the reply is a strict requirement is in the initial
* SETUP/READY handshake sequence; beyond that the protocol is completely
* stateless (though if everything's operating correctly the expected replies
* *should* be given).
*/
/* HACK: glibc's rpcgen generates XDR code with unused variables. */
#ifdef RPC_XDR
%#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#ifdef __APPLE__
typedef u_int32_t uint32_t;
#endif
enum msgtype_t {
MT_SETUP = 1,
MT_READY,
MT_MOVEREL,
MT_MOVEABS,
MT_MOUSEPOS,
MT_CLICKEVENT,
MT_KEYEVENT,
MT_GETCLIPBOARD,
MT_SETCLIPBOARD,
MT_LOGMSG,
MT_SETBRIGHTNESS,
MT_SETLOGLEVEL
};
/* Screen position (e.g. for the mouse pointer), with 0,0 at the top left. */
struct xypoint {
int32_t x;
int32_t y;
};
struct range {
int32_t min;
int32_t max;
};
/* An area of screen space (used for screen dimensions) */
struct rectangle {
range x;
range y;
};
/* A simple key-value pair. */
struct kvpair {
string key<>;
string value<>;
};
/*
* SETUP: the first message sent by the master to each remote upon
* establishing a connection. Contains various initialization parameters,
* including log level and an unstructured kvmap of miscellaneous other things
* (like the DISPLAY environment variable for X11 remotes).
*
* Should trigger a READY in reply.
*/
struct setup_body {
uint32_t prot_vers;
uint32_t loglevel;
kvpair params<>;
};
/*
* READY: the first message sent by a newly-alive remote in response to
* receiving a SETUP from the master. Informs the master of the remote's
* display dimensions.
*
* No reply expected.
*/
struct ready_body {
rectangle screendim;
};
/*
* MOVEREL: sent by the master to a remote to instruct it move the mouse
* pointer relative to its current position.
*
* Should trigger a MOUSEPOS in reply.
*/
struct moverel_body {
int32_t dx;
int32_t dy;
};
/*
* MOVEABS: sent by the master to a remote to instruct it to move the mouse
* pointer to an absolute position.
*
* No reply expected.
*/
struct moveabs_body {
xypoint pt;
};
/*
* MOUSEPOS: sent by remotes to the master in response to a MOVEREL to inform
* the master of the mouse pointer's new position (post-MOVEREL).
*
* No reply expected.
*/
struct mousepos_body {
xypoint pt;
};
/*
* CLICKEVENT: sent by the master to a remote to generate a mouse-click event.
*
* No reply expected.
*/
struct clickevent_body {
uint32_t button;
uint32_t pressrel;
};
/*
* KEYEVENT: sent by the master to a remote to generate a keypress event.
*
* No reply expected.
*/
struct keyevent_body {
uint32_t keycode;
uint32_t pressrel;
};
/*
* GETCLIPBOARD: sent by the master to a remote to retrieve the contents of
* the remote's clipboard.
*
* Should trigger a SETCLIPBOARD in reply.
*
* GETCLIPBOARD messages have no body content.
*/
/*
* SETCLIPBOARD: sent from the master to a remote when switching focus to that
* remote, or from a remote to the master in response to a GETCLIPBOARD.
* Instructs the recipient to set its clipboard to the supplied content.
*
* No reply expected.
*/
struct setclipboard_body {
string text<>;
};
/*
* LOGMSG: sent by remotes to the master to write a message to the log.
* Log-level filtering is done on the remotes (so that this already-chatty
* protocol doesn't become wastefully more so), so LOGMSG messages are
* unconditionally written to the log.
*
* No reply expected.
*/
struct logmsg_body {
string msg<>;
};
/*
* SETBRIGHTNESS: sent by the master to a remote to instruct it to set its
* screen brightness to the given level.
*
* No reply expected.
*/
struct setbrightness_body {
float brightness;
};
/*
* SETLOGLEVEL: sent by master to remotes to request a dynamic log-level
* change.
*
* No reply expected.
*/
struct setloglevel_body {
uint32_t loglevel;
};
union msgbody switch (msgtype_t type) {
case MT_SETUP:
setup_body setup;
case MT_READY:
ready_body ready;
case MT_MOVEREL:
moverel_body moverel;
case MT_MOVEABS:
moveabs_body moveabs;
case MT_MOUSEPOS:
mousepos_body mousepos;
case MT_CLICKEVENT:
clickevent_body clickevent;
case MT_KEYEVENT:
keyevent_body keyevent;
case MT_GETCLIPBOARD:
void;
case MT_SETCLIPBOARD:
setclipboard_body setclipboard;
case MT_LOGMSG:
logmsg_body logmsg;
case MT_SETBRIGHTNESS:
setbrightness_body setbrightness;
case MT_SETLOGLEVEL:
setloglevel_body setloglevel;
};