[pve-devel] [PATCH 2/2] add local scale resize
Alexandre Derumier
aderumier at odiso.com
Wed Jun 24 03:27:47 CEST 2015
bump to commit 205d1a11ce71744f1e95c6849f9652b65487a652
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
Makefile | 4 ++--
debian/rules | 4 ++--
pveui.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------------
3 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/Makefile b/Makefile
index 8c2e441..e64d0d5 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ dinstall: deb
deb ${DEB}: ${TARSRC}
rm -rf ${NOVNCDIR}
tar xf ${NOVNCSRC}
- mv ${NOVNCDIR}/debian ${NOVNCDIR}/debian.org
+# mv ${NOVNCDIR}/debian ${NOVNCDIR}/debian.org
cp -a debian ${NOVNCDIR}/debian
cp pveui.js ${NOVNCDIR}
# fix file permissions
@@ -36,7 +36,7 @@ download:
rm -rf ${NOVNCDIR}
git clone git://github.com/kanaka/noVNC ${NOVNCDIR}
cd ${NOVNCDIR}
- git checkout f675e03cccc5ac6a7f68e992331403ba557b0452
+ git checkout 205d1a11ce71744f1e95c6849f9652b65487a652
cd ..
tar czf ${NOVNCSRC} ${NOVNCDIR}
diff --git a/debian/rules b/debian/rules
index 4929ed9..2abf1d2 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,11 +6,11 @@
export DEB_BUILD_HARDENING=1
clean:
- make -C utils clean
+# make -C utils clean
dh clean
build:
- make -C utils rebind.so
+# make -C utils rebind.so
%:
dh ${@} --with quilt
diff --git a/pveui.js b/pveui.js
index 9bc12f5..7659061 100644
--- a/pveui.js
+++ b/pveui.js
@@ -512,7 +512,7 @@ pve_start: function(callback) {
UI.updateSetting('cursor', !UI.isTouchDevice);
UI.updateSetting('shared', true);
UI.updateSetting('view_only', false);
- UI.updateSetting('resize', true);
+ UI.updateSetting('resize', 'scale');
UI.updateSetting('path', 'api2/json' + wsurl + "?" + wsparams);
@@ -606,15 +606,29 @@ togglePVESendKeysPanel: function() {
},
onresize: function (callback) {
- if (UI.getSetting('resize')) {
- var innerW = window.innerWidth;
- var innerH = window.innerHeight;
- var controlbarH = $D('noVNC-control-bar').offsetHeight;
- // For some unknown reason the container is higher than the canvas,
- // 5px higher in Firefox and 4px higher in Chrome
- var padding = 5;
- if (innerW !== undefined && innerH !== undefined)
- UI.rfb.setDesktopSize(innerW, innerH - controlbarH - padding);
+ var innerW = window.innerWidth;
+ var innerH = window.innerHeight;
+ var controlbarH = $D('noVNC-control-bar').offsetHeight;
+ // For some unknown reason the container is higher than the canvas,
+ // 5px higher in Firefox and 4px higher in Chrome
+ var padding = 5;
+ var effectiveH = innerH - controlbarH - padding;
+
+ var display = UI.rfb.get_display();
+
+ if (innerW !== undefined && innerH !== undefined) {
+ var scaleType = UI.getSetting('resize');
+ if (scaleType === 'remote') {
+ // use remote resizing
+ Util.Debug('Attempting setDesktopSize(' + innerW + ', ' + effectiveH + ')');
+ UI.rfb.setDesktopSize(innerW, effectiveH);
+ } else if (scaleType === 'scale' || scaleType === 'downscale') {
+ // use local scaling
+ var downscaleOnly = scaleType === 'downscale';
+ var scaleRatio = display.autoscale(innerW, effectiveH, downscaleOnly);
+ UI.rfb.get_mouse().set_scale(scaleRatio);
+ Util.Debug('Scaling by ' + UI.rfb.get_mouse().get_scale());
+ }
}
},
// Render default UI and initialize settings menu
@@ -783,6 +797,11 @@ addMouseHandlers: function() {
//$D("noVNC_apply").onclick = UI.settingsApply;
//$D("noVNC_connect_button").onclick = UI.connect;
+
+ $D("noVNC_resize").onchange = function () {
+ var connected = UI.rfb_state === 'normal' ? true : false;
+ UI.enableDisableClip(connected);
+ };
},
// Read form control compatible setting from cookie
@@ -1018,8 +1037,11 @@ toggleSettingsPanel: function() {
UI.updateSetting('cursor', !UI.isTouchDevice);
$D('noVNC_cursor').disabled = true;
}
- UI.updateSetting('clip');
UI.updateSetting('resize');
+ if (UI.getSetting('resize') === 'downscale' || UI.getSetting('resize') === 'scale') {
+ UI.forceSetting('clip', false);
+ }
+ UI.updateSetting('clip');
UI.updateSetting('shared');
UI.updateSetting('view_only');
UI.updateSetting('path');
@@ -1204,7 +1226,9 @@ updateVisualState: function() {
UI.updateSetting('cursor', !UI.isTouchDevice);
$D('noVNC_cursor').disabled = true;
}
- $D('noVNC_clip').disabled = connected || UI.isTouchDevice;
+
+ UI.enableDisableClip(connected);
+
$D('noVNC_resize').disabled = connected;
$D('noVNC_shared').disabled = connected;
$D('noVNC_view_only').disabled = connected;
@@ -1259,6 +1283,18 @@ updateXvpVisualState: function(ver) {
}
}
},
+enableDisableClip: function (connected) {
+ var resizeElem = $D('noVNC_resize');
+ if (resizeElem.value === 'downscale' || resizeElem.value === 'scale') {
+ UI.forceSetting('clip', false);
+ $D('noVNC_clip').disabled = true;
+ } else {
+ $D('noVNC_clip').disabled = connected || UI.isTouchDevice;
+ if (UI.isTouchDevice) {
+ UI.forceSetting('clip', true);
+ }
+ }
+},
// This resize can not be done until we know from the first Frame Buffer Update
// if it is supported or not.
--
2.1.4
More information about the pve-devel
mailing list