You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Cathy Huang <lu...@163.com> on 2018/08/27 10:52:39 UTC

Scaling strategy for RDP on Retina and other 2x screen

Hi. 
I am building a remote desktop application based on guacamole-common-js and
guacamole-lite(a nodejs-based guacamole-common implementation). The version
of guacamole is 0.9.13-incubating.

I have a resolution problem when opening an RDP-connection on Retina screen. 

```
function getConnectionString (token) {
  var pixel_density = window.devicePixelRatio || 1;
  var optimal_dpi = pixel_density * 96;
  var optimal_width = window.innerWidth * pixel_density; // on retina screen
it's twice the width of window.innerWidth
  var optimal_height = window.innerHeight * pixel_density;
  return ("token=" + token
    + "&width="       + Math.floor(optimal_width)
    + "&height="      + Math.floor(optimal_height)
    + "&dpi="         + Math.floor(optimal_dpi)

...

client.connect(getConnectionString(token))

```

The resulted canvas is beyond the viewport because the received image is
twice as big as the window. So I call `client.getDisplay().scale(0.5)` to
scale the display. Then the wrapper of canvas shrinks to fit the window. The
icons and texts on the canvas are difficult to discern because they are now
half of the original size.

<http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/file/t706/t01c53e7c3267d0f517.png> 


However I found that the official demo is fine on Retina screen. I checked
the canvas' width in chrome dev-tool. It neither equals to
`window.innerWidth * pixel_density` nor `window.innerWidth`. As shown below. 

<http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/file/t706/t01d84d55d86d97306a.png> 

PS: I didn't resize the window at all.

Does the official demo's server implementation do anything to resize the
image before sending to the browser? Or did I miss something when I set up
the connection? How can I get the same effect as the official demo do? 



--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Scaling strategy for RDP on Retina and other 2x screen

Posted by Adam Thorn <al...@cam.ac.uk>.
On 28/08/2018 04:43, Cathy Huang wrote:
> Thank you, Mike.
> 
> What I mentioned as the "official demo" is installed by this script:
> https://sourceforge.net/projects/guacamoleinstallscript/.

That's a third-party project, and so I wouldn't describe any part of it 
as "official". Probably the most "official" way to install guacamole is 
by following the instructions on the guacamole website, e.g.

https://guacamole.apache.org/doc/gug/installing-guacamole.html

or

https://guacamole.apache.org/doc/gug/guacamole-docker.html

Amongst other things, this has the advantage that you'd be building and 
installing the latest version of guacamole rather than the out-of-date 
0.9.13-incubating version provided by that script.

Adam

Re: Scaling strategy for RDP on Retina and other 2x screen

Posted by Cathy Huang <lu...@163.com>.
Thank you, Mike.

What I mentioned as the "official demo" is installed by this script:
https://sourceforge.net/projects/guacamoleinstallscript/.
It installs guacd which I used to build my own app. It also automatically
builds an app based on Java and Angularjs, which is the "official demo" I
mentioned above. Here's the screenshot.
<http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/file/t706/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7_2018-08-28_%E4%B8%8A%E5%8D%8811.png> 


Those two apps are based on the same guacd but different guacamole-common
and server implementation. 

I debugged the guacamole-lite. When I set dpi 2 * 96, it did connect to the
guacd with code:`4.2560,4.1452,3.192, which are equal to `window.innerWidth
* window.devicePixelRatio`, `window.innerHeight * window.devicePixelRatio`,
and `window.devicePixelRatio * 96`. So the DPI value is being correctly
forwarded through the tunnel to guacd during the initial connection.

And things become tiny is due to scaling the overlarge display. If I don't
scale, things can be clearly discerned but the display will go beyond the
viewport.

I'm still wondering why the "official demo" sent back an image with a size
that's neither `window.innerWidth * window.devicePixelRatio` nor
`window.innerWidth`. If I know the reason, maybe I can change my code to
implement the same effect.




--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Scaling strategy for RDP on Retina and other 2x screen

Posted by Mike Jumper <mi...@glyptodon.org>.
On Mon, Aug 27, 2018 at 3:52 AM, Cathy Huang <lu...@163.com> wrote:

> Hi.
> I am building a remote desktop application based on guacamole-common-js and
> guacamole-lite(a nodejs-based guacamole-common implementation). The version
> of guacamole is 0.9.13-incubating.
>

It would be better to use the latest version.


> I have a resolution problem when opening an RDP-connection on Retina
> screen.
>
> ```
> function getConnectionString (token) {
>   var pixel_density = window.devicePixelRatio || 1;
>   var optimal_dpi = pixel_density * 96;
>   var optimal_width = window.innerWidth * pixel_density; // on retina
> screen
> it's twice the width of window.innerWidth
>   var optimal_height = window.innerHeight * pixel_density;
>   return ("token=" + token
>     + "&width="       + Math.floor(optimal_width)
>     + "&height="      + Math.floor(optimal_height)
>     + "&dpi="         + Math.floor(optimal_dpi)
>
> ...
>
> client.connect(getConnectionString(token))
>
> ```
>
>
I can't speak to the correctness of "guacamole-lite". Based on what you're
describing, the most likely explanation is that the DPI value is not being
forwarded through the tunnel to guacd during the initial connection.
Lacking DPI information, the RDP support will assume 96 DPI and things will
be tiny.


> However I found that the official demo is fine on Retina screen. I checked
> the canvas' width in chrome dev-tool. It neither equals to
> `window.innerWidth * pixel_density` nor `window.innerWidth`. As shown
> below.
>
> <http://apache-guacamole-general-user-mailing-list.
> 2363388.n4.nabble.com/file/t706/t01d84d55d86d97306a.png>
>
> PS: I didn't resize the window at all.
>
> Does the official demo's server implementation do anything to resize the
> image before sending to the browser? Or did I miss something when I set up
> the connection? How can I get the same effect as the official demo do?
>

There is no such official demo. We (Apache Guacamole) do not host a demo.
What are you referring to?

If you have tried deploying Apache Guacamole exactly as released and things
work as expected, but things do not work when using a third-party library
like "guacamole-lite", that fairly definitively demonstrates that the issue
is within that library. You may wish to reach out to the author of that
library to try to get things corrected.

- Mike