GUACAMOLE-313: Add function for sending "key" instructions.

This commit is contained in:
Michael Jumper 2017-11-27 23:30:13 -08:00
parent 81a0e66d9f
commit b21aef565b
2 changed files with 44 additions and 0 deletions

View File

@ -106,6 +106,32 @@ int guac_protocol_send_disconnect(guac_socket* socket);
int guac_protocol_send_error(guac_socket* socket, const char* error,
guac_protocol_status status);
/**
* Sends a key instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket
* The guac_socket connection to use.
*
* @param keysym
* The X11 keysym of the key that was pressed or released.
*
* @param pressed
* Non-zero if the key represented by the given keysym is currently
* pressed, zero if it is released.
*
* @param timestamp
* The server timestamp (in milliseconds) at the point in time this key
* event was acknowledged.
*
* @return
* Zero on success, non-zero on error.
*/
int guac_protocol_send_key(guac_socket* socket, int keysym, int pressed,
guac_timestamp timestamp);
/**
* Sends a log instruction over the given guac_socket connection. This is
* mainly useful in debugging.

View File

@ -615,6 +615,24 @@ int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer) {
}
int guac_protocol_send_key(guac_socket* socket, int keysym, int pressed,
guac_timestamp timestamp) {
int ret_val;
guac_socket_instruction_begin(socket);
ret_val =
guac_socket_write_string(socket, "3.key,")
|| __guac_socket_write_length_int(socket, keysym)
|| guac_socket_write_string(socket, pressed ? ",1.1," : ",1.0,")
|| __guac_socket_write_length_int(socket, timestamp)
|| guac_socket_write_string(socket, ";");
guac_socket_instruction_end(socket);
return ret_val;
}
int guac_protocol_send_lfill(guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer,
const guac_layer* srcl) {