hooking up windowwatcher active window. bug 44809,76011 r=chak,hyatt,saari

This commit is contained in:
danm%netscape.com 2001-04-16 20:34:33 +00:00
Родитель b29ebab2a2
Коммит 269f5f62cd
3 изменённых файлов: 27 добавлений и 18 удалений

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

@ -72,6 +72,8 @@ nsWebBrowser::nsWebBrowser() : mDocShellTreeOwner(nsnull),
{
NS_INIT_REFCNT();
mInitInfo = new nsWebBrowserInitInfo();
mWWatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
NS_ASSERTION(mWWatch, "failed to get WindowWatcher");
}
nsWebBrowser::~nsWebBrowser()
@ -1541,28 +1543,27 @@ NS_IMETHODIMP nsWebBrowser::GetPrimaryContentWindow(nsIDOMWindowInternal **aDOMW
/* void activate (); */
NS_IMETHODIMP nsWebBrowser::Activate(void)
{
// Make sure we can get the to a valid nsIPresShell
// Without this check we assert when the embeddor calls
// us and the presShell is not yet created
// For ex, under MSFT Windows embeddors can trap
// the WM_ACTIVATE message in response to which
// can call nsIWebBrowser->Activate(). During the initial
// window creation the presShell will not be created when
// the call to the initial Activate() is made
NS_ENSURE_STATE(mDocShell);
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
if(!presShell)
return NS_OK;
nsCOMPtr<nsIDOMWindow> domWindow;
GetContentDOMWindow(getter_AddRefs(domWindow));
if (domWindow) {
// tell windowwatcher about the new active window
if (mWWatch)
mWWatch->SetActiveWindow(domWindow);
/* Activate the window itself. Do this only if the PresShell has
been created, since DOMWindow->Activate asserts otherwise.
(This method can be called during window creation before
the PresShell exists. For ex, Windows apps responding to
WM_ACTIVATE). */
NS_ENSURE_STATE(mDocShell);
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
if(presShell) {
nsCOMPtr<nsPIDOMWindow> privateDOMWindow = do_QueryInterface(domWindow);
if(privateDOMWindow)
privateDOMWindow->Activate();
}
}
return NS_OK;
}
@ -1570,6 +1571,11 @@ NS_IMETHODIMP nsWebBrowser::Activate(void)
/* void deactivate (); */
NS_IMETHODIMP nsWebBrowser::Deactivate(void)
{
/* At this time we don't clear mWWatch's ActiveWindow; we just allow
the presumed other newly active window to set it when it comes in.
This seems harmless and maybe safer, but we have no real evidence
either way just yet. */
NS_ENSURE_STATE(mDocShell);
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));

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

@ -48,6 +48,7 @@
#include "nsIWebBrowserFocus.h"
#include "nsIWebBrowserFind.h"
#include "nsIWebBrowserPrint.h"
#include "nsIWindowWatcher.h"
// for painting the background window
#include "nsIDeviceContext.h"
@ -140,6 +141,7 @@ protected:
nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
nsCOMPtr<nsIWidget> mInternalWidget;
nsCOMPtr<nsIWindowWatcher> mWWatch;
nsWebBrowserInitInfo* mInitInfo;
PRUint32 mContentType;
nativeWindow mParentNativeWindow;

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

@ -980,6 +980,7 @@ void CBrowserView::Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
switch(nState) {
case WA_ACTIVE:
case WA_CLICKACTIVE:
focus->Activate();
break;
case WA_INACTIVE: