Bug 282812. Fix GTK1 popup widget positioning by invalidating the cached positions of all child widgets, even those that aren't directly connected in the nsIWidget hierarchy. r+sr=blizzard,a=asa

This commit is contained in:
roc+%cs.cmu.edu 2005-06-16 02:53:00 +00:00
parent ba5c3a9060
commit a43f77a450
2 changed files with 43 additions and 2 deletions

View File

@ -249,6 +249,7 @@ nsWindow::nsWindow()
mLastDragMotionWindow = NULL;
mBlockMozAreaFocusIn = PR_FALSE;
mLastGrabFailed = PR_TRUE;
mHasAnonymousChildren = PR_FALSE;
mDragMotionWidget = 0;
mDragMotionContext = 0;
mDragMotionX = 0;
@ -416,6 +417,35 @@ void nsWindow::InvalidateWindowPos(void)
kid->GetBounds(kidBounds);
kid->Move(kidBounds.x, kidBounds.y);
}
// The following code was shamelessly copied from nsWindow::DestroyNativeChildren
// If this wasn't GTK1, I'd refactor it to share code with that function
if (mSuperWin && mHasAnonymousChildren) {
Display *display = GDK_DISPLAY();
Window window = GDK_WINDOW_XWINDOW(mSuperWin->bin_window);
if (window && !((GdkWindowPrivate *)mSuperWin->bin_window)->destroyed)
{
Window root_return;
Window parent_return;
Window *children_return = NULL;
unsigned int nchildren_return = 0;
// get a list of children for this window
XQueryTree(display, window, &root_return, &parent_return,
&children_return, &nchildren_return);
// walk the list of children
for (unsigned int i=0; i < nchildren_return; i++)
{
Window child_window = children_return[i];
nsWindow *thisWindow = GetnsWindowFromXWindow(child_window);
if (thisWindow)
{
nsRect kidBounds;
thisWindow->GetBounds(kidBounds);
thisWindow->Move(kidBounds.x, kidBounds.y);
}
}
}
}
}
void
@ -1963,10 +1993,16 @@ NS_METHOD nsWindow::CreateNative(GtkObject *parentWidget)
}
}
else {
if (superwin)
if (superwin) {
mSuperWin = gdk_superwin_new(superwin->bin_window,
mBounds.x, mBounds.y,
mBounds.width, mBounds.height);
nsWindow* realParent =
NS_STATIC_CAST(nsWindow*, gtk_object_get_data(GTK_OBJECT(superwin), "nsWindow"));
if (realParent && !mParent) {
realParent->mHasAnonymousChildren = PR_TRUE;
}
}
}
break;

View File

@ -409,7 +409,13 @@ private:
PRPackedBool mLeavePending;
PRPackedBool mRestoreFocus;
/**
* Whether this widget has child widgets that are not linked into
* its explicit nsIWidget child list
*/
PRPackedBool mHasAnonymousChildren;
PRPackedBool mIsTranslucent;
// This bitmap tracks which pixels are transparent. We don't support
// full translucency at this time; each pixel is either fully opaque
// or fully transparent.
@ -418,7 +424,6 @@ private:
void DestroyNativeChildren(void);
GtkWindow *mTransientParent;
};
//