Closed Dshufeng closed 6 years ago
Do you see the picture of the same size you requested in your parameters? I mean when you request &width=1080&height=1920 do you see the picture 1080x1920 or of a different size?
The picture is Default size when I change any params . And I use VNC protocol, is that the reason ?
Looks like it's a limitation of VNC protocol. Here's one of the answers I found in another group:
Unfortunately, the VNC protocol itself does not define any mechanism for the connecting client to indicate the desired screen size. The size of the display is dictated entirely by the VNC server, and while Guacamole always receives the size of your browser window when you connect (and updated sizes if you resize the window), there is no way for it to communicate that size to the VNC server. The best you can achieve is to manually adjust the display by using the "xrandr" command within the VNC session after you connect.
Oh.Thank you. It looks like I need to find other ways to solve it.
You can correct this by using scale on client interface
Three years pass and vnc still not support it.... anyone knows how to solve this problem?
merry christmas
var client = client = new Guacamole.Client(new Guacamole.WebSocketTunnel("/guacamole/tunnel"));
$wrapper =client.getDisplay().getElement()
function initialize(){
var scale = 1
var pixel_density = window.devicePixelRatio || 1;
var optimal_dpi = pixel_density * 96;
var optimal_width = document.body.clientWidth //* pixel_density;
var optimal_height = document.body.clientHeight// * pixel_density;
if(!optimal_width){
//case when size == 0 (wrapper not visible)
return setTimeout(function(){
initialize(comm)
},1000)
}
$wrapper.style.position = 'absolute'
$wrapper.style.left = '50%'
$wrapper.style.top = '50%'
$wrapper.style.transform = 'translate(-50%,-50%)';
client.connect(encodeURI('token={{token}}&width='+optimal_width+'&height='+optimal_height+'&dpi='+optimal_dpi))
client.onstatechange = function(state){
var STATE_IDLE = 0;
var STATE_CONNECTING = 1;
var STATE_WAITING = 2;
var STATE_CONNECTED = 3;
var STATE_DISCONNECTING = 4;
var STATE_DISCONNECTED = 5;
if(state == 3){
scale = Math.min(optimal_height / $wrapper.clientHeight, optimal_width / $wrapper.clientWidth)
$wrapper.style.transform = 'translate(-50%,-50%) scale('+scale+')'
}
}
var touch = new Guacamole.Mouse.Touchscreen(client.getDisplay().getElement()); // or Guacamole.Touchscreen
var mouse = new Guacamole.Mouse(client.getDisplay().getElement());
mouse.onmousedown = mouse.onmouseup = touch.onmousedown = touch.onmouseup = function(mouseState){
console.log('mouseState',mouseState)
client.sendMouseState(mouseState);
}
touch.onmousemove = mouse.onmousemove = function(mouseState) {
height = $wrapper.clientHeight
width = $wrapper.clientWidth
scale = scale == Infinity ? 1 : scale
mouseState.x /= scale
mouseState.y /= scale
mouseState.x += width / 2
mouseState.y += height / 2
client.sendMouseState(mouseState);
};
// Keyboard
var keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = function (keysym) {
client.sendKeyEvent(1, keysym);
};
keyboard.onkeyup = function (keysym) {
client.sendKeyEvent(0, keysym);
};
}
@ptorrent thank u :)
Hi: When I try to resize the picture, but it not works. My params is ws://192.168.1.115:8081/?token=token&width=1080&height=1920&dpi=32. I can see the picture but can't resize it. thank you.