[Spice-devel] [PATCH spice-html5 2/2] Make sure to not set to smaller height than is minimal

Tomáš Bohdálek tom.bohdalek at gmail.com
Tue May 23 08:44:37 UTC 2017


Get minimal  screen height from css file.
---
 resize.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/resize.js b/resize.js
index b572de7..89b59ff 100644
--- a/resize.js
+++ b/resize.js
@@ -32,9 +32,14 @@
 **--------------------------------------------------------------------------*/
 function resize_helper(sc)
 {
-    var w = document.getElementById(sc.screen_id).clientWidth;
+    var screen_id = document.getElementById(sc.screen_id);
+    var w = screen_id.clientWidth;
     var m = document.getElementById(sc.message_id);
 
+    /* Screen size can't be get from screen_id.style.minHeight, min-height is defined in css */
+    var minHeight = parseInt(window.getComputedStyle(screen_id).getPropertyValue("min-height"),
+                             10);
+
     /* Resize vertically; basically we leave a 20 pixel margin
          at the bottom, and use the position of the message window
          to figure out how to resize */
@@ -42,6 +47,9 @@ function resize_helper(sc)
     /* Show both div elements - spice-area and message-div */
     var h = window.innerHeight - m.offsetHeight - m.clientHeight - 20;
 
+    /* Set minimal height if screen is smaller than screen min-height */
+    if (h < minHeight)
+        h = minHeight;
 
     /* Xorg requires height be a multiple of 8; round up */
     if (h % 8 > 0)
@@ -51,7 +59,6 @@ function resize_helper(sc)
     if (w % 8 > 0)
         w += (8 - (w % 8));
 
-
     sc.resize_window(0, w, h, 32, 0, 0);
     sc.spice_resize_timer = undefined;
 }
-- 
2.9.4



More information about the Spice-devel mailing list