diff --git a/guacamole-common-js/src/main/webapp/modules/Client.js b/guacamole-common-js/src/main/webapp/modules/Client.js index 18d8412a6..3c1c239df 100644 --- a/guacamole-common-js/src/main/webapp/modules/Client.js +++ b/guacamole-common-js/src/main/webapp/modules/Client.js @@ -323,19 +323,33 @@ Guacamole.Client = function(tunnel) { * Sends a mouse event having the properties provided by the given mouse * state. * - * @param {Guacamole.Mouse.State} mouseState The state of the mouse to send - * in the mouse event. + * @param {Guacamole.Mouse.State} mouseState + * The state of the mouse to send in the mouse event. + * + * @param {Boolean} [applyDisplayScale=false] + * Whether the provided mouse state uses local display units, rather + * than remote display units, and should be scaled to match the + * {@link Guacamole.Display}. */ - this.sendMouseState = function(mouseState) { + this.sendMouseState = function sendMouseState(mouseState, applyDisplayScale) { // Do not send requests if not connected if (!isConnected()) return; + var x = mouseState.x; + var y = mouseState.y; + + // Translate for display units if requested + if (applyDisplayScale) { + x /= display.getScale(); + y /= display.getScale(); + } + // Update client-side cursor display.moveCursor( - Math.floor(mouseState.x), - Math.floor(mouseState.y) + Math.floor(x), + Math.floor(y) ); // Build mask @@ -347,7 +361,7 @@ Guacamole.Client = function(tunnel) { if (mouseState.down) buttonMask |= 16; // Send message - tunnel.sendMessage("mouse", Math.floor(mouseState.x), Math.floor(mouseState.y), buttonMask); + tunnel.sendMessage("mouse", Math.floor(x), Math.floor(y), buttonMask); }; /** diff --git a/guacamole/src/main/webapp/app/client/directives/guacClient.js b/guacamole/src/main/webapp/app/client/directives/guacClient.js index cc8829657..6d608cba6 100644 --- a/guacamole/src/main/webapp/app/client/directives/guacClient.js +++ b/guacamole/src/main/webapp/app/client/directives/guacClient.js @@ -185,29 +185,6 @@ angular.module('client').directive('guacClient', [function guacClient() { }; - /** - * Sends the given mouse state to the current client. - * - * @param {Guacamole.Mouse.State} mouseState The mouse state to - * send. - */ - var sendScaledMouseState = function sendScaledMouseState(mouseState) { - - // Scale event by current scale - var scaledState = new Guacamole.Mouse.State( - mouseState.x / display.getScale(), - mouseState.y / display.getScale(), - mouseState.left, - mouseState.middle, - mouseState.right, - mouseState.up, - mouseState.down); - - // Send mouse event - client.sendMouseState(scaledState); - - }; - /** * Handles a mouse event originating from the user's actual mouse. * This differs from handleEmulatedMouseState() in that the @@ -226,7 +203,7 @@ angular.module('client').directive('guacClient', [function guacClient() { // Send mouse state, show cursor if necessary display.showCursor(!localCursor); - sendScaledMouseState(mouseState); + client.sendMouseState(mouseState, true); }; @@ -251,7 +228,7 @@ angular.module('client').directive('guacClient', [function guacClient() { // Send mouse state, ensure cursor is visible scrollToMouse(mouseState); - sendScaledMouseState(mouseState); + client.sendMouseState(mouseState, true); };