b=601545 use mNeedsResize/mNeedsMove on toplevel windows to make mPlaced unnecessary r+a=roc
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 21 Dec 2010 15:45:58 +1300
changeset 59547 71d2d1c6d12df860ea8e31a04a1bcd29ce242f34
parent 59546 ec338170e5f7379f03d32d7d97b38dadc149b73e
child 59548 944010571e9d688ba3e203c46021234192bdf73f
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs601545
milestone2.0b9pre
b=601545 use mNeedsResize/mNeedsMove on toplevel windows to make mPlaced unnecessary r+a=roc
widget/src/gtk2/nsWindow.cpp
widget/src/gtk2/nsWindow.h
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -387,17 +387,16 @@ nsWindow::nsWindow()
     mIsDestroyed      = PR_FALSE;
     mNeedsResize      = PR_FALSE;
     mNeedsMove        = PR_FALSE;
     mListenForResizes = PR_FALSE;
     mIsShown          = PR_FALSE;
     mNeedsShow        = PR_FALSE;
     mEnabled          = PR_TRUE;
     mCreated          = PR_FALSE;
-    mPlaced           = PR_FALSE;
 
     mContainer           = nsnull;
     mGdkWindow           = nsnull;
     mShell               = nsnull;
     mWindowGroup         = nsnull;
     mHasMappedToplevel   = PR_FALSE;
     mIsFullyObscured     = PR_FALSE;
     mRetryPointerGrab    = PR_FALSE;
@@ -1151,17 +1150,16 @@ NS_IMETHODIMP
 nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
                        PRBool aRepaint)
 {
     mBounds.x = aX;
     mBounds.y = aY;
     mBounds.SizeTo(GetSafeWindowSize(nsIntSize(aWidth, aHeight)));
 
     mNeedsMove = PR_TRUE;
-    mPlaced = PR_TRUE;
 
     if (!mCreated)
         return NS_OK;
 
     // There are several cases here that we need to handle, based on a
     // matrix of the visibility of the widget, the sanity of this resize
     // and whether or not the widget was previously sane.
 
@@ -1236,33 +1234,33 @@ nsWindow::Move(PRInt32 aX, PRInt32 aY)
     LOG(("nsWindow::Move [%p] %d %d\n", (void *)this,
          aX, aY));
 
     if (mWindowType == eWindowType_toplevel ||
         mWindowType == eWindowType_dialog) {
         SetSizeMode(nsSizeMode_Normal);
     }
 
-    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.
     if (aX == mBounds.x && aY == mBounds.y &&
         mWindowType != eWindowType_popup)
         return NS_OK;
 
     // XXX Should we do some AreBoundsSane check here?
 
     mBounds.x = aX;
     mBounds.y = aY;
 
     if (!mCreated)
         return NS_OK;
 
+    mNeedsMove = PR_FALSE;
+
     if (mIsTopLevel) {
         gtk_window_move(GTK_WINDOW(mShell), aX, aY);
     }
     else if (mGdkWindow) {
         gdk_window_move(mGdkWindow, aX, aY);
     }
 
     return NS_OK;
@@ -2306,17 +2304,16 @@ nsWindow::OnConfigureEvent(GtkWidget *aW
         check_for_rollup(aEvent->window, 0, 0, PR_FALSE, PR_TRUE);
     }
 
     // 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.
     nsIntPoint pnt(aEvent->x, aEvent->y);
     if (mIsTopLevel) {
-        mPlaced = PR_TRUE;
         // Need to translate this into the right coordinates
         mBounds.MoveTo(WidgetToScreenOffset());
         pnt = mBounds.TopLeft();
     }
 
     nsGUIEvent event(PR_TRUE, NS_MOVE, this);
 
     event.refPoint = pnt;
@@ -3772,21 +3769,23 @@ nsWindow::Create(nsIWidget        *aPare
 
     // and do our common creation
     CommonCreate(aParent, listenForResizes);
 
     // save our bounds
     mBounds = aRect;
     if (mWindowType != eWindowType_child &&
         mWindowType != eWindowType_plugin) {
-        // The window manager might place us. Indicate that if we're
-        // shown, we want to go through
-        // nsWindow::NativeResize(x,y,w,h) to maybe set our own
-        // position.
-        mNeedsMove = PR_TRUE;
+        // We only move a 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.
+        //
+        // Indicate that if we're shown, we at least need to have our size set.
+        // If we get explicitly moved, the position will also be set.
+        mNeedsResize = PR_TRUE;
     }
 
     // figure out our parent window
     GtkWidget      *parentMozContainer = nsnull;
     GtkContainer   *parentGtkContainer = nsnull;
     GdkWindow      *parentGdkWindow = nsnull;
     GtkWindow      *topLevelParent = nsnull;
 
@@ -4306,23 +4305,17 @@ nsWindow::NativeResize(PRInt32 aX, PRInt
     mNeedsMove = PR_FALSE;
 
     LOG(("nsWindow::NativeResize [%p] %d %d %d %d\n", (void *)this,
          aX, aY, aWidth, aHeight));
 
     ResizeTransparencyBitmap(aWidth, aHeight);
 
     if (mIsTopLevel) {
-        // 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_move(GTK_WINDOW(mShell), aX, aY);
         gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight);
     }
     else if (mContainer) {
         GtkAllocation allocation;
         allocation.x = aX;
         allocation.y = aY;
         allocation.width = aWidth;
         allocation.height = aHeight;
--- a/widget/src/gtk2/nsWindow.h
+++ b/widget/src/gtk2/nsWindow.h
@@ -368,19 +368,16 @@ protected:
     PRPackedBool        mListenForResizes;
     // This flag tracks if we're hidden or shown.
     PRPackedBool        mIsShown;
     PRPackedBool        mNeedsShow;
     // is this widget enabled?
     PRPackedBool        mEnabled;
     // has the native window for this been created yet?
     PRPackedBool        mCreated;
-    // Has anyone set an x/y location for this widget yet? Toplevels
-    // shouldn't be automatically set to 0,0 for first show.
-    PRPackedBool        mPlaced;
 
 private:
     void               DestroyChildWindows();
     void               GetToplevelWidget(GtkWidget **aWidget);
     GtkWidget         *GetMozContainerWidget();
     nsWindow          *GetContainerWindow();
     void               SetUrgencyHint(GtkWidget *top_window, PRBool state);
     void              *SetupPluginPort(void);