mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-1480: Only check clipboard when window regains focus. Do not attempt to read clipboard unless textarea actually has focus (paste may occur elsewhere otherwise).
This commit is contained in:
@@ -110,10 +110,11 @@ angular.module('client').factory('clipboardService', ['$injector',
|
|||||||
|
|
||||||
// Clear and select the clipboard DOM element
|
// Clear and select the clipboard DOM element
|
||||||
clipboardContent.value = '';
|
clipboardContent.value = '';
|
||||||
|
clipboardContent.focus();
|
||||||
clipboardContent.select();
|
clipboardContent.select();
|
||||||
|
|
||||||
// Attempt paste local clipboard into clipboard DOM element
|
// Attempt paste local clipboard into clipboard DOM element
|
||||||
if (document.execCommand('paste'))
|
if (document.activeElement === clipboardContent && document.execCommand('paste'))
|
||||||
deferred.resolve(clipboardContent.value);
|
deferred.resolve(clipboardContent.value);
|
||||||
else
|
else
|
||||||
deferred.reject();
|
deferred.reject();
|
||||||
@@ -142,7 +143,13 @@ angular.module('client').factory('clipboardService', ['$injector',
|
|||||||
// Attempt to read the clipboard if it may have changed
|
// Attempt to read the clipboard if it may have changed
|
||||||
window.addEventListener('copy', checkClipboard, true);
|
window.addEventListener('copy', checkClipboard, true);
|
||||||
window.addEventListener('cut', checkClipboard, true);
|
window.addEventListener('cut', checkClipboard, true);
|
||||||
window.addEventListener('focus', checkClipboard, true);
|
window.addEventListener('focus', function focusGained(e) {
|
||||||
|
|
||||||
|
// Only recheck clipboard if it's the window itself that gained focus
|
||||||
|
if (e.target === window)
|
||||||
|
checkClipboard();
|
||||||
|
|
||||||
|
}, true);
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user