From 9da78d61d2b8ec595539a700586a85dcfb0ecb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Wed, 15 Jun 2011 19:21:58 +0200 Subject: [PATCH] Bug 954255 - Better window positions at first start. --- im/content/blist.js | 8 ++++++++ im/content/blist.xul | 1 - im/content/menus.js | 30 +++++++++--------------------- im/content/preferences/main.js | 23 +++++------------------ im/modules/ibCore.jsm | 7 ++++++- 5 files changed, 28 insertions(+), 41 deletions(-) diff --git a/im/content/blist.js b/im/content/blist.js index 8d299833b9..968fd576f9 100644 --- a/im/content/blist.js +++ b/im/content/blist.js @@ -592,6 +592,14 @@ var buddyList = { } } + // Move the window to the right of the screen on new profiles. + let docElt = document.documentElement; + if (!docElt.hasAttribute("height")) { + docElt.setAttribute("height", screen.availHeight || 600); + let width = parseInt(docElt.getAttribute("width")); + window.moveTo(screen.availLeft + screen.availWidth - width, 0); + } + // TODO remove this once we cleanup the way the menus are inserted let menubar = document.getElementById("blistMenubar"); let statusArea = document.getElementById("statusArea"); diff --git a/im/content/blist.xul b/im/content/blist.xul index 19910ee76d..593dd0666c 100644 --- a/im/content/blist.xul +++ b/im/content/blist.xul @@ -54,7 +54,6 @@ windowtype="Messenger:blist" title = "&contacts.title;" width = "200" - height = "600" persist= "width height screenX screenY" #ifndef XP_MACOSX onclose= "event.preventDefault(); goQuitApplication();" diff --git a/im/content/menus.js b/im/content/menus.js index 007289e58b..424be41516 100644 --- a/im/content/menus.js +++ b/im/content/menus.js @@ -35,9 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -const addonManagerWindow = "chrome://instantbird/content/extensions.xul"; -const accountManagerWindow = "chrome://instantbird/content/accounts.xul"; -const blistWindow = "chrome://instantbird/content/blist.xul"; const addBuddyWindow = "chrome://instantbird/content/addbuddy.xul"; const joinChatWindow = "chrome://instantbird/content/joinchat.xul"; const aboutWindow = "chrome://instantbird/content/aboutDialog.xul"; @@ -50,17 +47,9 @@ if (!("Core" in window)) Components.utils.import("resource:///modules/ibCore.jsm"); var menus = { - focus: function menu_focus(aWindowType) { - var win = Services.wm.getMostRecentWindow(aWindowType); - if (win) - win.focus(); - return win; - }, - about: function menu_about() { - if (!this.focus("Messenger:About")) - window.open(aboutWindow, "About", - "chrome,resizable=no,minimizable=no,centerscreen"); + Core.showWindow("Messenger:About", aboutWindow, "About", + "chrome,resizable=no,minimizable=no,centerscreen"); }, accounts: function menu_accounts() { @@ -72,15 +61,12 @@ var menus = { }, addons: function menu_addons() { - if (!this.focus("Addons:Manager")) - window.open(addonManagerWindow, "Addons", - "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable"); + Core.showAddons(); }, errors: function debug_errors() { - if (!menus.focus("global:console")) - window.open(errorConsoleWindow, "Errors", - "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); + Core.showWindow("global:console", errorConsoleWindow, "Errors", + "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); }, updates: function menu_updates() { @@ -199,9 +185,11 @@ var menus = { if (!status) return; // is this really possible? - let blist = this.focus("Messenger:blist"); - if (blist) + let blist = Services.wm.getMostRecentWindow("Messenger:blist"); + if (blist) { + blist.focus(); blist.buddyList.startEditStatus(status); + } else { Services.core.setStatus(Status.toFlag(status), Services.core.currentStatusMessage); diff --git a/im/content/preferences/main.js b/im/content/preferences/main.js index 5deff9f4de..6f51ca9ec5 100644 --- a/im/content/preferences/main.js +++ b/im/content/preferences/main.js @@ -38,6 +38,9 @@ # # ***** END LICENSE BLOCK ***** +if (!("Core" in window)) + Components.utils.import("resource:///modules/ibCore.jsm"); + var gMainPane = { _pane: null, @@ -49,24 +52,12 @@ var gMainPane = { this._pane = document.getElementById("paneMain"); }, - /** - * Helper to focus an already existing window before opening a new one. - */ - focus: function (aWindowType) { - var win = Services.wm.getMostRecentWindow(aWindowType); - if (win) - win.focus(); - return win; - }, - /** * Displays the Add-ons Manager. */ showAccountsMgr: function () { - if (!this.focus("Messenger:Accounts")) - window.open("chrome://instantbird/content/accounts.xul", "Accounts", - "chrome,resizable"); + Core.showAccounts(); }, /** @@ -74,10 +65,6 @@ var gMainPane = { */ showAddonsMgr: function () { - const AMURL = "chrome://instantbird/content/extensions.xul"; - - if (!this.focus("Addons:Manager")) - window.open(AMURL, "Addons", - "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable"); + Core.showAddons(); } }; diff --git a/im/modules/ibCore.jsm b/im/modules/ibCore.jsm index e5234bc2bd..586cd49c40 100644 --- a/im/modules/ibCore.jsm +++ b/im/modules/ibCore.jsm @@ -130,7 +130,12 @@ var Core = { showAccounts: function() { this.showWindow("Messenger:Accounts", "chrome://instantbird/content/accounts.xul", "Accounts", - "chrome,resizable"); + "chrome,resizable,centerscreen"); + }, + showAddons: function() { + this.showWindow("Addons:Manager", + "chrome://instantbird/content/extensions.xul", "Addons", + "chrome,menubar,extrachrome,toolbar,dialog=no,resizable,centerscreen"); }, showContacts: function() { this.showWindow("Messenger:blist",