From 849abb5f16edd8793ac74bbbd9d90faa53e4fbdc Mon Sep 17 00:00:00 2001 From: "blizzard%redhat.com" Date: Thu, 27 May 2004 20:18:59 +0000 Subject: [PATCH] Bug #209342. Browser will come up at position 0,0. git-svn-id: svn://10.0.0.236/trunk@157029 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/gtk2/nsCommonWidget.cpp | 3 +++ mozilla/widget/src/gtk2/nsCommonWidget.h | 3 +++ mozilla/widget/src/gtk2/nsWindow.cpp | 29 ++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mozilla/widget/src/gtk2/nsCommonWidget.cpp b/mozilla/widget/src/gtk2/nsCommonWidget.cpp index 888d04c8b33..c33b089033c 100644 --- a/mozilla/widget/src/gtk2/nsCommonWidget.cpp +++ b/mozilla/widget/src/gtk2/nsCommonWidget.cpp @@ -49,6 +49,7 @@ nsCommonWidget::nsCommonWidget() mNeedsShow = PR_FALSE; mEnabled = PR_TRUE; mCreated = PR_FALSE; + mPlaced = PR_FALSE; mPreferredWidth = 0; mPreferredHeight = 0; @@ -330,6 +331,8 @@ nsCommonWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, mBounds.width = aWidth; mBounds.height = aHeight; + mPlaced = PR_TRUE; + if (!mCreated) return NS_OK; diff --git a/mozilla/widget/src/gtk2/nsCommonWidget.h b/mozilla/widget/src/gtk2/nsCommonWidget.h index 4de9cd95467..a02121b3edb 100644 --- a/mozilla/widget/src/gtk2/nsCommonWidget.h +++ b/mozilla/widget/src/gtk2/nsCommonWidget.h @@ -137,6 +137,9 @@ protected: PRBool mEnabled; // has the native window for this been created yet? PRBool mCreated; + // Has anyone set an x/y location for this widget yet? Toplevels + // shouldn't be automatically set to 0,0 for first show. + PRBool mPlaced; // Preferred sizes PRUint32 mPreferredWidth; diff --git a/mozilla/widget/src/gtk2/nsWindow.cpp b/mozilla/widget/src/gtk2/nsWindow.cpp index 14a1caa69e3..35b931abd96 100644 --- a/mozilla/widget/src/gtk2/nsWindow.cpp +++ b/mozilla/widget/src/gtk2/nsWindow.cpp @@ -465,6 +465,8 @@ nsWindow::Move(PRInt32 aX, PRInt32 aY) LOG(("nsWindow::Move [%p] %d %d\n", (void *)this, aX, aY)); + mPlaced = PR_TRUE; + // Since a popup window's x/y coordinates are in relation to to // the parent, the parent might have moved so we always move a // popup window. @@ -487,7 +489,12 @@ nsWindow::Move(PRInt32 aX, PRInt32 aY) gtk_window_move(GTK_WINDOW(mShell), newrect.x, newrect.y); } else { - gtk_window_move(GTK_WINDOW(mShell), aX, aY); + // We only move the toplevel window if someone has + // actually placed the window somewhere. If no placement + // has taken place, we just let the window manager Do The + // Right Thing. + if (mPlaced) + gtk_window_move(GTK_WINDOW(mShell), aX, aY); } } else if (mDrawingarea) { @@ -1189,6 +1196,18 @@ nsWindow::OnConfigureEvent(GtkWidget *aWidget, GdkEventConfigure *aEvent) mBounds.y == aEvent->y) return FALSE; + // Toplevel windows need to have their bounds set so that we can + // keep track of our location. It's not often that the x,y is set + // by the layout engine. Width and height are set elsewhere. + if (mIsTopLevel) { + mPlaced = PR_TRUE; + // Need to translate this into the right coordinates + nsRect oldrect, newrect; + WidgetToScreen(oldrect, newrect); + mBounds.x = newrect.x; + mBounds.y = newrect.y; + } + nsGUIEvent event(NS_MOVE, this); event.point.x = aEvent->x; @@ -2336,7 +2355,13 @@ nsWindow::NativeResize(PRInt32 aX, PRInt32 aY, gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight); } else { - gtk_window_move(GTK_WINDOW(mShell), aX, aY); + // We only move the toplevel window if someone has + // actually placed the window somewhere. If no placement + // has taken place, we just let the window manager Do The + // Right Thing. + if (mPlaced) + gtk_window_move(GTK_WINDOW(mShell), aX, aY); + gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight); moz_drawingarea_resize(mDrawingarea, aWidth, aHeight); }