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).
This commit is contained in:
foudfou 2012-12-13 19:11:58 +01:00
parent c622e61e9d
commit 29de64e51f
4 changed files with 14 additions and 50 deletions

View File

@ -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);
}
}
};

View File

@ -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) {},

View File

@ -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;

View File

@ -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);