diff --git a/guacamole/src/main/frontend/src/app/client/directives/guacClientNotification.js b/guacamole/src/main/frontend/src/app/client/directives/guacClientNotification.js index 60c7595db..cae932ba3 100644 --- a/guacamole/src/main/frontend/src/app/client/directives/guacClientNotification.js +++ b/guacamole/src/main/frontend/src/app/client/directives/guacClientNotification.js @@ -407,6 +407,23 @@ angular.module('client').directive('guacClientNotification', [function guacClien }); + /** + * Prevents the default behavior of the given AngularJS event if a + * notification is currently shown and the client is focused. + * + * @param {event} e + * The AngularJS event to selectively prevent. + */ + var preventDefaultDuringNotification = function preventDefaultDuringNotification(e) { + if ($scope.status && $scope.client.clientProperties.focused) + e.preventDefault(); + }; + + // Block internal handling of key events (by the client) if a + // notification is visible + $scope.$on('guacBeforeKeydown', preventDefaultDuringNotification); + $scope.$on('guacBeforeKeyup', preventDefaultDuringNotification); + }]; return directive; diff --git a/guacamole/src/main/frontend/src/app/index/controllers/indexController.js b/guacamole/src/main/frontend/src/app/index/controllers/indexController.js index 1ed49b7a8..5f7e70211 100644 --- a/guacamole/src/main/frontend/src/app/index/controllers/indexController.js +++ b/guacamole/src/main/frontend/src/app/index/controllers/indexController.js @@ -163,9 +163,8 @@ angular.module('index').controller('indexController', ['$scope', '$injector', // Broadcast keydown events keyboard.onkeydown = function onkeydown(keysym) { - // Do not handle key events if not logged in or if a notification is - // shown - if ($scope.applicationState !== ApplicationState.READY || guacNotification.getStatus()) + // Do not handle key events if not logged in + if ($scope.applicationState !== ApplicationState.READY) return true; // Warn of pending keydown @@ -184,7 +183,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector', // Do not handle key events if not logged in or if a notification is // shown - if ($scope.applicationState !== ApplicationState.READY || guacNotification.getStatus()) + if ($scope.applicationState !== ApplicationState.READY) return; // Warn of pending keyup