diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index 2b68c25..4b39800 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -125,11 +125,13 @@ firetray.Handler = { firetray.Utils.addObservers(firetray.Handler, [ "xpcom-will-shutdown", "profile-change-teardown" ]); - if (this.appId === FIRETRAY_APP_DB['thunderbird']['id'] || - this.appId === FIRETRAY_APP_DB['firefox']['id']) { - firetray.Utils.addObservers(firetray.Handler, [ "before-first-paint" ]); + if (this.appId === FIRETRAY_APP_DB['thunderbird']['id']) { + firetray.Utils.addObservers(firetray.Handler, [ "console-api-log-event" ]); + } else if (this.appId === FIRETRAY_APP_DB['firefox']['id'] || + this.appId === FIRETRAY_APP_DB['seamonkey']['id']) { + firetray.Utils.addObservers(firetray.Handler, [ "sessionstore-windows-restored" ]); } else { - firetray.Utils.addObservers(firetray.Handler, [ "xul-window-visible" ]); + firetray.Utils.addObservers(firetray.Handler, [ "final-ui-startup" ]); } this.preventWarnOnClose(); @@ -204,7 +206,7 @@ firetray.Handler = { startupDone: function() { firetray.Handler.timers['startup-done'] = - firetray.Utils.timer(FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, + firetray.Utils.timer(FIRETRAY_DELAY_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT, function() { firetray.Handler.appStarted = true; log.debug("*** appStarted ***"); @@ -214,16 +216,16 @@ firetray.Handler = { observe: function(subject, topic, data) { switch (topic) { - case "before-first-paint": - if (FIRETRAY_APP_DB[this.appName.toLowerCase()]['mainXUL'] !== subject.baseURI) return; - - log.debug("before-first-paint: "+subject.baseURI); - firetray.Utils.removeObservers(firetray.Handler, [ "before-first-paint" ]); - firetray.Handler.startupDone(); - break; - case "xul-window-visible": - log.debug("xul-window-visible: "+subject+","+data); - firetray.Utils.removeObservers(firetray.Handler, [ "xul-window-visible" ]); + case "sessionstore-windows-restored": + // sessionstore-windows-restored does not come after the realization of + // all windows... so we wait a little + case "console-api-log-event": // one of the few events issued at later + // stage, once windows are realized + // second TB window also issues + // "mail-startup-done"/"mail-tabs-session-restored" + case "final-ui-startup": // subject=ChromeWindow + log.debug(topic+": "+subject+","+data); + firetray.Utils.removeObservers(firetray.Handler, [ topic ]); firetray.Handler.startupDone(); break; @@ -533,7 +535,7 @@ firetray.VersionChangeHandler = { if (tabmail) { firetray.Handler.timers['open-mail-tab'] = - firetray.Utils.timer(FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, + firetray.Utils.timer(FIRETRAY_DELAY_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT, function() { log.debug("openMailTab"); tabmail.openTab("contentTab", {contentPage: url}); diff --git a/src/modules/commons.js b/src/modules/commons.js index e0b44c9..a84fbe9 100644 --- a/src/modules/commons.js +++ b/src/modules/commons.js @@ -11,7 +11,7 @@ var EXPORTED_SYMBOLS = "FIRETRAY_IM_STATUS_AVAILABLE", "FIRETRAY_IM_STATUS_AWAY", "FIRETRAY_IM_STATUS_BUSY", "FIRETRAY_IM_STATUS_OFFLINE", "FIRETRAY_ACCOUNT_SERVER_TYPE_IM", - "FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS", + "FIRETRAY_DELAY_STARTUP_MILLISECONDS", "FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS", "FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD", "FIRETRAY_MESSAGE_COUNT_TYPE_NEW", @@ -46,45 +46,38 @@ const FIRETRAY_IM_STATUS_OFFLINE = "user-offline"; const FIRETRAY_ACCOUNT_SERVER_TYPE_IM = "im"; -const FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS = 500; -const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0; -const FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS = 15*60*1000; +const FIRETRAY_DELAY_STARTUP_MILLISECONDS = 500; +const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0; +const FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS = 15*60*1000; const FIRETRAY_APP_DB = { firefox: { id: "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", - mainXUL: "chrome://browser/content/browser.xul" }, thunderbird: { id: "{3550f703-e582-4d05-9a08-453d09bdfdc6}", - mainXUL: "chrome://messenger/content/msgAccountCentral.xul" }, seamonkey: { id: "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}", - mainXUL: null }, songbird: { id: "songbird@songbirdnest.com", - mainXUL: null }, sunbird: { id: "718e30fb-e89b-41dd-9da7-e25a45638b28}", - mainXUL: null }, chatzilla: { id: "{59c81df5-4b7a-477b-912d-4e0fdf64e5f2}", - mainXUL: null }, zotero: { id: "zotero@chnm.gmu.edu", - mainXUL: null } }; diff --git a/src/modules/linux/FiretrayChatStatusIcon.jsm b/src/modules/linux/FiretrayChatStatusIcon.jsm index ca17dd8..daa0ea1 100644 --- a/src/modules/linux/FiretrayChatStatusIcon.jsm +++ b/src/modules/linux/FiretrayChatStatusIcon.jsm @@ -16,7 +16,6 @@ Cu.import("resource://firetray/ctypes/linux/gdk.jsm"); Cu.import("resource://firetray/ctypes/linux/gtk.jsm"); Cu.import("resource://firetray/linux/FiretrayWindow.jsm"); Cu.import("resource://firetray/commons.js"); -Cu.import("resource://firetray/promise.js"); firetray.Handler.subscribeLibsForClosing([gobject, gio, gtk]); if ("undefined" == typeof(firetray.Handler)) diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index 8816328..8909af0 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -589,7 +589,8 @@ firetray.Window = { let xid = xany.contents.window; if (xany.contents.type === x11.MapNotify) { - if (firetray.Utils.prefService.getBoolPref('start_hidden')) { + if (!firetray.Handler.appStarted && + firetray.Utils.prefService.getBoolPref('start_hidden')) { log.debug("start_hidden"); firetray.Window.startupHide(xid); }