You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by "McRoy, Jeffrey (GE Healthcare)" <Je...@ge.com> on 2018/02/16 17:33:11 UTC

Re: guacamole-common-js resize method guidance

Hi wthomas,

I'm also trying to add resizing to the guacamole-example. Here's what I tried and the issues I have. Were you able to get yours working?

I added a javascript function to handle updating the guac display scale:
function rescale(browserDisp, guacDisp) {
	var scale = Math.min(browserDisp.offsetWidth / Math.max(guacDisp.getWidth(), 1),
                            browserDisp.offsetHeight / Math.max(guacDisp.getHeight(), 1));
               guacDisp.scale(scale);
}

I then added a listener for the browser resize:
.
.
var display = document.getElementById("display");
var guac = new Guacamole.Client(new Guacamole.HTTPTunnel("tunnel"));
var guacDisplay = guac.getDisplay();
rescale(display, guacDisplay);
display.appendChild(guacDisplay.getElement());
.
.
window.onresize = function(event) {
	rescale(display, guacDisplay);
};
.
.

I’ve hit a couple of issues:
- Calculating the initial scale, Guacamole.Display.getHeight() and Guacamole.Display.getWidth() return 0 until the browser window is resized. This causes the first attempt at caluclating scale to be 0.
- In VNC the local mouse location seems to be off from the remote mouse locatipn, maybe need scaling applied here also?
 
Thanks & Regards,
Jeff

 
On 4/5/17, 4:57 PM, "wthomas" <we...@edgecaselabs.com> wrote:

    Anyone have any guidance on how to resize the guac viewer display so it
    doesn't fill beyond my entire browser window?
    
    
    
    --
    View this message in context: http://apache-guacamole-incubating-users.2363388.n4.nabble.com/guacamole-common-js-resize-method-guidance-tp693p738.html
    Sent from the Apache Guacamole (incubating) - Users mailing list archive at Nabble.com.
    

Re: guacamole-common-js resize method guidance

Posted by Mike Jumper <mi...@guac-dev.org>.
On Fri, Feb 16, 2018 at 9:33 AM, McRoy, Jeffrey (GE Healthcare) <
Jeffrey.McRoy@ge.com> wrote:

> ...
>
> I’ve hit a couple of issues:
> - Calculating the initial scale, Guacamole.Display.getHeight() and
> Guacamole.Display.getWidth() return 0 until the browser window is resized.
> This causes the first attempt at caluclating scale to be 0.
>

Yes, you will need to handle this case.

- In VNC the local mouse location seems to be off from the remote mouse
> locatipn, maybe need scaling applied here also?
>

Yes. The Guacamole.Mouse object is independent of the Guacamole.Client /
Guacamole.Display. If the Guacamole display is being scaled, you will need
to adjust the coordinates returned by Guacamole.Mouse accordingly. This
goes for the mouse emulation objects for touch support, as well.

- Mike