Bug 97067: focus changes windows when background window finally loads. patch by saari, slightly modified by me, r=jag,ben, sr/rs=hyatt (sr on the original patch)

This commit is contained in:
jaggernaut%netscape.com 2001-10-07 10:23:32 +00:00
Родитель 86c2bc826c
Коммит aa3ec222c2
1 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -371,9 +371,9 @@ function Startup()
// Focus the content area if the caller instructed us to.
if ("arguments" in window && window.arguments.length >= 3 && window.arguments[2] == true ||
!window.locationbar.visible)
setTimeout("_content.focus();", 0); // XXXjag bug 91884
setTimeout(WindowFocusTimerCallback, 0, _content);
else
setTimeout("gURLBar.focus();", 0); // XXXjag bug 91884
setTimeout(WindowFocusTimerCallback, 0, gURLBar);
// Perform default browser checking.
checkForDefaultBrowser();
@ -388,6 +388,23 @@ function Startup()
}
}
function WindowFocusTimerCallback(element)
{
// This fuction is a redo of the fix for jag bug 91884
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
if (window == ww.activeWindow) {
element.focus();
} else {
// set the element in command dispatcher so focus will restore properly
// when the window does become active
if (element instanceof Components.interfaces.nsIDOMElement)
document.commandDispatcher.focusedElement = element;
else if (element instanceof Components.interfaces.nsIDOMWindow)
document.commandDispatcher.focusedWindow = element;
}
}
function BrowserFlushBookmarksAndHistory()
{
// Flush bookmakrs and history (used when window closes or is cached).