add a separate header file for MetaContact::Private class
[kdenetwork.git] / krfb / libvncserver / rfbproto.h
blobcd619dff47a4d0bb3d65c256c612557a5d4ca2d9
1 #ifndef RFBPROTO_H
2 #define RFBPROTO_H
4 /*
5 * Copyright (C) 2000, 2001 Const Kaplinsky. All Rights Reserved.
6 * Copyright (C) 2000 Tridia Corporation. All Rights Reserved.
7 * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
9 * This is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This software is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this software; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 * USA.
26 * rfbproto.h - header file for the RFB protocol version 3.3
28 * Uses types CARD<n> for an n-bit unsigned integer, INT<n> for an n-bit signed
29 * integer (for n = 8, 16 and 32).
31 * All multiple byte integers are in big endian (network) order (most
32 * significant byte first). Unless noted otherwise there is no special
33 * alignment of protocol structures.
36 * Once the initial handshaking is done, all messages start with a type byte,
37 * (usually) followed by message-specific data. The order of definitions in
38 * this file is as follows:
40 * (1) Structures used in several types of message.
41 * (2) Structures used in the initial handshaking.
42 * (3) Message types.
43 * (4) Encoding types.
44 * (5) For each message type, the form of the data following the type byte.
45 * Sometimes this is defined by a single structure but the more complex
46 * messages have to be explained by comments.
50 /*****************************************************************************
52 * Structures used in several messages
54 *****************************************************************************/
56 /*-----------------------------------------------------------------------------
57 * Structure used to specify a rectangle. This structure is a multiple of 4
58 * bytes so that it can be interspersed with 32-bit pixel data without
59 * affecting alignment.
62 typedef struct {
63 CARD16 x;
64 CARD16 y;
65 CARD16 w;
66 CARD16 h;
67 } rfbRectangle;
69 #define sz_rfbRectangle 8
72 /*-----------------------------------------------------------------------------
73 * Structure used to specify pixel format.
76 typedef struct {
78 CARD8 bitsPerPixel; /* 8,16,32 only */
80 CARD8 depth; /* 8 to 32 */
82 CARD8 bigEndian; /* True if multi-byte pixels are interpreted
83 as big endian, or if single-bit-per-pixel
84 has most significant bit of the byte
85 corresponding to first (leftmost) pixel. Of
86 course this is meaningless for 8 bits/pix */
88 CARD8 trueColour; /* If false then we need a "colour map" to
89 convert pixels to RGB. If true, xxxMax and
90 xxxShift specify bits used for red, green
91 and blue */
93 /* the following fields are only meaningful if trueColour is true */
95 CARD16 redMax; /* maximum red value (= 2^n - 1 where n is the
96 number of bits used for red). Note this
97 value is always in big endian order. */
99 CARD16 greenMax; /* similar for green */
101 CARD16 blueMax; /* and blue */
103 CARD8 redShift; /* number of shifts needed to get the red
104 value in a pixel to the least significant
105 bit. To find the red value from a given
106 pixel, do the following:
107 1) Swap pixel value according to bigEndian
108 (e.g. if bigEndian is false and host byte
109 order is big endian, then swap).
110 2) Shift right by redShift.
111 3) AND with redMax (in host byte order).
112 4) You now have the red value between 0 and
113 redMax. */
115 CARD8 greenShift; /* similar for green */
117 CARD8 blueShift; /* and blue */
119 CARD8 pad1;
120 CARD16 pad2;
122 } rfbPixelFormat;
124 #define sz_rfbPixelFormat 16
128 /*****************************************************************************
130 * Initial handshaking messages
132 *****************************************************************************/
134 /*-----------------------------------------------------------------------------
135 * Protocol Version
137 * The server always sends 12 bytes to start which identifies the latest RFB
138 * protocol version number which it supports. These bytes are interpreted
139 * as a string of 12 ASCII characters in the format "RFB xxx.yyy\n" where
140 * xxx and yyy are the major and minor version numbers (for version 3.3
141 * this is "RFB 003.003\n").
143 * The client then replies with a similar 12-byte message giving the version
144 * number of the protocol which should actually be used (which may be different
145 * to that quoted by the server).
147 * It is intended that both clients and servers may provide some level of
148 * backwards compatibility by this mechanism. Servers in particular should
149 * attempt to provide backwards compatibility, and even forwards compatibility
150 * to some extent. For example if a client demands version 3.1 of the
151 * protocol, a 3.0 server can probably assume that by ignoring requests for
152 * encoding types it doesn't understand, everything will still work OK. This
153 * will probably not be the case for changes in the major version number.
155 * The format string below can be used in sprintf or sscanf to generate or
156 * decode the version string respectively.
159 #define rfbProtocolVersionFormat "RFB %03d.%03d\n"
160 #define rfbProtocolMajorVersion 3
161 #define rfbProtocolMinorVersion 3
163 typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */
165 #define sz_rfbProtocolVersionMsg 12
168 /*-----------------------------------------------------------------------------
169 * Authentication
171 * Once the protocol version has been decided, the server then sends a 32-bit
172 * word indicating whether any authentication is needed on the connection.
173 * The value of this word determines the authentication scheme in use. For
174 * version 3.0 of the protocol this may have one of the following values:
177 #define rfbConnFailed 0
178 #define rfbNoAuth 1
179 #define rfbVncAuth 2
182 * rfbConnFailed: For some reason the connection failed (e.g. the server
183 * cannot support the desired protocol version). This is
184 * followed by a string describing the reason (where a
185 * string is specified as a 32-bit length followed by that
186 * many ASCII characters).
188 * rfbNoAuth: No authentication is needed.
190 * rfbVncAuth: The VNC authentication scheme is to be used. A 16-byte
191 * challenge follows, which the client encrypts as
192 * appropriate using the password and sends the resulting
193 * 16-byte response. If the response is correct, the
194 * server sends the 32-bit word rfbVncAuthOK. If a simple
195 * failure happens, the server sends rfbVncAuthFailed and
196 * closes the connection. If the server decides that too
197 * many failures have occurred, it sends rfbVncAuthTooMany
198 * and closes the connection. In the latter case, the
199 * server should not allow an immediate reconnection by
200 * the client.
203 #define rfbVncAuthOK 0
204 #define rfbVncAuthFailed 1
205 #define rfbVncAuthTooMany 2
208 /*-----------------------------------------------------------------------------
209 * Client Initialisation Message
211 * Once the client and server are sure that they're happy to talk to one
212 * another, the client sends an initialisation message. At present this
213 * message only consists of a boolean indicating whether the server should try
214 * to share the desktop by leaving other clients connected, or give exclusive
215 * access to this client by disconnecting all other clients.
218 typedef struct {
219 CARD8 shared;
220 } rfbClientInitMsg;
222 #define sz_rfbClientInitMsg 1
225 /*-----------------------------------------------------------------------------
226 * Server Initialisation Message
228 * After the client initialisation message, the server sends one of its own.
229 * This tells the client the width and height of the server's framebuffer,
230 * its pixel format and the name associated with the desktop.
233 typedef struct {
234 CARD16 framebufferWidth;
235 CARD16 framebufferHeight;
236 rfbPixelFormat format; /* the server's preferred pixel format */
237 CARD32 nameLength;
238 /* followed by char name[nameLength] */
239 } rfbServerInitMsg;
241 #define sz_rfbServerInitMsg (8 + sz_rfbPixelFormat)
245 * Following the server initialisation message it's up to the client to send
246 * whichever protocol messages it wants. Typically it will send a
247 * SetPixelFormat message and a SetEncodings message, followed by a
248 * FramebufferUpdateRequest. From then on the server will send
249 * FramebufferUpdate messages in response to the client's
250 * FramebufferUpdateRequest messages. The client should send
251 * FramebufferUpdateRequest messages with incremental set to true when it has
252 * finished processing one FramebufferUpdate and is ready to process another.
253 * With a fast client, the rate at which FramebufferUpdateRequests are sent
254 * should be regulated to avoid hogging the network.
259 /*****************************************************************************
261 * Message types
263 *****************************************************************************/
265 /* server -> client */
267 #define rfbFramebufferUpdate 0
268 #define rfbSetColourMapEntries 1
269 #define rfbBell 2
270 #define rfbServerCutText 3
271 #ifdef BACKCHANNEL
272 #define rfbBackChannel 15
273 #endif
275 /* client -> server */
277 #define rfbSetPixelFormat 0
278 #define rfbFixColourMapEntries 1 /* not currently supported */
279 #define rfbSetEncodings 2
280 #define rfbFramebufferUpdateRequest 3
281 #define rfbKeyEvent 4
282 #define rfbPointerEvent 5
283 #define rfbClientCutText 6
288 /*****************************************************************************
290 * Encoding types
292 *****************************************************************************/
294 #define rfbEncodingRaw 0
295 #define rfbEncodingCopyRect 1
296 #define rfbEncodingRRE 2
297 #define rfbEncodingCoRRE 4
298 #define rfbEncodingHextile 5
299 #define rfbEncodingZlib 6
300 #define rfbEncodingTight 7
301 #define rfbEncodingZlibHex 8
302 #ifdef BACKCHANNEL
303 #define rfbEncodingBackChannel 15
304 #endif
307 * Special encoding numbers:
308 * 0xFFFFFF00 .. 0xFFFFFF0F -- encoding-specific compression levels;
309 * 0xFFFFFF10 .. 0xFFFFFF1F -- mouse cursor shape data;
310 * 0xFFFFFF20 .. 0xFFFFFF2F -- various protocol extensions;
311 * 0xFFFFFF30 .. 0xFFFFFFDF -- not allocated yet;
312 * 0xFFFFFFE0 .. 0xFFFFFFEF -- quality level for JPEG compressor;
313 * 0xFFFFFFF0 .. 0xFFFFFFFF -- cross-encoding compression levels.
316 #define rfbEncodingCompressLevel0 0xFFFFFF00
317 #define rfbEncodingCompressLevel1 0xFFFFFF01
318 #define rfbEncodingCompressLevel2 0xFFFFFF02
319 #define rfbEncodingCompressLevel3 0xFFFFFF03
320 #define rfbEncodingCompressLevel4 0xFFFFFF04
321 #define rfbEncodingCompressLevel5 0xFFFFFF05
322 #define rfbEncodingCompressLevel6 0xFFFFFF06
323 #define rfbEncodingCompressLevel7 0xFFFFFF07
324 #define rfbEncodingCompressLevel8 0xFFFFFF08
325 #define rfbEncodingCompressLevel9 0xFFFFFF09
327 #define rfbEncodingXCursor 0xFFFFFF10
328 #define rfbEncodingRichCursor 0xFFFFFF11
329 #define rfbEncodingSoftCursor 0xFFFFFF12
331 #define rfbEncodingLastRect 0xFFFFFF20
332 #define rfbEncodingBackground 0xFFFFFF25
334 #define rfbEncodingQualityLevel0 0xFFFFFFE0
335 #define rfbEncodingQualityLevel1 0xFFFFFFE1
336 #define rfbEncodingQualityLevel2 0xFFFFFFE2
337 #define rfbEncodingQualityLevel3 0xFFFFFFE3
338 #define rfbEncodingQualityLevel4 0xFFFFFFE4
339 #define rfbEncodingQualityLevel5 0xFFFFFFE5
340 #define rfbEncodingQualityLevel6 0xFFFFFFE6
341 #define rfbEncodingQualityLevel7 0xFFFFFFE7
342 #define rfbEncodingQualityLevel8 0xFFFFFFE8
343 #define rfbEncodingQualityLevel9 0xFFFFFFE9
346 /*****************************************************************************
348 * Server -> client message definitions
350 *****************************************************************************/
353 /*-----------------------------------------------------------------------------
354 * FramebufferUpdate - a block of rectangles to be copied to the framebuffer.
356 * This message consists of a header giving the number of rectangles of pixel
357 * data followed by the rectangles themselves. The header is padded so that
358 * together with the type byte it is an exact multiple of 4 bytes (to help
359 * with alignment of 32-bit pixels):
362 typedef struct {
363 CARD8 type; /* always rfbFramebufferUpdate */
364 CARD8 pad;
365 CARD16 nRects;
366 /* followed by nRects rectangles */
367 } rfbFramebufferUpdateMsg;
369 #define sz_rfbFramebufferUpdateMsg 4
372 * Each rectangle of pixel data consists of a header describing the position
373 * and size of the rectangle and a type word describing the encoding of the
374 * pixel data, followed finally by the pixel data. Note that if the client has
375 * not sent a SetEncodings message then it will only receive raw pixel data.
376 * Also note again that this structure is a multiple of 4 bytes.
379 typedef struct {
380 rfbRectangle r;
381 CARD32 encoding; /* one of the encoding types rfbEncoding... */
382 } rfbFramebufferUpdateRectHeader;
384 #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4)
387 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
388 * Raw Encoding. Pixels are sent in top-to-bottom scanline order,
389 * left-to-right within a scanline with no padding in between.
393 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
394 * CopyRect Encoding. The pixels are specified simply by the x and y position
395 * of the source rectangle.
398 typedef struct {
399 CARD16 srcX;
400 CARD16 srcY;
401 } rfbCopyRect;
403 #define sz_rfbCopyRect 4
406 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
407 * RRE - Rise-and-Run-length Encoding. We have an rfbRREHeader structure
408 * giving the number of subrectangles following. Finally the data follows in
409 * the form [<bgpixel><subrect><subrect>...] where each <subrect> is
410 * [<pixel><rfbRectangle>].
413 typedef struct {
414 CARD32 nSubrects;
415 } rfbRREHeader;
417 #define sz_rfbRREHeader 4
420 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
421 * CoRRE - Compact RRE Encoding. We have an rfbRREHeader structure giving
422 * the number of subrectangles following. Finally the data follows in the form
423 * [<bgpixel><subrect><subrect>...] where each <subrect> is
424 * [<pixel><rfbCoRRERectangle>]. This means that
425 * the whole rectangle must be at most 255x255 pixels.
428 typedef struct {
429 CARD8 x;
430 CARD8 y;
431 CARD8 w;
432 CARD8 h;
433 } rfbCoRRERectangle;
435 #define sz_rfbCoRRERectangle 4
438 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
439 * Hextile Encoding. The rectangle is divided up into "tiles" of 16x16 pixels,
440 * starting at the top left going in left-to-right, top-to-bottom order. If
441 * the width of the rectangle is not an exact multiple of 16 then the width of
442 * the last tile in each row will be correspondingly smaller. Similarly if the
443 * height is not an exact multiple of 16 then the height of each tile in the
444 * final row will also be smaller. Each tile begins with a "subencoding" type
445 * byte, which is a mask made up of a number of bits. If the Raw bit is set
446 * then the other bits are irrelevant; w*h pixel values follow (where w and h
447 * are the width and height of the tile). Otherwise the tile is encoded in a
448 * similar way to RRE, except that the position and size of each subrectangle
449 * can be specified in just two bytes. The other bits in the mask are as
450 * follows:
452 * BackgroundSpecified - if set, a pixel value follows which specifies
453 * the background colour for this tile. The first non-raw tile in a
454 * rectangle must have this bit set. If this bit isn't set then the
455 * background is the same as the last tile.
457 * ForegroundSpecified - if set, a pixel value follows which specifies
458 * the foreground colour to be used for all subrectangles in this tile.
459 * If this bit is set then the SubrectsColoured bit must be zero.
461 * AnySubrects - if set, a single byte follows giving the number of
462 * subrectangles following. If not set, there are no subrectangles (i.e.
463 * the whole tile is just solid background colour).
465 * SubrectsColoured - if set then each subrectangle is preceded by a pixel
466 * value giving the colour of that subrectangle. If not set, all
467 * subrectangles are the same colour, the foreground colour; if the
468 * ForegroundSpecified bit wasn't set then the foreground is the same as
469 * the last tile.
471 * The position and size of each subrectangle is specified in two bytes. The
472 * Pack macros below can be used to generate the two bytes from x, y, w, h,
473 * and the Extract macros can be used to extract the x, y, w, h values from
474 * the two bytes.
477 #define rfbHextileRaw (1 << 0)
478 #define rfbHextileBackgroundSpecified (1 << 1)
479 #define rfbHextileForegroundSpecified (1 << 2)
480 #define rfbHextileAnySubrects (1 << 3)
481 #define rfbHextileSubrectsColoured (1 << 4)
483 #define rfbHextilePackXY(x,y) (((x) << 4) | (y))
484 #define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1))
485 #define rfbHextileExtractX(byte) ((byte) >> 4)
486 #define rfbHextileExtractY(byte) ((byte) & 0xf)
487 #define rfbHextileExtractW(byte) (((byte) >> 4) + 1)
488 #define rfbHextileExtractH(byte) (((byte) & 0xf) + 1)
491 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
492 * zlib - zlib compressed Encoding. We have an rfbZlibHeader structure
493 * giving the number of bytes following. Finally the data follows is
494 * zlib compressed version of the raw pixel data as negotiated.
497 typedef struct {
498 CARD32 nBytes;
499 } rfbZlibHeader;
501 #define sz_rfbZlibHeader 4
504 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
505 * Tight Encoding. FIXME: Add more documentation.
508 #define rfbTightExplicitFilter 0x04
509 #define rfbTightFill 0x08
510 #define rfbTightJpeg 0x09
511 #define rfbTightMaxSubencoding 0x09
513 /* Filters to improve compression efficiency */
514 #define rfbTightFilterCopy 0x00
515 #define rfbTightFilterPalette 0x01
516 #define rfbTightFilterGradient 0x02
518 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
519 * XCursor encoding. This is a special encoding used to transmit X-style
520 * cursor shapes from server to clients. Note that for this encoding,
521 * coordinates in rfbFramebufferUpdateRectHeader structure hold hotspot
522 * position (r.x, r.y) and cursor size (r.w, r.h). If (w * h != 0), two RGB
523 * samples are sent after header in the rfbXCursorColors structure. They
524 * denote foreground and background colors of the cursor. If a client
525 * supports only black-and-white cursors, it should ignore these colors and
526 * assume that foreground is black and background is white. Next, two bitmaps
527 * (1 bits per pixel) follow: first one with actual data (value 0 denotes
528 * background color, value 1 denotes foreground color), second one with
529 * transparency data (bits with zero value mean that these pixels are
530 * transparent). Both bitmaps represent cursor data in a byte stream, from
531 * left to right, from top to bottom, and each row is byte-aligned. Most
532 * significant bits correspond to leftmost pixels. The number of bytes in
533 * each row can be calculated as ((w + 7) / 8). If (w * h == 0), cursor
534 * should be hidden (or default local cursor should be set by the client).
537 typedef struct {
538 CARD8 foreRed;
539 CARD8 foreGreen;
540 CARD8 foreBlue;
541 CARD8 backRed;
542 CARD8 backGreen;
543 CARD8 backBlue;
544 } rfbXCursorColors;
546 #define sz_rfbXCursorColors 6
549 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
550 * RichCursor encoding. This is a special encoding used to transmit cursor
551 * shapes from server to clients. It is similar to the XCursor encoding but
552 * uses client pixel format instead of two RGB colors to represent cursor
553 * image. For this encoding, coordinates in rfbFramebufferUpdateRectHeader
554 * structure hold hotspot position (r.x, r.y) and cursor size (r.w, r.h).
555 * After header, two pixmaps follow: first one with cursor image in current
556 * client pixel format (like in raw encoding), second with transparency data
557 * (1 bit per pixel, exactly the same format as used for transparency bitmap
558 * in the XCursor encoding). If (w * h == 0), cursor should be hidden (or
559 * default local cursor should be set by the client).
562 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
563 * SoftCursor encoding. This encoding is used to transmit image and position
564 * of the remote cursor. It has two sub-messages: SetImage is used to upload
565 * one of 16 images, and Move selects the image and sets the position of the
566 * cursor.
567 * Each SoftCursor message starts with a CARD8. If it is in the 0-15 range
568 * it specifies the number of the cursor image and is followed by the
569 * rfbSoftCursorMove message. If the given cursor has not been set yet the
570 * message will be ignored. If the first CARD8 is in the 128-143 range it
571 * specifies the cursor that will be set in the following
572 * rfbSoftCursorSetImage message. To hide the cursor send a SetImage
573 * message with width and height 0 and imageLength 0.
574 * SetImage transmits the hotspot coordinates in the x/y fields of the
575 * rfbFramebufferUpdateRectHeader, width and height of the image are in the
576 * header's width and height fields.
577 * Move transmits the pointer coordinates in the w/h fields of the
578 * header, x/y are always 0.
581 typedef struct {
582 CARD8 imageIndex;
583 CARD8 buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */
584 } rfbSoftCursorMove;
586 typedef struct {
587 CARD8 imageIndex;
588 CARD8 padding;
589 CARD16 imageLength;
591 * Followed by an image of the cursor in the client's image format
592 * with the following RLE mask compression. It begins with CARD8 that
593 * specifies the number of mask'ed pixels that will be NOT transmitted.
594 * Then follows a CARD8 that specified by the number of unmask'd pixels
595 * that will be transmitted next. Then a CARD8 with the number of mask'd
596 * pixels and so on.
598 } rfbSoftCursorSetImage;
600 typedef union {
601 CARD8 type;
602 rfbSoftCursorMove move;
603 rfbSoftCursorSetImage setImage;
604 } rfbSoftCursorMsg;
606 #define rfbSoftCursorMaxImages 16
607 #define rfbSoftCursorSetIconOffset 128
610 /*-----------------------------------------------------------------------------
611 * SetColourMapEntries - these messages are only sent if the pixel
612 * format uses a "colour map" (i.e. trueColour false) and the client has not
613 * fixed the entire colour map using FixColourMapEntries. In addition they
614 * will only start being sent after the client has sent its first
615 * FramebufferUpdateRequest. So if the client always tells the server to use
616 * trueColour then it never needs to process this type of message.
619 typedef struct {
620 CARD8 type; /* always rfbSetColourMapEntries */
621 CARD8 pad;
622 CARD16 firstColour;
623 CARD16 nColours;
625 /* Followed by nColours * 3 * CARD16
626 r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
628 } rfbSetColourMapEntriesMsg;
630 #define sz_rfbSetColourMapEntriesMsg 6
634 /*-----------------------------------------------------------------------------
635 * Bell - ring a bell on the client if it has one.
638 typedef struct {
639 CARD8 type; /* always rfbBell */
640 } rfbBellMsg;
642 #define sz_rfbBellMsg 1
646 /*-----------------------------------------------------------------------------
647 * ServerCutText - the server has new text in its cut buffer.
650 typedef struct {
651 CARD8 type; /* always rfbServerCutText */
652 CARD8 pad1;
653 CARD16 pad2;
654 CARD32 length;
655 /* followed by char text[length] */
656 } rfbServerCutTextMsg;
658 #define sz_rfbServerCutTextMsg 8
660 #ifdef BACKCHANNEL
661 typedef rfbServerCutTextMsg rfbBackChannelMsg;
662 #define sz_rfbBackChannelMsg 8
663 #endif
666 /*-----------------------------------------------------------------------------
667 * Union of all server->client messages.
670 typedef union {
671 CARD8 type;
672 rfbFramebufferUpdateMsg fu;
673 rfbSetColourMapEntriesMsg scme;
674 rfbBellMsg b;
675 rfbServerCutTextMsg sct;
676 } rfbServerToClientMsg;
680 /*****************************************************************************
682 * Message definitions (client -> server)
684 *****************************************************************************/
687 /*-----------------------------------------------------------------------------
688 * SetPixelFormat - tell the RFB server the format in which the client wants
689 * pixels sent.
692 typedef struct {
693 CARD8 type; /* always rfbSetPixelFormat */
694 CARD8 pad1;
695 CARD16 pad2;
696 rfbPixelFormat format;
697 } rfbSetPixelFormatMsg;
699 #define sz_rfbSetPixelFormatMsg (sz_rfbPixelFormat + 4)
702 /*-----------------------------------------------------------------------------
703 * FixColourMapEntries - when the pixel format uses a "colour map", fix
704 * read-only colour map entries.
706 * ***************** NOT CURRENTLY SUPPORTED *****************
709 typedef struct {
710 CARD8 type; /* always rfbFixColourMapEntries */
711 CARD8 pad;
712 CARD16 firstColour;
713 CARD16 nColours;
715 /* Followed by nColours * 3 * CARD16
716 r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
718 } rfbFixColourMapEntriesMsg;
720 #define sz_rfbFixColourMapEntriesMsg 6
723 /*-----------------------------------------------------------------------------
724 * SetEncodings - tell the RFB server which encoding types we accept. Put them
725 * in order of preference, if we have any. We may always receive raw
726 * encoding, even if we don't specify it here.
729 typedef struct {
730 CARD8 type; /* always rfbSetEncodings */
731 CARD8 pad;
732 CARD16 nEncodings;
733 /* followed by nEncodings * CARD32 encoding types */
734 } rfbSetEncodingsMsg;
736 #define sz_rfbSetEncodingsMsg 4
739 /*-----------------------------------------------------------------------------
740 * FramebufferUpdateRequest - request for a framebuffer update. If incremental
741 * is true then the client just wants the changes since the last update. If
742 * false then it wants the whole of the specified rectangle.
745 typedef struct {
746 CARD8 type; /* always rfbFramebufferUpdateRequest */
747 CARD8 incremental;
748 CARD16 x;
749 CARD16 y;
750 CARD16 w;
751 CARD16 h;
752 } rfbFramebufferUpdateRequestMsg;
754 #define sz_rfbFramebufferUpdateRequestMsg 10
757 /*-----------------------------------------------------------------------------
758 * KeyEvent - key press or release
760 * Keys are specified using the "keysym" values defined by the X Window System.
761 * For most ordinary keys, the keysym is the same as the corresponding ASCII
762 * value. Other common keys are:
764 * BackSpace 0xff08
765 * Tab 0xff09
766 * Return or Enter 0xff0d
767 * Escape 0xff1b
768 * Insert 0xff63
769 * Delete 0xffff
770 * Home 0xff50
771 * End 0xff57
772 * Page Up 0xff55
773 * Page Down 0xff56
774 * Left 0xff51
775 * Up 0xff52
776 * Right 0xff53
777 * Down 0xff54
778 * F1 0xffbe
779 * F2 0xffbf
780 * ... ...
781 * F12 0xffc9
782 * Shift 0xffe1
783 * Control 0xffe3
784 * Meta 0xffe7
785 * Alt 0xffe9
788 typedef struct {
789 CARD8 type; /* always rfbKeyEvent */
790 CARD8 down; /* true if down (press), false if up */
791 CARD16 pad;
792 CARD32 key; /* key is specified as an X keysym */
793 } rfbKeyEventMsg;
795 #define sz_rfbKeyEventMsg 8
798 /*-----------------------------------------------------------------------------
799 * PointerEvent - mouse/pen move and/or button press.
802 typedef struct {
803 CARD8 type; /* always rfbPointerEvent */
804 CARD8 buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */
805 CARD16 x;
806 CARD16 y;
807 } rfbPointerEventMsg;
809 #define rfbButton1Mask 1
810 #define rfbButton2Mask 2
811 #define rfbButton3Mask 4
813 #define sz_rfbPointerEventMsg 6
817 /*-----------------------------------------------------------------------------
818 * ClientCutText - the client has new text in its cut buffer.
821 typedef struct {
822 CARD8 type; /* always rfbClientCutText */
823 CARD8 pad1;
824 CARD16 pad2;
825 CARD32 length;
826 /* followed by char text[length] */
827 } rfbClientCutTextMsg;
829 #define sz_rfbClientCutTextMsg 8
833 /*-----------------------------------------------------------------------------
834 * Union of all client->server messages.
837 typedef union {
838 CARD8 type;
839 rfbSetPixelFormatMsg spf;
840 rfbFixColourMapEntriesMsg fcme;
841 rfbSetEncodingsMsg se;
842 rfbFramebufferUpdateRequestMsg fur;
843 rfbKeyEventMsg ke;
844 rfbPointerEventMsg pe;
845 rfbClientCutTextMsg cct;
846 } rfbClientToServerMsg;
848 #endif