0

I want to resize the screen which I am controlling to the available screen of the browser without showing any scrollbars . I have done this by resizing the html elements but by doing this the position and movement of the curser also changes on the remote end . I am using the sample App of guacamole

   var display = document.getElementById("display");
    // Instantiate client, using an HTTP tunnel for communications.
    var guac = new Guacamole.Client(
        new Guacamole.HTTPTunnel("tunnel")
    );
    // Add client to display div
    var dis =  guac.getDisplay().getElement();
    dis.getElementsByTagName("canvas")[0].style = "width:1100px;"
    dis.setAttribute("style", "width:1100px");
    display.appendChild(guac.getDisplay().getElement());

    // Error handler
    guac.onerror = function(error) {
        alert(error);
    };
    // Connect
    guac.connect();
TimeToCode
  • 901
  • 2
  • 16
  • 34
Zahid Nisar
  • 802
  • 4
  • 15
  • 26

3 Answers3

2

I had a task to make RDP screen resizing on browser window change. Initially, the connection was launched with the specified screen sizes using connect method. I made a screen change by sending a message through the tunnel with the desired dimensions.

GuacTunnel = new Guacamole.WebSocketTunnel(wsBaseUrl)
InstGuac = new Guacamole.Client(GuacTunnel);

const display = document.getElementById("display");

//---- Get Wrapper Size for Display Content 
let GUAC_WIDTH = Math.round($(display).width())
let GUAC_HEIGHT = Math.round($(display).height())

InstGuac.connect(`....&GUAC_WIDTH=${GUAC_WIDTH}&GUAC_HEIGHT=${GUAC_HEIGHT}&GUAC_DPI=96`);

window.onresize = function () {
    let GUAC_WIDTH  = Math.round($(display).width())
    let GUAC_HEIGHT = Math.round($(display).height())
    //---- Resize RDP window by sendMessage to the Server Guacamole
    GuacTunnel.sendMessage('size', GUAC_WIDTH, GUAC_HEIGHT)
 }
1

I was able to solve this problem by using css zoom and transform origin and dividing scale factor with mouse position movements and touch which is sent to the server fro, canvas .

Zahid Nisar
  • 802
  • 4
  • 15
  • 26
0

For people encountering a similar problem, I was able to solve the issue by setting config on the backend Java API through this method:

new GuacamoleConfiguration().setParameter("width", 500);

(You can specify also height parameter)

For getting client side browser dimensions, you can use the function in the JavaScript API to specify extra headers that give you the required values.

var guac1 = new Guacamole.Client(
    new Guacamole.HTTPTunnel("tunnel",false,{"X-Display-Height":Math.round(win_height),"X-Display-Width":Math.round(half_width)})
);

After that, you can just extract the dimensions specified in headers.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
complexia
  • 11
  • 1