b=793501 invalidate new regions of even toplevel resized windows r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 23 Oct 2012 11:40:50 +1300
changeset 111237 8da9c24417d07c87a8006a170efc2bfae0825512
parent 111236 1c2eaa7e3edd494847197f380c9d3c8e3acde309
child 111238 a0158d3707850441cbbd3156395390380d90ef36
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersroc
bugs793501
milestone19.0a1
b=793501 invalidate new regions of even toplevel resized windows r=roc
widget/gtk2/nsWindow.cpp
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -2372,27 +2372,41 @@ nsWindow::OnContainerUnrealize()
 
 void
 nsWindow::OnSizeAllocate(GtkAllocation *aAllocation)
 {
     LOG(("size_allocate [%p] %d %d %d %d\n",
          (void *)this, aAllocation->x, aAllocation->y,
          aAllocation->width, aAllocation->height));
 
-    nsIntRect rect(aAllocation->x, aAllocation->y,
-                   aAllocation->width, aAllocation->height);
-
-    mBounds.width = rect.width;
-    mBounds.height = rect.height;
+    nsIntSize size(aAllocation->width, aAllocation->height);
+    if (mBounds.Size() == size)
+        return;
+
+    // Invalidate the new part of the window now for the pending paint to
+    // minimize background flashes (GDK does not do this for external resizes
+    // of toplevels.)
+    if (mBounds.width < size.width) {
+        GdkRectangle rect =
+            { mBounds.width, 0, size.width - mBounds.width, size.height };
+        gdk_window_invalidate_rect(mGdkWindow, &rect, FALSE);
+    }
+    if (mBounds.height < size.height) {
+        GdkRectangle rect =
+            { 0, mBounds.height, size.width, size.height - mBounds.height };
+        gdk_window_invalidate_rect(mGdkWindow, &rect, FALSE);
+    }
+
+    mBounds.SizeTo(size);
 
     if (!mGdkWindow)
         return;
 
     if (mWidgetListener)
-        mWidgetListener->WindowResized(this, rect.width, rect.height);
+        mWidgetListener->WindowResized(this, size.width, size.height);
 }
 
 void
 nsWindow::OnDeleteEvent()
 {
     if (mWidgetListener)
         mWidgetListener->RequestWindowClose(this);
 }