Skip to content

Commit c60bc6e

Browse files
committed
implemented
1 parent 2bb561f commit c60bc6e

File tree

5 files changed

+84
-2
lines changed

5 files changed

+84
-2
lines changed

guacamole/src/main/frontend/src/app/client/controllers/clientController.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
4444
const requestService = $injector.get('requestService');
4545
const tunnelService = $injector.get('tunnelService');
4646
const userPageService = $injector.get('userPageService');
47-
47+
const fullscreenService = $injector.get('guacFullscreen');
4848
/**
4949
* The minimum number of pixels a drag gesture must move to result in the
5050
* menu being shown or hidden.
@@ -683,8 +683,22 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
683683
callback : $scope.disconnect
684684
};
685685

686+
/**
687+
* Action that locks the keyboard using the Keyboard Lock API within the
688+
* current client, and then closes the menu.
689+
*/
690+
var FULLSCREEN_MENU_ACTION = {
691+
name : 'CLIENT.ACTION_FULLSCREEN',
692+
classname : 'fullscreen action',
693+
callback : function fullscreen() {
694+
695+
fullscreenService.toggleFullscreenMode();
696+
$scope.menu.shown = false;
697+
}
698+
};
699+
686700
// Set client-specific menu actions
687-
$scope.clientMenuActions = [ DISCONNECT_MENU_ACTION ];
701+
$scope.clientMenuActions = [ DISCONNECT_MENU_ACTION,FULLSCREEN_MENU_ACTION ];
688702

689703
/**
690704
* @borrows Protocol.getNamespace
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* A service for providing true fullscreen and keyboard lock support.
22+
* Keyboard lock is currently only supported by Chromium based browsers
23+
* (Edge >= V79, Chrome >= V68 and Opera >= V55)
24+
*/
25+
angular.module('client').factory('guacFullscreen', ['$injector',
26+
27+
28+
function guacFullscreen($injector) {
29+
30+
var service = {};
31+
32+
// toggles current fullscreen mode (off if on, on if off)
33+
service.toggleFullscreenMode = function toggleFullscreenMode(){
34+
if(!service.isInFullscreenMode()){
35+
service.setFullscreenMode(true);
36+
}else{
37+
service.setFullscreenMode(false);
38+
}
39+
}
40+
41+
// check is browser in true fullscreen mode
42+
service.isInFullscreenMode=function isInFullscreenMode(){
43+
return document.fullscreenElement;
44+
}
45+
46+
// set fullscreen mode
47+
service.setFullscreenMode = function setFullscreenMode(state) {
48+
if(document.fullscreenEnabled){
49+
50+
if(state && !service.isInFullscreenMode()) document.documentElement.requestFullscreen().then(navigator.keyboard.lock());
51+
else if(!state && service.isInFullscreenMode()) document.exitFullscreen().then(navigator.keyboard.unlock());
52+
53+
}
54+
}
55+
56+
return service;
57+
}
58+
])

guacamole/src/main/frontend/src/app/client/types/ManagedClient.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
5151
const guacHistory = $injector.get('guacHistory');
5252
const guacImage = $injector.get('guacImage');
5353
const guacVideo = $injector.get('guacVideo');
54+
const fullscreen = $injector.get('guacFullscreen');
5455

5556
/**
5657
* The minimum amount of time to wait between updates to the client
@@ -411,6 +412,13 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
411412

412413
// Connection has closed
413414
case Guacamole.Tunnel.State.CLOSED:
415+
416+
// force restore non fullscreen mode after any disconnect
417+
// otherwise user may be confused what to do
418+
if(fullscreen.isInFullscreenMode){
419+
fullscreen.setFullscreenMode(false);
420+
}
421+
414422
ManagedClientState.setConnectionState(managedClient.clientState,
415423
ManagedClientState.ConnectionState.DISCONNECTED);
416424
break;

guacamole/src/main/frontend/src/translations/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"ACTION_ACKNOWLEDGE" : "@:APP.ACTION_ACKNOWLEDGE",
5353
"ACTION_CLEAR_COMPLETED_TRANSFERS" : "Entferne abgeschlossene Übertragungen",
5454
"ACTION_DISCONNECT" : "Trennen",
55+
"ACTION_FULLSCREEN" : "Vollbild",
5556
"ACTION_LOGOUT" : "@:APP.ACTION_LOGOUT",
5657
"ACTION_NAVIGATE_BACK" : "@:APP.ACTION_NAVIGATE_BACK",
5758
"ACTION_NAVIGATE_HOME" : "@:APP.ACTION_NAVIGATE_HOME",

guacamole/src/main/frontend/src/translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"ACTION_ACKNOWLEDGE" : "@:APP.ACTION_ACKNOWLEDGE",
6262
"ACTION_CANCEL" : "@:APP.ACTION_CANCEL",
6363
"ACTION_CLEAR_COMPLETED_TRANSFERS" : "Clear",
64+
"ACTION_FULLSCREEN" : "Fullscreen",
6465
"ACTION_CONTINUE" : "@:APP.ACTION_CONTINUE",
6566
"ACTION_DISCONNECT" : "Disconnect",
6667
"ACTION_LOGOUT" : "@:APP.ACTION_LOGOUT",

0 commit comments

Comments
 (0)