libguac  0.6.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
protocol.h
Go to the documentation of this file.
1 
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is libguac.
16  *
17  * The Initial Developer of the Original Code is
18  * Michael Jumper.
19  * Portions created by the Initial Developer are Copyright (C) 2010
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPL"), or
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27  * in which case the provisions of the GPL or the LGPL are applicable instead
28  * of those above. If you wish to allow use of your version of this file only
29  * under the terms of either the GPL or the LGPL, and not to allow others to
30  * use your version of this file under the terms of the MPL, indicate your
31  * decision by deleting the provisions above and replace them with the notice
32  * and other provisions required by the GPL or the LGPL. If you do not delete
33  * the provisions above, a recipient may use your version of this file under
34  * the terms of any one of the MPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
37 
38 #ifndef _GUAC_PROTOCOL_H
39 #define _GUAC_PROTOCOL_H
40 
41 #include <cairo/cairo.h>
42 
43 #include "socket.h"
44 
57 typedef int64_t guac_timestamp;
58 
63 typedef enum guac_composite_mode {
64 
65  /*
66  * A: Source where destination transparent = S n D'
67  * B: Source where destination opaque = S n D
68  * C: Destination where source transparent = D n S'
69  * D: Destination where source opaque = D n S
70  *
71  * 0 = Active, 1 = Inactive
72  */
73  /* ABCD */
74  GUAC_COMP_ROUT = 0x2, /* 0010 - Clears destination where source opaque */
75  GUAC_COMP_ATOP = 0x6, /* 0110 - Fill where destination opaque only */
76  GUAC_COMP_XOR = 0xA, /* 1010 - XOR */
77  GUAC_COMP_ROVER = 0xB, /* 1011 - Fill where destination transparent only */
78  GUAC_COMP_OVER = 0xE, /* 1110 - Draw normally */
79  GUAC_COMP_PLUS = 0xF, /* 1111 - Add */
80 
81  /* Unimplemented in client: */
82  /* NOT IMPLEMENTED: 0000 - Clear */
83  /* NOT IMPLEMENTED: 0011 - No operation */
84  /* NOT IMPLEMENTED: 0101 - Additive IN */
85  /* NOT IMPLEMENTED: 0111 - Additive ATOP */
86  /* NOT IMPLEMENTED: 1101 - Additive RATOP */
87 
88  /* Buggy in webkit browsers, as they keep channel C on in all cases: */
89  GUAC_COMP_RIN = 0x1, /* 0001 */
90  GUAC_COMP_IN = 0x4, /* 0100 */
91  GUAC_COMP_OUT = 0x8, /* 1000 */
92  GUAC_COMP_RATOP = 0x9, /* 1001 */
93  GUAC_COMP_SRC = 0xC /* 1100 */
94 
95  /* Bitwise composite operations (binary) */
96 
97  /*
98  * A: S' & D'
99  * B: S' & D
100  * C: S & D'
101  * D: S & D
102  *
103  * 0 = Active, 1 = Inactive
104  */
105 
107 
108 
114 
115  /* Constant functions */ /* ABCD */
116  GUAC_TRANSFER_BINARY_BLACK = 0x0, /* 0000 */
117  GUAC_TRANSFER_BINARY_WHITE = 0xF, /* 1111 */
118 
119  /* Copy functions */
120  GUAC_TRANSFER_BINARY_SRC = 0x3, /* 0011 */
121  GUAC_TRANSFER_BINARY_DEST = 0x5, /* 0101 */
122  GUAC_TRANSFER_BINARY_NSRC = 0xC, /* 1100 */
123  GUAC_TRANSFER_BINARY_NDEST = 0xA, /* 1010 */
124 
125  /* AND / NAND */
126  GUAC_TRANSFER_BINARY_AND = 0x1, /* 0001 */
127  GUAC_TRANSFER_BINARY_NAND = 0xE, /* 1110 */
128 
129  /* OR / NOR */
130  GUAC_TRANSFER_BINARY_OR = 0x7, /* 0111 */
131  GUAC_TRANSFER_BINARY_NOR = 0x8, /* 1000 */
132 
133  /* XOR / XNOR */
134  GUAC_TRANSFER_BINARY_XOR = 0x6, /* 0110 */
135  GUAC_TRANSFER_BINARY_XNOR = 0x9, /* 1001 */
136 
137  /* AND / NAND with inverted source */
138  GUAC_TRANSFER_BINARY_NSRC_AND = 0x4, /* 0100 */
139  GUAC_TRANSFER_BINARY_NSRC_NAND = 0xB, /* 1011 */
140 
141  /* OR / NOR with inverted source */
142  GUAC_TRANSFER_BINARY_NSRC_OR = 0xD, /* 1101 */
143  GUAC_TRANSFER_BINARY_NSRC_NOR = 0x2, /* 0010 */
144 
145  /* AND / NAND with inverted destination */
146  GUAC_TRANSFER_BINARY_NDEST_AND = 0x2, /* 0010 */
147  GUAC_TRANSFER_BINARY_NDEST_NAND = 0xD, /* 1101 */
148 
149  /* OR / NOR with inverted destination */
150  GUAC_TRANSFER_BINARY_NDEST_OR = 0xB, /* 1011 */
151  GUAC_TRANSFER_BINARY_NDEST_NOR = 0x4 /* 0100 */
152 
154 
158 typedef enum guac_line_cap_style {
159  GUAC_LINE_CAP_BUTT = 0x0,
160  GUAC_LINE_CAP_ROUND = 0x1,
161  GUAC_LINE_CAP_SQUARE = 0x2
163 
167 typedef enum guac_line_join_style {
168  GUAC_LINE_JOIN_BEVEL = 0x0,
169  GUAC_LINE_JOIN_MITER = 0x1,
170  GUAC_LINE_JOIN_ROUND = 0x2
172 
173 typedef struct guac_layer guac_layer;
174 
178 struct guac_layer {
179 
183  int index;
184 
188  guac_layer* __next;
189 
194  guac_layer* __next_available;
195 
196 };
197 
201 typedef struct guac_instruction {
202 
206  char* opcode;
207 
211  int argc;
212 
216  char** argv;
217 
219 
220 
226 void guac_instruction_free(guac_instruction* instruction);
227 
238 int guac_protocol_instructions_waiting(guac_socket* socket, int usec_timeout);
239 
257  int usec_timeout);
258 
279  int usec_timeout, const char* opcode);
280 
290 
291 /* CONTROL INSTRUCTIONS */
292 
303 int guac_protocol_send_args(guac_socket* socket, const char** args);
304 
315 int guac_protocol_send_connect(guac_socket* socket, const char** args);
316 
327 
338 int guac_protocol_send_error(guac_socket* socket, const char* error);
339 
352 int guac_protocol_send_set(guac_socket* socket, const guac_layer* layer,
353  const char* name, const char* value);
354 
365 int guac_protocol_send_select(guac_socket* socket, const char* protocol);
366 
378 int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp);
379 
380 /* DRAWING INSTRUCTIONS */
381 
399 int guac_protocol_send_arc(guac_socket* socket, const guac_layer* layer,
400  int x, int y, int radius, double startAngle, double endAngle,
401  int negative);
402 
419  guac_composite_mode mode, const guac_layer* layer,
420  int r, int g, int b, int a);
421 
432 int guac_protocol_send_clip(guac_socket* socket, const guac_layer* layer);
433 
444 int guac_protocol_send_close(guac_socket* socket, const guac_layer* layer);
445 
467  const guac_layer* srcl, int srcx, int srcy, int w, int h,
468  guac_composite_mode mode, const guac_layer* dstl, int dstx, int dsty);
469 
489  guac_composite_mode mode, const guac_layer* layer,
490  guac_line_cap_style cap, guac_line_join_style join, int thickness,
491  int r, int g, int b, int a);
492 
509 int guac_protocol_send_cursor(guac_socket* socket, int x, int y,
510  const guac_layer* srcl, int srcx, int srcy, int w, int h);
511 
528 int guac_protocol_send_curve(guac_socket* socket, const guac_layer* layer,
529  int cp1x, int cp1y, int cp2x, int cp2y, int x, int y);
530 
541 int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer);
542 
556  guac_composite_mode mode, const guac_layer* layer,
557  const guac_layer* srcl);
558 
571 int guac_protocol_send_line(guac_socket* socket, const guac_layer* layer,
572  int x, int y);
573 
590  guac_composite_mode mode, const guac_layer* layer,
591  guac_line_cap_style cap, guac_line_join_style join, int thickness,
592  const guac_layer* srcl);
593 
610  const guac_layer* layer, int x, int y, cairo_surface_t* surface);
611 
622 int guac_protocol_send_pop(guac_socket* socket, const guac_layer* layer);
623 
634 int guac_protocol_send_push(guac_socket* socket, const guac_layer* layer);
635 
650 int guac_protocol_send_rect(guac_socket* socket, const guac_layer* layer,
651  int x, int y, int width, int height);
652 
663 int guac_protocol_send_reset(guac_socket* socket, const guac_layer* layer);
664 
677 int guac_protocol_send_start(guac_socket* socket, const guac_layer* layer,
678  int x, int y);
679 
701  const guac_layer* srcl, int srcx, int srcy, int w, int h,
702  guac_transfer_function fn, const guac_layer* dstl, int dstx, int dsty);
703 
721  const guac_layer* layer,
722  double a, double b, double c,
723  double d, double e, double f);
724 
725 /* LAYER INSTRUCTIONS */
726 
737 int guac_protocol_send_dispose(guac_socket* socket, const guac_layer* layer);
738 
756  const guac_layer* layer,
757  double a, double b, double c,
758  double d, double e, double f);
759 
775 int guac_protocol_send_move(guac_socket* socket, const guac_layer* layer,
776  const guac_layer* parent, int x, int y, int z);
777 
789 int guac_protocol_send_shade(guac_socket* socket, const guac_layer* layer,
790  int a);
791 
804 int guac_protocol_send_size(guac_socket* socket, const guac_layer* layer,
805  int w, int h);
806 
807 /* TEXT INSTRUCTIONS */
808 
819 int guac_protocol_send_clipboard(guac_socket* socket, const char* data);
820 
828 int guac_protocol_send_name(guac_socket* socket, const char* name);
829 
830 #endif
831