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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]