Bug 433001 - Base default Mail & Newsgroup window size on available screen size. ui-r=Ratty, r=Ratty, a=Ratty
authorrsx11m <rsx11m.pub@gmail.com>
Thu, 02 Jun 2016 18:13:30 -0500
changeset 19422 9c6b3837eb83e05d38ed17050f2732423c5fc9bb
parent 19421 309a67d48771492e2f959a0d4b263c30efa0ed28
child 19423 4e2619025b77ac6beca689dc4ad22d05ee6f982b
push id11953
push userrsx11m.pub@gmail.com
push dateSun, 05 Jun 2016 15:03:25 +0000
treeherdercomm-central@9c6b3837eb83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty, Ratty, Ratty
bugs433001
Bug 433001 - Base default Mail & Newsgroup window size on available screen size. ui-r=Ratty, r=Ratty, a=Ratty
suite/mailnews/messenger.xul
suite/mailnews/msgMail3PaneWindow.js
--- a/suite/mailnews/messenger.xul
+++ b/suite/mailnews/messenger.xul
@@ -22,17 +22,16 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:nc="http://home.netscape.com/NC-rdf#"
         title="&messengerWindow.title;"
         titlemodifier="&titleModifier.label;"
         titlemenuseparator="&titleSeparator.label;"
         onload="OnLoadMessenger()"
         onunload="OnUnloadMessenger()"
         onclose="return MailWindowIsClosing();"
-        style="width: 82em; height: 50em;"
         screenX="10" screenY="10"
         persist="width height screenX screenY sizemode"
         toggletoolbar="true"
         lightweightthemes="true"
         lightweightthemesfooter="status-bar"
         macanimationtype="document"
         drawtitle="true"
         windowtype="mail:3pane">
--- a/suite/mailnews/msgMail3PaneWindow.js
+++ b/suite/mailnews/msgMail3PaneWindow.js
@@ -671,16 +671,38 @@ function OnLoadMessenger()
   CreateMailWindowGlobals();
   Services.prefs.addObserver("mail.pane_config.dynamic", MailPrefObserver, false);
   Services.prefs.addObserver("mail.showCondensedAddresses", MailPrefObserver, false);
   UpdateMailPaneConfig();
   Create3PaneGlobals();
   verifyAccounts(null, false);
   msgDBCacheManager.init();
 
+  // set the messenger default window size relative to the screen size
+  // initial default dimensions are 2/3 and 1/2 of the screen dimensions
+  if (!document.documentElement.hasAttribute("width")) {
+    let screenHeight  = window.screen.availHeight;
+    let screenWidth   = window.screen.availWidth;
+    let defaultHeight = Math.floor(screenHeight * 2 / 3);
+    let defaultWidth  = Math.floor(screenWidth / 2);
+
+    // minimum dimensions are 1024x768 less padding unless restrained by screen
+    const minHeight = 768;
+    const minWidth = 1024;
+
+    if (defaultHeight < minHeight)
+       defaultHeight = Math.min(minHeight, screenHeight);
+    if (defaultWidth < minWidth)
+       defaultWidth = Math.min(minWidth, screenWidth);
+
+    // keep some distance to the borders, accounting for window decoration
+    document.documentElement.setAttribute("height", defaultHeight - 48);
+    document.documentElement.setAttribute("width",  defaultWidth  - 24);
+  }
+
   // initialize tabmail system - see tabmail.js and tabmail.xml for details
   let tabmail = GetTabMail();
   tabmail.registerTabType(gMailNewsTabsType);
   tabmail.openFirstTab();
   Services.obs.addObserver(MailWindowIsClosing,
                            "quit-application-requested", false);
 
   InitMsgWindow();