From 4f64efaabdae18f3ce581408a42800b1a30a075c Mon Sep 17 00:00:00 2001 From: Pawel Raczyk Date: Tue, 14 May 2019 11:00:05 +0200 Subject: [PATCH] enable fullscreen when vnc is in iframe --- app/styles/base.css | 10 ++++---- app/ui.js | 59 +++++++++++++-------------------------------- vnc.html | 22 ++++++++--------- 3 files changed, 32 insertions(+), 59 deletions(-) diff --git a/app/styles/base.css b/app/styles/base.css index 57f1a4d2..232d2242 100644 --- a/app/styles/base.css +++ b/app/styles/base.css @@ -580,7 +580,11 @@ select:active { } /* Extra manual keys */ -:root:not(.noVNC_connected) #noVNC_extra_keys, :root:not(.noVNC_connected) #noVNC_special_keys { +:root:not(.noVNC_connected) #noVNC_extra_keys, +:root:not(.noVNC_connected) #noVNC_special_keys, +:root:not(.noVNC_connected) #noVNC_clipboard_button, +:root:not(.noVNC_connected) #noVNC_send_ctrl_alt_del_button, +:root:not(.noVNC_connected) #noVNC_clipboard_button { display: none; } @@ -604,10 +608,6 @@ select:active { width: 100%; } -/* Clipboard */ -:root:not(.noVNC_connected) #noVNC_clipboard_button { - display: none; -} #noVNC_clipboard { /* Full screen, minus padding and left and right margins */ max-width: calc(100vw - 2*15px - 75px - 25px); diff --git a/app/ui.js b/app/ui.js index f6631173..d3426be8 100644 --- a/app/ui.js +++ b/app/ui.js @@ -385,11 +385,6 @@ const UI = { addFullscreenHandlers() { document.getElementById("noVNC_fullscreen_button") .addEventListener('click', UI.toggleFullscreen); - - window.addEventListener('fullscreenchange', UI.updateFullscreenButton); - window.addEventListener('mozfullscreenchange', UI.updateFullscreenButton); - window.addEventListener('webkitfullscreenchange', UI.updateFullscreenButton); - window.addEventListener('msfullscreenchange', UI.updateFullscreenButton); }, /* ------^------- @@ -1236,46 +1231,27 @@ const UI = { * ============== * FULLSCREEN * ------v------*/ - - toggleFullscreen() { - if (document.fullscreenElement || // alternative standard method - document.mozFullScreenElement || // currently working methods - document.webkitFullscreenElement || - document.msFullscreenElement) { - if (document.exitFullscreen) { - document.exitFullscreen(); - } else if (document.mozCancelFullScreen) { - document.mozCancelFullScreen(); - } else if (document.webkitExitFullscreen) { - document.webkitExitFullscreen(); - } else if (document.msExitFullscreen) { - document.msExitFullscreen(); - } + checkFullScreen() { + const fullscreenButton = document.getElementById('noVNC_fullscreen_button'); + if (fullscreenButton.classList.contains('noVNC_selected')) { + fullscreenButton + .classList.remove("noVNC_selected"); + UI.rfb.scaleViewport = false; + return false; } else { - if (document.documentElement.requestFullscreen) { - document.documentElement.requestFullscreen(); - } else if (document.documentElement.mozRequestFullScreen) { - document.documentElement.mozRequestFullScreen(); - } else if (document.documentElement.webkitRequestFullscreen) { - document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); - } else if (document.body.msRequestFullscreen) { - document.body.msRequestFullscreen(); - } + fullscreenButton + .classList.add("noVNC_selected"); + UI.rfb.scaleViewport = true; + return true; } - UI.updateFullscreenButton(); }, - updateFullscreenButton() { - if (document.fullscreenElement || // alternative standard method - document.mozFullScreenElement || // currently working methods - document.webkitFullscreenElement || - document.msFullscreenElement ) { - document.getElementById('noVNC_fullscreen_button') - .classList.add("noVNC_selected"); - } else { - document.getElementById('noVNC_fullscreen_button') - .classList.remove("noVNC_selected"); - } + toggleFullscreen() { + const sendMessage = (message) => { + window.parent.postMessage(message, '*'); + }; + const isFullscreen = UI.checkFullScreen(); + sendMessage(isFullscreen); }, /* ------^------- @@ -1287,7 +1263,6 @@ const UI = { // Apply remote resizing or local scaling applyResizeMode() { if (!UI.rfb) return; - UI.rfb.scaleViewport = UI.getSetting('resize') === 'scale'; UI.rfb.resizeSession = UI.getSetting('resize') === 'remote'; }, diff --git a/vnc.html b/vnc.html index 36c386be..e355c3ac 100644 --- a/vnc.html +++ b/vnc.html @@ -46,10 +46,8 @@ - - @@ -138,9 +136,6 @@ - @@ -191,11 +186,14 @@ - + +
@@ -228,7 +226,7 @@
- @@ -242,10 +240,10 @@
  • Settings
  • -
  • +
  • -
  • +
  • @@ -262,7 +260,7 @@

  • -
  • +
  • Advanced
      @@ -307,7 +305,7 @@
    • -
    • @@ -328,7 +326,7 @@
    -