Adding changes from pull request 118 (#138)

This commit is contained in:
rspruel 2025-06-13 05:54:15 -04:00 committed by GitHub
parent bed156c565
commit 31cf849134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -32,7 +32,7 @@ import "core-js/stable";
import "regenerator-runtime/runtime";
import * as Log from '../core/util/logging.js';
import _, { l10n } from './localization.js';
import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold, supportsBinaryClipboard, isFirefox, isWindows, isIOS, supportsPointerLock }
import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold, supportsBinaryClipboard, isFirefox, isWindows, isIOS, supportsPointerLock, supportsKeyboardLock }
from '../core/util/browser.js';
import { setCapture, getPointerEvent } from '../core/util/events.js';
import KeyTable from "../core/input/keysym.js";
@ -1551,7 +1551,7 @@ const UI = {
//keep alive for websocket connection to stay open, since we may not control reverse proxies
//send a keep alive within a window that we control
UI._sessionTimeoutInterval = setInterval(function() {
if (UI.rfb) {
if (UI.rfb) {
const timeSinceLastActivityInS = (Date.now() - UI.rfb.lastActiveAt) / 1000;
let idleDisconnectInS = 1200; //20 minute default
if (Number.isFinite(parseFloat(UI.rfb.idleDisconnect))) {
@ -1869,6 +1869,9 @@ const UI = {
document.mozFullScreenElement || // currently working methods
document.webkitFullscreenElement ||
document.msFullscreenElement) {
if (supportsKeyboardLock) {
navigator.keyboard.unlock();
}
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
@ -1888,8 +1891,11 @@ const UI = {
} else if (document.body.msRequestFullscreen) {
document.body.msRequestFullscreen();
}
if(navigator.keyboard && navigator.keyboard.lock){
navigator.keyboard.lock(['Escape']);
// No need to explicitly ask for permission,
// but it's expected that user grant it since Chromium 131.
// See https://developer.chrome.com/blog/keyboard-lock-pointer-lock-permission
if (supportsKeyboardLock) {
navigator.keyboard.lock();
}
}
UI.updateFullscreenButton();

View File

@ -27,6 +27,8 @@ window.addEventListener('touchstart', function onFirstTouch() {
// brings us a bit closer but is not optimal.
export let dragThreshold = 10 * (window.devicePixelRatio || 1);
export const supportsKeyboardLock = ('keyboard' in navigator && 'lock' in navigator.keyboard && typeof(navigator.keyboard.lock) === 'function');
let _supportsCursorURIs = false;
try {