GUACAMOLE-313: Include timestamp with mouse position reporting.

This commit is contained in:
Michael Jumper 2017-11-27 20:08:34 -08:00
parent e2455d6f26
commit a74d6a2aaf
5 changed files with 28 additions and 5 deletions

View File

@ -102,6 +102,12 @@ typedef struct guac_common_cursor {
*/ */
int y; int y;
/**
* The server timestamp representing the point in time when the mousr
* location was last updated.
*/
guac_timestamp timestamp;
} guac_common_cursor; } guac_common_cursor;
/** /**

View File

@ -28,6 +28,7 @@
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>
#include <guacamole/timestamp.h>
#include <guacamole/user.h> #include <guacamole/user.h>
#include <limits.h> #include <limits.h>
@ -67,6 +68,7 @@ guac_common_cursor* guac_common_cursor_alloc(guac_client* client) {
/* No user has moved the mouse yet */ /* No user has moved the mouse yet */
cursor->user = NULL; cursor->user = NULL;
cursor->timestamp = guac_timestamp_current();
/* Start cursor in upper-left */ /* Start cursor in upper-left */
cursor->x = 0; cursor->x = 0;
@ -101,7 +103,8 @@ void guac_common_cursor_dup(guac_common_cursor* cursor, guac_user* user,
guac_socket* socket) { guac_socket* socket) {
/* Synchronize location */ /* Synchronize location */
guac_protocol_send_mouse(socket, cursor->x, cursor->y); guac_protocol_send_mouse(socket, cursor->x, cursor->y,
cursor->timestamp);
/* Synchronize cursor image */ /* Synchronize cursor image */
if (cursor->surface != NULL) { if (cursor->surface != NULL) {
@ -138,7 +141,8 @@ static void* guac_common_cursor_broadcast_position(guac_user* user,
/* Send cursor position only if the user is not moving the cursor */ /* Send cursor position only if the user is not moving the cursor */
if (user != cursor->user) { if (user != cursor->user) {
guac_protocol_send_mouse(user->socket, cursor->x, cursor->y); guac_protocol_send_mouse(user->socket, cursor->x, cursor->y,
cursor->timestamp);
guac_socket_flush(user->socket); guac_socket_flush(user->socket);
} }
@ -156,6 +160,9 @@ void guac_common_cursor_move(guac_common_cursor* cursor, guac_user* user,
cursor->x = x; cursor->x = x;
cursor->y = y; cursor->y = y;
/* Store time at which cursor position was updated */
cursor->timestamp = guac_timestamp_current();
/* Notify all other users of change in cursor position */ /* Notify all other users of change in cursor position */
guac_client_foreach_user(cursor->client, guac_client_foreach_user(cursor->client,
guac_common_cursor_broadcast_position, cursor); guac_common_cursor_broadcast_position, cursor);

View File

@ -22,6 +22,7 @@
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>
#include <guacamole/timestamp.h>
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <direct.h> #include <direct.h>
@ -182,7 +183,8 @@ void guac_common_recording_report_mouse(guac_common_recording* recording,
int x, int y) { int x, int y) {
/* Report mouse location */ /* Report mouse location */
guac_protocol_send_mouse(recording->socket, x, y); guac_protocol_send_mouse(recording->socket, x, y,
guac_timestamp_current());
} }

View File

@ -159,10 +159,15 @@ int vguac_protocol_send_log(guac_socket* socket, const char* format,
* @param y * @param y
* The Y coordinate of the current mouse position. * The Y coordinate of the current mouse position.
* *
* @param timestamp
* The server timestamp (in milliseconds) at the point in time this mouse
* position was acknowledged.
*
* @return * @return
* Zero on success, non-zero on error. * Zero on success, non-zero on error.
*/ */
int guac_protocol_send_mouse(guac_socket* socket, int x, int y); int guac_protocol_send_mouse(guac_socket* socket, int x, int y,
guac_timestamp timestamp);
/** /**
* Sends a nest instruction over the given guac_socket connection. * Sends a nest instruction over the given guac_socket connection.

View File

@ -684,7 +684,8 @@ int guac_protocol_send_lstroke(guac_socket* socket,
} }
int guac_protocol_send_mouse(guac_socket* socket, int x, int y) { int guac_protocol_send_mouse(guac_socket* socket, int x, int y,
guac_timestamp timestamp) {
int ret_val; int ret_val;
@ -694,6 +695,8 @@ int guac_protocol_send_mouse(guac_socket* socket, int x, int y) {
|| __guac_socket_write_length_int(socket, x) || __guac_socket_write_length_int(socket, x)
|| guac_socket_write_string(socket, ",") || guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, y) || __guac_socket_write_length_int(socket, y)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, timestamp)
|| guac_socket_write_string(socket, ";"); || guac_socket_write_string(socket, ";");
guac_socket_instruction_end(socket); guac_socket_instruction_end(socket);