Javascript Appach Guacomole JS RDP窗口缩放
我在我的网站上使用javascript Apache Guacamole客户端进行RDP控制。 我遇到了一个问题-在窗口上调整显示大小时未调整大小。 我尝试过使用鳄梨酱显示的“缩放”方法:Javascript Appach Guacomole JS RDP窗口缩放,javascript,guacamole,Javascript,Guacamole,我在我的网站上使用javascript Apache Guacamole客户端进行RDP控制。 我遇到了一个问题-在窗口上调整显示大小时未调整大小。 我尝试过使用鳄梨酱显示的“缩放”方法: guac = new Guacamole.Client(tunnel); ... guac.getDisplay().scale(myScale); 此方法更改显示大小。但是,当执行调整大小时,鼠标坐标将保持与客户端上相同的状态。所以客户端和web屏幕上的鼠标指针不匹配 修复程序也将缩放鼠标坐标: 我希望它
guac = new Guacamole.Client(tunnel);
...
guac.getDisplay().scale(myScale);
此方法更改显示大小。但是,当执行调整大小时,鼠标坐标将保持与客户端上相同的状态。所以客户端和web屏幕上的鼠标指针不匹配
修复程序也将缩放鼠标坐标:
我希望它能帮助别人。kban,当拖放浏览器的右下角时,gua显示区会留下一个空白(向下或向右),这似乎只是执行浏览器的guacamole js的缩放功能,如何解决这个问题
let scale = 1;
$(document).ready(function ($) {
$(window).resize(function () {
nsZoomZoom();
});
//Get screen resolution.
origHeigth = window.screen.height * window.devicePixelRatio;
origWidth = window.screen.width * window.devicePixelRatio;
nsZoomZoom();
function nsZoomZoom() {
//Calculating scalse
let htmlWidth = $(window).innerWidth();
var htmlHeigth = $(window).height();
var xscale = htmlWidth / origWidth;
var yscale = htmlHeigth / origHeigth;
//This is done to handle both X and Y axis slacing
scale = Math.min(xscale, yscale);
//Add 10% to scale because window always less than screen resolution
scale += scale / 10;
//Change Cuacamole Display scale
guac.getDisplay().scale(scale);
}
});
...
guac = new Guacamole.Client(tunnel);
const guacEl = guac.getDisplay().getElement();
rootEl.appendChild(guacEl);
mouse = new Guacamole.Mouse(guacEl);
mouse.onmousedown = mouse.onmouseup = (state) => guac.sendMouseState(state);
//The fix is here
mouse.onmousemove = (state) => {
updateMouseState(state);
};
//Handle mouse coordinates scaling
let updateMouseState = (mouseState) => {
mouseState.y = mouseState.y / scale;
mouseState.x = mouseState.x / scale;
guac.sendMouseState(mouseState);
}