[tor-commits] [torbutton/master] Bug #1282: Turns out window.screen.availHeight lies.

mikeperry at torproject.org mikeperry at torproject.org
Thu Jun 30 02:58:28 UTC 2011


commit f2b3ddc18d4e602c17627968edc3244536d7f5fb
Author: Mike Perry <mikeperry-git at fscked.org>
Date:   Wed Jun 29 19:57:35 2011 -0700

    Bug #1282: Turns out window.screen.availHeight lies.
    
    Need to use nsIScreenManager.
---
 src/chrome/content/torbutton.js |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 9c720e1..e086a8d 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -3649,14 +3649,20 @@ function torbutton_set_window_size(bWin) {
     if (m_tb_prefs.getBoolPref("extensions.torbutton.resize_new_windows")
             && m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")
             && torbutton_is_windowed(window)) {
+        var screenMan = Components.classes["@mozilla.org/gfx/screenmanager;1"]
+                            .getService(Components.interfaces.nsIScreenManager);
+        var junk = {}, availWidth = {}, availHeight = {};
+        screenMan.primaryScreen.GetRect(junk, junk, availWidth, availHeight);
+
         // We need to set the inner width to an initial value because it has none
         // at this point...
         bWin.innerWidth = 200;
         bWin.innerHeight = 200;
-        torbutton_log(2, "About to resize new window: "+window.outerWidth+"x"+window.outerHeight+" in state "+window.windowState);
+        torbutton_log(2, "About to resize new window: "+window.outerWidth+"x"+window.outerHeight
+                +" in state "+window.windowState+" Have "+availWidth.value+"x"+availHeight.value);
 
-        var maxHeight = window.screen.availHeight - (window.outerHeight - bWin.innerHeight) - 1;
-        var maxWidth = window.screen.availWidth - (window.outerWidth - bWin.innerWidth) -1;
+        var maxHeight = availHeight.value - (window.outerHeight - bWin.innerHeight) - 101;
+        var maxWidth = availWidth.value - (window.outerWidth - bWin.innerWidth);
 
         var width;
         var height;



More information about the tor-commits mailing list