Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h	(revision 22851)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h	(revision 22852)
@@ -573,5 +573,4 @@
 
     const VBoxVHWADirtyRect & getDirtyRect() { return mUpdateMem2TexRect; }
-
 private:
     void doSetRectValuesInternal(const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisTargRect);
@@ -1062,5 +1061,13 @@
     const QRect & vboxViewport() const {return mViewport;}
 
-    bool performDisplay(bool bForce) { return mDisplay.performDisplay(bForce); }
+    bool performDisplayAndSwap(bool bForce)
+    {
+        bForce = mDisplay.performDisplay(bForce | mRepaintNeeded);
+        if(bForce)
+        {
+            swapBuffers();
+        }
+        return bForce;
+    }
 protected:
 
@@ -1150,4 +1157,7 @@
     ulong  mPixelFormat;
     bool   mUsesGuestVRAM;
+
+    bool mRepaintNeeded;
+
 //    bool   mbVGASurfCreated;
     QRect mViewport;
@@ -1259,6 +1269,5 @@
 #else
             makeCurrent();
-            mpOverlayWidget->performDisplay(false);
-            mpOverlayWidget->swapBuffers();
+            mpOverlayWidget->performDisplayAndSwap(false);
 #endif
         }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 22851)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 22852)
@@ -2941,4 +2941,5 @@
     mPixelFormat(0),
     mUsesGuestVRAM(false),
+    mRepaintNeeded(false),
 //    mbVGASurfCreated(false),
     mView(aView),
@@ -3524,4 +3525,7 @@
         }
     }
+
+    /* just in case we destroy a visible overlay sorface */
+    mRepaintNeeded = true;
 
     void * test = mSurfHandleTable.remove(pCmd->u.in.hSurf);
@@ -3619,4 +3623,5 @@
     pTargSurf->getComplexList()->setCurrentVisible(pTargSurf);
 
+    mRepaintNeeded = true;
 #ifdef DEBUG
     pCurrSurf->cFlipsCurr++;
@@ -3794,4 +3799,6 @@
     }
 
+    mRepaintNeeded = true;
+
     return VINF_SUCCESS;
 }
@@ -3812,4 +3819,20 @@
     QPoint pos(pCmd->u.in.xPos, pCmd->u.in.yPos);
 
+#ifdef DEBUG_misha
+    Assert(pDstSurf == mDisplay.getVGA());
+    Assert(mDisplay.getVGA() == mDisplay.getPrimary());
+#endif
+    if(pSrcSurf->getComplexList()->current() != NULL)
+    {
+        Assert(pDstSurf);
+        if(pDstSurf != mDisplay.getPrimary())
+        {
+            mDisplay.updateVGA(pDstSurf);
+            pDstSurf->getComplexList()->setCurrentVisible(pDstSurf);
+        }
+    }
+
+    mRepaintNeeded = true;
+
     for (SurfList::const_iterator it = surfaces.begin();
              it != surfaces.end(); ++ it)
@@ -3829,4 +3852,6 @@
 
     vboxCheckUpdateAddress (pSurf, pCmd->u.in.offSurface);
+
+    mRepaintNeeded = true;
 
 //    VBOXVHWA_CKEY_COLORSPACE
@@ -5474,4 +5499,5 @@
             VBOXVHWACMD_SURF_UNLOCK * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_UNLOCK);
             pCmd->rc = vhwaSurfaceUnlock(pBody);
+            /* mNeedOverlayRepaint is set inside the vhwaSurfaceUnlock */
         } break;
         case VBOXVHWACMD_TYPE_SURF_BLT:
@@ -5515,4 +5541,5 @@
             VBOXVHWACMD_SURF_COLORKEY_SET * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_COLORKEY_SET);
             pCmd->rc = mpOverlayWidget->vhwaSurfaceColorkeySet(pBody);
+            mNeedOverlayRepaint = true;
         } break;
         case VBOXVHWACMD_TYPE_QUERY_INFO1:
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 22851)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 22852)
@@ -130,7 +130,5 @@
     }
 
-    pw->performDisplay(true);
-
-    pw->swapBuffers();
+    pw->performDisplayAndSwap(true);
 }
 
