]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Prevent unexpected guest UI DragEnter
authorVMware, Inc <>
Wed, 26 Jan 2011 01:35:36 +0000 (17:35 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Wed, 26 Jan 2011 01:35:36 +0000 (17:35 -0800)
In some cases there may be some unexpected UI DragEnter after DnD
finished, which may disturb our state machine. With this change, guest
DragEnter is not allowed within 0.5 second after each DnD.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/dndcp/dndGuest/guestDnD.hh
open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDDest.cc
open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDMgr.cc

index 3812364bc4f04fcdf4a2dd7cffc28d0ebb238c30..07d3fac63251dab6a18187a71595e23b9efbf1ff 100644 (file)
@@ -102,6 +102,7 @@ public:
    void SetDnDAllowed(bool isDnDAllowed)
    { mDnDAllowed = isDnDAllowed;}
    void VmxDnDVersionChanged(uint32 version);
+   bool IsDragEnterAllowed(void);
 
 private:
    void OnRpcSrcDragBegin(uint32 sessionId,
index 111f3dc27cd08155f224e2e2d38e3c0e39abd7db..69293a6b36d4e56196104d89ae234b84c318fb22 100644 (file)
@@ -75,6 +75,11 @@ GuestDnDDest::~GuestDnDDest(void)
 void
 GuestDnDDest::UIDragEnter(const CPClipboard *clip)
 {
+   if (!mMgr->IsDragEnterAllowed()) {
+      Debug("%s: not allowed.\n", __FUNCTION__);
+      return;
+   }
+
    Debug("%s: entering.\n", __FUNCTION__);
 
    if (GUEST_DND_DEST_DRAGGING == mMgr->GetState() ||
index 3a86f0a0e640655f12e813b0e3b14385e7c7edde..eb934812a7b13e959c94ff09912aec02e376d14d 100644 (file)
@@ -558,6 +558,25 @@ GuestDnDMgr::SetState(GUEST_DND_STATE state)
 }
 
 
+/**
+ * Check if DragEnter is allowed.
+ *
+ * @return true if DragEnter is allowed, false otherwise.
+ */
+
+bool
+GuestDnDMgr::IsDragEnterAllowed(void)
+{
+   /*
+    * Right after any DnD is finished, there may be some unexpected
+    * DragEnter from UI, and may disturb our state machine. The
+    * mHideDetWndTimer will only be valid for 0.5 second after each
+    * DnD, and during this time UI DragEnter is not allowed.
+    */
+   return mHideDetWndTimer == NULL;
+}
+
+
 /**
  * Handle version change in VMX.
  *