From: VMware, Inc <> Date: Wed, 26 Jan 2011 01:35:36 +0000 (-0800) Subject: Prevent unexpected guest UI DragEnter X-Git-Tag: stable-8.8.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f39d7b636bb4a9bee947eebdf64a92c48d59a83e;p=thirdparty%2Fopen-vm-tools.git Prevent unexpected guest UI DragEnter 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 --- diff --git a/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnD.hh b/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnD.hh index 3812364bc..07d3fac63 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnD.hh +++ b/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnD.hh @@ -102,6 +102,7 @@ public: void SetDnDAllowed(bool isDnDAllowed) { mDnDAllowed = isDnDAllowed;} void VmxDnDVersionChanged(uint32 version); + bool IsDragEnterAllowed(void); private: void OnRpcSrcDragBegin(uint32 sessionId, diff --git a/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDDest.cc b/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDDest.cc index 111f3dc27..69293a6b3 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDDest.cc +++ b/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDDest.cc @@ -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() || diff --git a/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDMgr.cc b/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDMgr.cc index 3a86f0a0e..eb934812a 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDMgr.cc +++ b/open-vm-tools/services/plugins/dndcp/dndGuest/guestDnDMgr.cc @@ -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. *