You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by "corentin-soriano (via GitHub)" <gi...@apache.org> on 2025/11/27 18:12:27 UTC

[PR] GUACAMOLE-2175: Wait clipboard synchronization before pasting. [guacamole-client]

corentin-soriano opened a new pull request, #1132:
URL: https://github.com/apache/guacamole-client/pull/1132

   (no comment)


-- 
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: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GUACAMOLE-2175: Wait clipboard synchronization before pasting. [guacamole-client]

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
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: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GUACAMOLE-2175: Wait clipboard synchronization before pasting. [guacamole-client]

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman merged PR #1132:
URL: https://github.com/apache/guacamole-client/pull/1132


-- 
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: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GUACAMOLE-2175: Wait clipboard synchronization before pasting. [guacamole-client]

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on code in PR #1132:
URL: https://github.com/apache/guacamole-client/pull/1132#discussion_r2581313731


##########
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:
   Okay - might be worth adding a comment to the code to document that for future reference...



-- 
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: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GUACAMOLE-2175: Wait clipboard synchronization before pasting. [guacamole-client]

Posted by "corentin-soriano (via GitHub)" <gi...@apache.org>.
corentin-soriano commented on code in PR #1132:
URL: https://github.com/apache/guacamole-client/pull/1132#discussion_r2584576234


##########
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:
   Comment added!



-- 
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: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org