necouchman commented on code in PR #1132:
URL: https://github.com/apache/guacamole-client/pull/1132#discussion_r2571819006


##########
guacamole/src/main/frontend/src/app/client/directives/guacClient.js:
##########
@@ -239,15 +246,45 @@ angular.module('client').directive('guacClient', 
[function guacClient() {
             event.stopPropagation();
             event.preventDefault();
 
-            // Send mouse state, show cursor if necessary
-            display.showCursor(!localCursor);
-            client.sendMouseState(event.state, true);
+            // Wait for any in-progress clipboard synchronization to complete.
+            // This avoids the pasting of outdated clipboard content when 
guacamole
+            // window regains focus.
+            waitForClipboardSync().then(() => {
 
-            // Broadcast the mouse event
-            $rootScope.$broadcast(getMouseEventName(event), event, client);
+                // Send mouse state, show cursor if necessary
+                display.showCursor(!localCursor);
+                client.sendMouseState(event.state, true);
+
+                // Broadcast the mouse event
+                $rootScope.$broadcast(getMouseEventName(event), event, client);
+
+            });
 
         };
 
+        /**
+         * Returns a promise which resolves once any in-progress clipboard
+         * synchronization has completed.
+         *
+         * @returns {Promise}
+         *     A promise which resolves once any in-progress clipboard
+         *     synchronization has completed.
+         */
+        function waitForClipboardSync() {
+            return new Promise((resolve) => {
+                function checkClipboardSync() {
+                    if (!clipboardSyncInProgress) {
+                        resolve();
+                        return;
+                    }
+
+                    setTimeout(checkClipboardSync, 10);

Review Comment:
   Any particular rationale behind the `10` ms timeout, here? I'm not opposed 
to it, just wondered if there was some reason for selecting that particular 
amount of time?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to