+ const wxRegion& updateRegion = win->GetUpdateRegion();
+ if ( win->GetTLW()->IsPainting() && !updateRegion.IsEmpty() )
+ {
+ r.Intersect(updateRegion.AsRect());
+ // parent TLW will flip the entire surface when painting is done
+ m_shouldFlip = false;
+
+ wxCHECK_RET( !r.IsEmpty(), _T("invalid painting rectangle") );
+ }
+ else
+ {
+ // One of two things happened:
+ // (1) the TLW is not being painted by PaintWindow() now; or
+ // (2) we're drawing on some window other than the one that is
+ // currently painted on by PaintWindow()
+ // In either case, we need to flip the surface when we're done
+ // painting and we don't have to use updateRegion for clipping.
+ // OTOH, if the window is (partially) hidden by being
+ // out of its parent's area, we must clip the surface accordingly.
+ r.Intersect(GetUncoveredWindowArea(win));
+ if ( r.IsEmpty() )
+ {
+ // the window is fully hidden, we can't paint on it, so create
+ // a dummy surface as above
+ surface = CreateDummySurface(win, &rectOrig);
+ m_shouldFlip = false;
+ }
+ else
+ {
+ DFBRectangle dfbrect = { r.x, r.y, r.width, r.height };
+ surface = win->GetDfbSurface()->GetSubSurface(&dfbrect);
+
+ // paint the results immediately
+ m_shouldFlip = true;
+ }
+ }