Repository: incubator-guacamole-server Updated Branches: refs/heads/staging/0.9.12-incubating cf05eca68 -> 145762a2b
GUACAMOLE-231: Broadcast mouse position only to users who are not moving the mouse. Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/240e18cd Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/240e18cd Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/240e18cd Branch: refs/heads/staging/0.9.12-incubating Commit: 240e18cd921c7a38a5d216dc8a323941c3dd981c Parents: ae7e8d3 Author: Michael Jumper <[email protected]> Authored: Sat Mar 11 14:35:43 2017 -0800 Committer: Michael Jumper <[email protected]> Committed: Sat Mar 11 14:57:09 2017 -0800 ---------------------------------------------------------------------- src/common/cursor.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/240e18cd/src/common/cursor.c ---------------------------------------------------------------------- diff --git a/src/common/cursor.c b/src/common/cursor.c index 0384ea3..f956f6a 100644 --- a/src/common/cursor.c +++ b/src/common/cursor.c @@ -110,6 +110,32 @@ void guac_common_cursor_dup(guac_common_cursor* cursor, guac_user* user, } +/** + * Callback for guac_client_foreach_user() which sends the current cursor + * position to any given user except the user that moved the cursor last. + * + * @param data + * A pointer to the guac_common_cursor whose position should be broadcast + * to all users except the user that moved the cursor last. + * + * @return + * Always NULL. + */ +static void* guac_common_cursor_broadcast_position(guac_user* user, + void* data) { + + guac_common_cursor* cursor = (guac_common_cursor*) data; + + /* Send cursor position only if the user is not moving the cursor */ + if (user != cursor->user) { + guac_protocol_send_mouse(user->socket, cursor->x, cursor->y); + guac_socket_flush(user->socket); + } + + return NULL; + +} + void guac_common_cursor_move(guac_common_cursor* cursor, guac_user* user, int x, int y) { @@ -120,9 +146,9 @@ void guac_common_cursor_move(guac_common_cursor* cursor, guac_user* user, cursor->x = x; cursor->y = y; - /* Notify of change in cursor position */ - guac_protocol_send_mouse(cursor->client->socket, x, y); - guac_socket_flush(cursor->client->socket); + /* Notify all other users of change in cursor position */ + guac_client_foreach_user(cursor->client, + guac_common_cursor_broadcast_position, cursor); }
