diff --git a/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/ConfiguredGuacamoleSocket.java b/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/ConfiguredGuacamoleSocket.java index 06308f401..9c9742db3 100644 --- a/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/ConfiguredGuacamoleSocket.java +++ b/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/ConfiguredGuacamoleSocket.java @@ -149,7 +149,8 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket { new GuacamoleInstruction( "size", Integer.toString(info.getOptimalScreenWidth()), - Integer.toString(info.getOptimalScreenHeight()) + Integer.toString(info.getOptimalScreenHeight()), + Integer.toString(info.getOptimalResolution()) ) ); diff --git a/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleClientInformation.java b/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleClientInformation.java index 6cb10a275..1f2b1e06b 100644 --- a/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleClientInformation.java +++ b/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleClientInformation.java @@ -59,14 +59,19 @@ public class GuacamoleClientInformation { private int optimalScreenHeight = 768; /** - * The list of audio mimetypes reported by the client to be supported. + * The resolution of the optimal dimensions given, in DPI. */ - private List audioMimetypes = new ArrayList(); + private int optimalResolution = 96; /** * The list of audio mimetypes reported by the client to be supported. */ - private List videoMimetypes = new ArrayList(); + private final List audioMimetypes = new ArrayList(); + + /** + * The list of audio mimetypes reported by the client to be supported. + */ + private final List videoMimetypes = new ArrayList(); /** * Returns the optimal screen width requested by the client, in pixels. @@ -100,6 +105,26 @@ public class GuacamoleClientInformation { this.optimalScreenHeight = optimalScreenHeight; } + /** + * Returns the resolution of the screen if the optimal width and height are + * used, in DPI. + * + * @return The optimal screen resolution. + */ + public int getOptimalResolution() { + return optimalResolution; + } + + /** + * Sets the resolution of the screen if the optimal width and height are + * used, in DPI. + * + * @param optimalResolution The optimal screen resolution in DPI. + */ + public void setOptimalResolution(int optimalResolution) { + this.optimalResolution = optimalResolution; + } + /** * Returns the list of audio mimetypes supported by the client. To add or * removed supported mimetypes, the list returned by this function can be diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/BasicTunnelRequestUtility.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/BasicTunnelRequestUtility.java index 57f8184ee..5a8922544 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/BasicTunnelRequestUtility.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/BasicTunnelRequestUtility.java @@ -251,6 +251,11 @@ public class BasicTunnelRequestUtility { if (height != null) info.setOptimalScreenHeight(Integer.parseInt(height)); + // Set resolution if provided + String dpi = request.getParameter("dpi"); + if (dpi != null) + info.setOptimalResolution(Integer.parseInt(dpi)); + // Add audio mimetypes String[] audio_mimetypes = request.getParameterValues("audio"); if (audio_mimetypes != null) diff --git a/guacamole/src/main/webapp/client.xhtml b/guacamole/src/main/webapp/client.xhtml index 9bf3e3aea..0e7fabd1c 100644 --- a/guacamole/src/main/webapp/client.xhtml +++ b/guacamole/src/main/webapp/client.xhtml @@ -105,8 +105,10 @@ try { // Calculate optimal width/height for display - var optimal_width = window.innerWidth; - var optimal_height = window.innerHeight; + var pixel_density = window.devicePixelRatio || 1; + var optimal_dpi = pixel_density * 96; + var optimal_width = window.innerWidth * pixel_density; + var optimal_height = window.innerHeight * pixel_density; // Scale width/height to be at least 600x600 if (optimal_width < 600 || optimal_height < 600) { @@ -123,7 +125,8 @@ var connect_string = window.location.search.substring(1) + "&width=" + optimal_width - + "&height=" + optimal_height; + + "&height=" + optimal_height + + "&dpi=" + optimal_dpi; // Add audio mimetypes to connect_string GuacUI.Audio.supported.forEach(function(mimetype) { diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index cc6e6f5b8..0e485ec67 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -953,7 +953,11 @@ GuacUI.Client.attach = function(guac) { */ window.onresize = function() { - guac.sendSize(window.innerWidth, window.innerHeight); + var pixel_density = window.devicePixelRatio || 1; + var width = window.innerWidth * pixel_density; + var height = window.innerHeight * pixel_density; + + guac.sendSize(width, height); GuacUI.Client.updateDisplayScale(); };