From 29de64e51f2667cca4074c20a3667ed032412c89 Mon Sep 17 00:00:00 2001 From: foudfou Date: Thu, 13 Dec 2012 19:11:58 +0100 Subject: [PATCH] base the startup event on the first 'before-first-paint' That lets the windows get well realized before we can hide them (start_hidden). This is especially true for heavy configurations with numerous addons (Lightning with multiple remote calendars for instance). --- src/chrome/content/overlay.js | 12 --------- src/modules/FiretrayHandler.jsm | 37 ++++++++++------------------ src/modules/commons.js | 2 -- src/modules/linux/FiretrayWindow.jsm | 13 +--------- 4 files changed, 14 insertions(+), 50 deletions(-) diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js index 6eb726f..80e7210 100644 --- a/src/chrome/content/overlay.js +++ b/src/chrome/content/overlay.js @@ -24,9 +24,6 @@ var firetrayChrome = { // each new window gets a new firetrayChrome ! ftlog.debug("ONLOAD"); firetray.Handler.dumpWindows(); this.winId = firetray.Handler.registerWindow(win); - win.setTimeout(firetrayChrome.startHiddenMaybe, - FIRETRAY_DELAY_STARTUP_HIDE_MILLISECONDS, - this.winId); win.addEventListener('close', firetrayChrome.onClose, true); @@ -69,15 +66,6 @@ var firetrayChrome = { // each new window gets a new firetrayChrome ! firetray.Handler.hideAllWindows(); event && event.preventDefault(); } - }, - - startHiddenMaybe: function(winId) { - ftlog.debug('startHiddenMaybe'+'. appStarted='+firetray.Handler.appStarted); - - if (firetray.Utils.prefService.getBoolPref('start_hidden') && - !firetray.Handler.appStarted) { // !appStarted for new windows ! - firetray.Handler.startupHideWindow(winId); - } } }; diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index 3f0b5bf..463ab41 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -43,7 +43,6 @@ firetray.Handler = { appId: (function(){return Services.appinfo.ID;})(), appName: (function(){return Services.appinfo.name;})(), - appStartupTopic: null, runtimeABI: (function(){return Services.appinfo.XPCOMABI;})(), runtimeOS: (function(){return Services.appinfo.OS;})(), // "WINNT", "Linux", "Darwin" addonRootDir: (function(){ @@ -116,9 +115,8 @@ firetray.Handler = { firetray.Chat.init(); } - this.appStartupTopic = this.getAppStartupTopic(this.appId); - firetray.Utils.addObservers(firetray.Handler, [ this.appStartupTopic, - "xpcom-will-shutdown", "profile-change-teardown" ]); + firetray.Utils.addObservers(firetray.Handler, + [ "before-first-paint", "xpcom-will-shutdown", "profile-change-teardown" ]); this.preventWarnOnClose(); @@ -190,18 +188,22 @@ firetray.Handler = { observe: function(subject, topic, data) { switch (topic) { - case "sessionstore-windows-restored": - case "mail-startup-done": - case "final-ui-startup": // subject=ChromeWindow - if (firetray.Handler.appStarted) return; // second TB window issues "mail-startup-done" - log.debug("RECEIVED: "+topic+", launching timer"); - // sessionstore-windows-restored does not come after the realization of - // all windows... so we wait a little + + case "before-first-paint": + log.debug("before-first-paint: "+subject.baseURI); + firetray.Utils.removeObservers(firetray.Handler, [ "before-first-paint" ]); firetray.Utils.timer(function() { + + if (firetray.Utils.prefService.getBoolPref('start_hidden')) { + log.debug("start_hidden"); + firetray.Handler.hideAllWindows(); + } + firetray.Handler.appStarted = true; log.debug("*** appStarted ***"); }, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT); break; + case "xpcom-will-shutdown": log.debug("xpcom-will-shutdown"); this.shutdown(); @@ -225,18 +227,6 @@ firetray.Handler = { } }, - getAppStartupTopic: function(id) { - switch (id) { - case FIRETRAY_FIREFOX_ID: - case FIRETRAY_SEAMONKEY_ID: - return 'sessionstore-windows-restored'; - case FIRETRAY_THUNDERBIRD_ID: - return 'mail-startup-done'; - default: - return 'final-ui-startup'; - } - }, - // these get overridden in OS-specific Icon/Window handlers setIconImageDefault: function() {}, setIconImageNewMail: function() {}, @@ -249,7 +239,6 @@ firetray.Handler = { unregisterWindow: function(win) {}, getWindowIdFromChromeWindow: function(win) {}, hideWindow: function(winId) {}, - startupHideWindow: function(winId) {}, showWindow: function(winId) {}, showHideAllWindows: function() {}, activateLastWindow: function(gtkStatusIcon, gdkEvent, userData) {}, diff --git a/src/modules/commons.js b/src/modules/commons.js index a15e7df..7de2854 100644 --- a/src/modules/commons.js +++ b/src/modules/commons.js @@ -11,7 +11,6 @@ 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_STARTUP_HIDE_MILLISECONDS", "FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS", "FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS", @@ -49,7 +48,6 @@ const FIRETRAY_IM_STATUS_OFFLINE = "user-offline"; const FIRETRAY_ACCOUNT_SERVER_TYPE_IM = "im"; const FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS = 500; -const FIRETRAY_DELAY_STARTUP_HIDE_MILLISECONDS = 400; const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0; const FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS = 15*60*1000; diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index a2b6e48..06b4556 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -257,16 +257,6 @@ firetray.Window = { firetray.Handler.showHideIcon(); }, - startupHide: function(xid) { - log.debug('startupHide: '+xid); - - firetray.Handler.windows[xid].baseWin.visibility = false; - firetray.Window.updateVisibility(xid, false); - - firetray.PopupMenu.showWindowItem(xid); - firetray.Handler.showHideIcon(); - }, - savePositionAndSize: function(xid) { let gx = {}, gy = {}, gwidth = {}, gheight = {}; firetray.Handler.windows[xid].baseWin.getPositionAndSize(gx, gy, gwidth, gheight); @@ -533,7 +523,7 @@ firetray.Window = { case x11.MapNotify: log.debug("MapNotify"); let win = firetray.Handler.windows[xid]; - if (!win.visible) { // happens when hidden app called from command line + if (!win.visible && firetray.Handler.appStarted) { // happens when hidden app called from command line log.warn("window not visible, correcting visibility"); firetray.Window.updateVisibility(xid, true); log.debug("visibleWindowsCount="+firetray.Handler.visibleWindowsCount); @@ -635,7 +625,6 @@ firetray.Handler.unregisterWindow = function(win) { firetray.Handler.showWindow = firetray.Window.show; firetray.Handler.hideWindow = firetray.Window.hide; -firetray.Handler.startupHideWindow = firetray.Window.startupHide; firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) { log.debug("showHideAllWindows: "+userData);