adding events to constrain z-level
git-svn-id: svn://10.0.0.236/trunk@64900 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
5923e169e1
commit
d72876c011
@ -120,9 +120,6 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
|||||||
#define USE_NATIVE_MENUS
|
#define USE_NATIVE_MENUS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "nsIWindowMediator.h"
|
|
||||||
|
|
||||||
#include "nsIPopupSetFrame.h"
|
#include "nsIPopupSetFrame.h"
|
||||||
|
|
||||||
/* Define Class IDs */
|
/* Define Class IDs */
|
||||||
@ -140,10 +137,6 @@ static NS_DEFINE_CID(kContextMenuCID, NS_CONTEXTMENU_CID);
|
|||||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|
||||||
|
|
||||||
static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID);
|
static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID);
|
||||||
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
|
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
|
||||||
|
|
||||||
@ -244,6 +237,8 @@ nsWebShellWindow::~nsWebShellWindow()
|
|||||||
NS_RELEASE(mWebShell);
|
NS_RELEASE(mWebShell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mWindow)
|
||||||
|
mWindow->SetClientData(0);
|
||||||
mWindow = nsnull; // Force release here.
|
mWindow = nsnull; // Force release here.
|
||||||
|
|
||||||
PR_Lock(mSPTimerLock);
|
PR_Lock(mSPTimerLock);
|
||||||
@ -273,6 +268,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
|||||||
nsIAppShell* aShell, nsIURI* aUrl,
|
nsIAppShell* aShell, nsIURI* aUrl,
|
||||||
PRBool aCreatedVisible,
|
PRBool aCreatedVisible,
|
||||||
PRBool aLoadDefaultPage,
|
PRBool aLoadDefaultPage,
|
||||||
|
PRUint32 aZlevel,
|
||||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
|
||||||
nsWidgetInitData& widgetInitData)
|
nsWidgetInitData& widgetInitData)
|
||||||
{
|
{
|
||||||
@ -281,6 +277,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
|||||||
|
|
||||||
mShowAfterLoad = aCreatedVisible;
|
mShowAfterLoad = aCreatedVisible;
|
||||||
mLoadDefaultPage = aLoadDefaultPage;
|
mLoadDefaultPage = aLoadDefaultPage;
|
||||||
|
mZlevel = aZlevel;
|
||||||
|
|
||||||
// XXX: need to get the default window size from prefs...
|
// XXX: need to get the default window size from prefs...
|
||||||
// Doesn't come from prefs... will come from CSS/XUL/RDF
|
// Doesn't come from prefs... will come from CSS/XUL/RDF
|
||||||
@ -474,13 +471,29 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case NS_SETZLEVEL: {
|
||||||
|
void *data;
|
||||||
|
nsZLevelEvent *zEvent = (nsZLevelEvent *) aEvent;
|
||||||
|
|
||||||
|
zEvent->widget->GetClientData(data);
|
||||||
|
if (data) {
|
||||||
|
nsWebShellWindow *win;
|
||||||
|
win = NS_REINTERPRET_CAST(nsWebShellWindow *, data);
|
||||||
|
zEvent->mAdjusted = win->ConstrainToZLevel(zEvent->mImmediate,
|
||||||
|
&zEvent->mPlacement,
|
||||||
|
zEvent->mReqBelow, &zEvent->mActualBelow);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case NS_MOUSE_ACTIVATE:
|
||||||
case NS_ACTIVATE: {
|
case NS_ACTIVATE: {
|
||||||
#ifdef DEBUG_saari
|
#ifdef DEBUG_saari
|
||||||
printf("nsWebShellWindow::NS_ACTIVATE\n");
|
printf("nsWebShellWindow::NS_ACTIVATE\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NS_DEACTIVATE: {
|
case NS_DEACTIVATE: {
|
||||||
#ifdef DEBUG_saari
|
#ifdef DEBUG_saari
|
||||||
printf("nsWebShellWindow::NS_DEACTIVATE\n");
|
printf("nsWebShellWindow::NS_DEACTIVATE\n");
|
||||||
@ -562,7 +575,7 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nsEventStatus_eIgnore;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -111,6 +111,7 @@ public:
|
|||||||
// nsWebShellWindow methods...
|
// nsWebShellWindow methods...
|
||||||
nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl,
|
nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl,
|
||||||
PRBool aCreatedVisible, PRBool aLoadDefaultPage,
|
PRBool aCreatedVisible, PRBool aLoadDefaultPage,
|
||||||
|
PRUint32 aZlevel,
|
||||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
|
||||||
nsWidgetInitData& widgetInitData);
|
nsWidgetInitData& widgetInitData);
|
||||||
nsIWidget* GetWidget(void) { return mWindow; }
|
nsIWidget* GetWidget(void) { return mWindow; }
|
||||||
|
|||||||
@ -49,6 +49,7 @@
|
|||||||
// XXX Get rid of this
|
// XXX Get rid of this
|
||||||
#pragma message("WARNING: XXX bad include, remove it.")
|
#pragma message("WARNING: XXX bad include, remove it.")
|
||||||
#include "nsIWebShellWindow.h"
|
#include "nsIWebShellWindow.h"
|
||||||
|
#include "nsWebShellWindow.h" // get rid of this one, too...
|
||||||
|
|
||||||
// CIDs
|
// CIDs
|
||||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||||
@ -64,7 +65,8 @@ static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|||||||
nsXULWindow::nsXULWindow() : mChromeTreeOwner(nsnull),
|
nsXULWindow::nsXULWindow() : mChromeTreeOwner(nsnull),
|
||||||
mContentTreeOwner(nsnull), mPrimaryContentTreeOwner(nsnull),
|
mContentTreeOwner(nsnull), mPrimaryContentTreeOwner(nsnull),
|
||||||
mContinueModalLoop(PR_FALSE), mChromeLoaded(PR_FALSE),
|
mContinueModalLoop(PR_FALSE), mChromeLoaded(PR_FALSE),
|
||||||
mShowAfterLoad(PR_FALSE), mIntrinsicallySized(PR_FALSE)
|
mShowAfterLoad(PR_FALSE), mIntrinsicallySized(PR_FALSE),
|
||||||
|
mZlevel(nsIXULWindow::normalZ)
|
||||||
|
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
@ -121,6 +123,13 @@ NS_IMETHODIMP nsXULWindow::GetDocShell(nsIDocShell** aDocShell)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsXULWindow::GetZlevel(PRUint32 *outLevel)
|
||||||
|
{
|
||||||
|
// report our known zlevel, or be on top if currently modal
|
||||||
|
*outLevel = mContinueModalLoop ? nsIXULWindow::highestZ : mZlevel;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULWindow::SetIntrinsicallySized(PRBool aIntrinsicallySized)
|
NS_IMETHODIMP nsXULWindow::SetIntrinsicallySized(PRBool aIntrinsicallySized)
|
||||||
{
|
{
|
||||||
mIntrinsicallySized = aIntrinsicallySized;
|
mIntrinsicallySized = aIntrinsicallySized;
|
||||||
@ -426,6 +435,7 @@ NS_IMETHODIMP nsXULWindow::Destroy()
|
|||||||
mChromeTreeOwner->XULWindow(nsnull);
|
mChromeTreeOwner->XULWindow(nsnull);
|
||||||
NS_RELEASE(mChromeTreeOwner);
|
NS_RELEASE(mChromeTreeOwner);
|
||||||
}
|
}
|
||||||
|
mWindow->SetClientData(0); // nsWebShellWindow hackery
|
||||||
mWindow = nsnull;
|
mWindow = nsnull;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -1161,6 +1171,82 @@ void nsXULWindow::EnableParent(PRBool aEnable)
|
|||||||
parentWidget->Enable(aEnable);
|
parentWidget->Enable(aEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constrain the window to its proper z-level
|
||||||
|
PRBool nsXULWindow::ConstrainToZLevel(
|
||||||
|
PRBool aImmediate,
|
||||||
|
nsWindowZ *aPlacement,
|
||||||
|
nsIWidget *aReqBelow,
|
||||||
|
nsIWidget **aActualBelow) {
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Do we have a parent window? This means our z-order is already constrained,
|
||||||
|
since we're a dependent window. Our window list isn't hierarchical,
|
||||||
|
so we can't properly calculate placement for such a window.
|
||||||
|
Should we just abort? */
|
||||||
|
nsCOMPtr<nsIBaseWindow> parentWindow = do_QueryReferent(mParentWindow);
|
||||||
|
if (parentWindow)
|
||||||
|
return PR_FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nsCOMPtr<nsIWindowMediator> mediator(do_GetService(kWindowMediatorCID));
|
||||||
|
if(!mediator)
|
||||||
|
return PR_FALSE;
|
||||||
|
|
||||||
|
PRBool altered;
|
||||||
|
PRUint32 position,
|
||||||
|
newPosition;
|
||||||
|
nsIXULWindow *us = NS_STATIC_CAST(nsIXULWindow *, this);
|
||||||
|
|
||||||
|
altered = PR_FALSE;
|
||||||
|
|
||||||
|
// translate from nsIWindowMediator to nsGUIEvent constants
|
||||||
|
position = nsIWindowMediator::zLevelTop;
|
||||||
|
if (*aPlacement == nsWindowZBottom)
|
||||||
|
position = nsIWindowMediator::zLevelBottom;
|
||||||
|
else if (*aPlacement == nsWindowZRelative)
|
||||||
|
position = nsIWindowMediator::zLevelBelow;
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(mediator->CalculateZPosition(us, position, aReqBelow,
|
||||||
|
&newPosition, aActualBelow, &altered))) {
|
||||||
|
if (altered) {
|
||||||
|
if (newPosition == nsIWindowMediator::zLevelTop)
|
||||||
|
*aPlacement = nsWindowZTop;
|
||||||
|
else if (newPosition == nsIWindowMediator::zLevelBottom)
|
||||||
|
*aPlacement = nsWindowZBottom;
|
||||||
|
else
|
||||||
|
*aPlacement = nsWindowZRelative;
|
||||||
|
|
||||||
|
if (aImmediate) {
|
||||||
|
nsCOMPtr<nsIBaseWindow> ourBase = do_QueryInterface(NS_STATIC_CAST(nsIXULWindow *,this));
|
||||||
|
if (ourBase) {
|
||||||
|
nsCOMPtr<nsIWidget> ourWidget;
|
||||||
|
ourBase->GetMainWidget(getter_AddRefs(ourWidget));
|
||||||
|
ourWidget->PlaceBehind(*aActualBelow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (CalculateZPosition can tell us to be below nothing, because it tries
|
||||||
|
not to change something it doesn't recognize. A request to verify
|
||||||
|
being below an unrecognized window, then, is treated as a request
|
||||||
|
to come to the top (below null) */
|
||||||
|
nsCOMPtr<nsIXULWindow> windowAbove;
|
||||||
|
if (newPosition == nsIWindowMediator::zLevelBelow && *aActualBelow) {
|
||||||
|
void *data;
|
||||||
|
(*aActualBelow)->GetClientData(data);
|
||||||
|
if (data) {
|
||||||
|
nsWebShellWindow *win;
|
||||||
|
win = NS_REINTERPRET_CAST(nsWebShellWindow *, data);
|
||||||
|
windowAbove = do_QueryInterface(NS_STATIC_CAST(nsIWebShellWindow *,win));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mediator->SetZPosition(us, newPosition, windowAbove);
|
||||||
|
}
|
||||||
|
|
||||||
|
return altered;
|
||||||
|
}
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsXULWindow: Accessors
|
// nsXULWindow: Accessors
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|||||||
@ -90,6 +90,8 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void EnableParent(PRBool aEnable);
|
void EnableParent(PRBool aEnable);
|
||||||
|
PRBool ConstrainToZLevel(PRBool aImmediate, nsWindowZ *aPlacement,
|
||||||
|
nsIWidget *aReqBelow, nsIWidget **aActualBelow);
|
||||||
|
|
||||||
nsChromeTreeOwner* mChromeTreeOwner;
|
nsChromeTreeOwner* mChromeTreeOwner;
|
||||||
nsContentTreeOwner* mContentTreeOwner;
|
nsContentTreeOwner* mContentTreeOwner;
|
||||||
@ -104,6 +106,7 @@ protected:
|
|||||||
PRBool mChromeLoaded; // True when chrome has loaded
|
PRBool mChromeLoaded; // True when chrome has loaded
|
||||||
PRBool mShowAfterLoad;
|
PRBool mShowAfterLoad;
|
||||||
PRBool mIntrinsicallySized;
|
PRBool mIntrinsicallySized;
|
||||||
|
unsigned long mZlevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
// nsContentShellInfo
|
// nsContentShellInfo
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user