Hide the pointer capture button unless in fullscreen

This change is a compromise to de-clutter the navbar by only showing the
pointer capture button when fullscreen is enabled. There is no strong
requirement (from the browser side) to be in fullscreen to acquire a
pointer lock.
This commit is contained in:
lhchavez 2021-03-16 07:07:14 -07:00
parent 30fda3c948
commit a7f4d708ca
1 changed files with 6 additions and 0 deletions

View File

@ -1251,6 +1251,7 @@ const UI = {
document.getElementById('noVNC_fullscreen_button')
.classList.remove("noVNC_selected");
}
UI.updatePointerLockButton();
},
/* ------^-------
@ -1308,8 +1309,13 @@ const UI = {
updatePointerLockButton() {
// Only show the button if the pointer lock API is properly supported
// AND in fullscreen.
if (
UI.connected &&
(document.fullscreenElement || // alternative standard method
document.mozFullScreenElement || // currently working methods
document.webkitFullscreenElement ||
document.msFullscreenElement) &&
(document.pointerLockElement !== undefined ||
document.mozPointerLockElement !== undefined)
) {