From a7f4d708cab667e47fc189cc3da213e441bc0ba6 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Tue, 16 Mar 2021 07:07:14 -0700 Subject: [PATCH] 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. --- app/ui.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/ui.js b/app/ui.js index ee831961..714c0dec 100644 --- a/app/ui.js +++ b/app/ui.js @@ -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) ) {