Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 29407)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 29410)
@@ -173,8 +173,8 @@
         return;
 
-    /* Storing new mouse 'integrated' value: */
+    /* Store new mouse 'integrated' state value: */
     uisession()->setMouseIntegrated(fEnabled);
 
-    /* We should capture/release mouse depending on mouse 'integrated' state: */
+    /* We should capture/release mouse depending on mouse 'integrated' state value: */
     captureMouse(!uisession()->isMouseIntegrated(), false /* emit signal? */);
 
@@ -182,7 +182,7 @@
     updateMouseCursorShape();
 
-    /* Also we switch guest mouse to the absolute mode: */
-    if (uisession()->isMouseIntegrated() &&
-        uisession()->isMouseSupportsAbsolute())
+    /* If mouse is integrated and supports absolute pointing
+     * we should switch guest mouse to the absolute mode: */
+    if (uisession()->isMouseIntegrated() && uisession()->isMouseSupportsAbsolute())
     {
         CMouse mouse = session().GetConsole().GetMouse();
@@ -221,4 +221,7 @@
     , m_fAccelerate2DVideo(bAccelerate2DVideo)
 #endif /* VBOX_WITH_VIDEOHWACCEL */
+#ifdef Q_WS_WIN
+    , m_fItsMeWhoCapturedMouse(false)
+#endif
 #ifdef Q_WS_MAC
     , m_darwinKeyModifiers(0)
@@ -423,12 +426,11 @@
 }
 
-#ifdef Q_WS_WIN32
-/* This method is actually required only because
- * under win-host we do not really grab the mouse
- * in case of capturing it. I have to check if its
- * really need, may be just grabMouse() will be enought: */
+#ifdef Q_WS_WIN
+/* This method is actually required only because under win-host
+ * we do not really grab the mouse in case of capturing it.
+ * I have to check if its really need, may be just grabMouse() will be enought: */
 void UIMachineView::updateMouseCursorClipping()
 {
-    if (uisession()->isMouseCaptured())
+    if (m_fItsMeWhoCapturedMouse)
     {
         QRect r = viewport()->rect();
@@ -436,8 +438,4 @@
         RECT rect = { r.left(), r.top(), r.right() + 1, r.bottom() + 1 };
         ::ClipCursor(&rect);
-    }
-    else
-    {
-        ::ClipCursor(NULL);
     }
 }
@@ -831,7 +829,4 @@
             /* Update mouse cursor shape: */
             updateMouseCursorShape();
-#ifdef Q_WS_WIN32
-            updateMouseCursorClipping();
-#endif
 
             /* May be we have to restrict minimum size? */
@@ -1304,16 +1299,15 @@
 void UIMachineView::sltMouseCapturedStatusChanged()
 {
-#ifndef Q_WS_WIN32
+    /* If mouse 'captured' state value changed to 'false': */
     if (!uisession()->isMouseCaptured())
     {
         /* Releasing grabbed mouse from that window: */
+#ifdef Q_WS_WIN
+        m_fItsMeWhoCapturedMouse = false;
+        ::ClipCursor(NULL);
+#else
         viewport()->releaseMouse();
-    }
-#endif
-
-#ifdef Q_WS_WIN32
-    /* Update mouse clipping: */
-    updateMouseCursorClipping();
-#endif
+#endif /* Q_WS_WIN */
+    }
 
     /* Update mouse cursor shape: */
@@ -2607,4 +2601,7 @@
         return;
 
+    /* Store new mouse 'captured' state value: */
+    uisession()->setMouseCaptured(fCapture);
+
     if (fCapture)
     {
@@ -2612,7 +2609,11 @@
         m_capturedMousePos = QCursor::pos();
 #ifdef Q_WS_WIN32
+        /* Remember what this window captured mouse: */
+        m_fItsMeWhoCapturedMouse = true;
         /* Move the mouse to the center of the visible area: */
         m_lastMousePos = mapToGlobal(visibleRegion().boundingRect().center());
         QCursor::setPos(m_lastMousePos);
+        /* Update mouse clipping: */
+        updateMouseCursorClipping();
 #elif defined (Q_WS_MAC)
         /* Move the mouse to the center of the visible area: */
@@ -2636,7 +2637,4 @@
     CMouse mouse = session().GetConsole().GetMouse();
     mouse.PutMouseEvent(0, 0, 0, 0, 0);
-
-    /* Storing new mouse 'captured' value: */
-    uisession()->setMouseCaptured(fCapture);
 
     /* Emit signal if required: */
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 29407)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 29410)
@@ -243,9 +243,12 @@
     bool m_bIsHostkeyInCapture : 1;
     bool m_bIsMachineWindowResizeIgnored : 1;
-    bool m_fPassCAD;
+    bool m_fPassCAD : 1;
 #ifdef VBOX_WITH_VIDEOHWACCEL
     bool m_fAccelerate2DVideo;
 #endif
 
+#ifdef Q_WS_WIN
+    bool m_fItsMeWhoCapturedMouse;
+#endif /* Q_WS_WIN */
 #ifdef Q_WS_MAC
     /** The current modifier key mask. Used to figure out which modifier
