Huw Davies : ole32: Move end-of-drag handling to a separate function.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Feb 23 11:24:21 CST 2016


Module: wine
Branch: master
Commit: b8fcc4a20ad2b4c830dadd779d93a79a8ddbe425
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b8fcc4a20ad2b4c830dadd779d93a79a8ddbe425

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Feb 23 10:09:31 2016 +0000

ole32: Move end-of-drag handling to a separate function.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/ole2.c | 85 ++++++++++++++++++++++---------------------------------
 1 file changed, 34 insertions(+), 51 deletions(-)

diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c
index fdfe16f..07c8e9d 100644
--- a/dlls/ole32/ole2.c
+++ b/dlls/ole32/ole2.c
@@ -2211,6 +2211,38 @@ static void drag_enter( TrackerWindowInfo *info, HWND new_target )
     }
 }
 
+static void drag_end( TrackerWindowInfo *info )
+{
+    HRESULT hr;
+
+    info->trackingDone = TRUE;
+    ReleaseCapture();
+
+    if (info->curDragTarget)
+    {
+        if (info->returnValue == DRAGDROP_S_DROP &&
+            *info->pdwEffect != DROPEFFECT_NONE)
+        {
+            *info->pdwEffect = info->dwOKEffect;
+            hr = IDropTarget_Drop( info->curDragTarget, info->dataObject, info->dwKeyState,
+                                   info->curMousePos, info->pdwEffect );
+            *info->pdwEffect &= info->dwOKEffect;
+
+            if (FAILED( hr ))
+                info->returnValue = hr;
+        }
+        else
+        {
+            IDropTarget_DragLeave( info->curDragTarget );
+            *info->pdwEffect = DROPEFFECT_NONE;
+        }
+        IDropTarget_Release( info->curDragTarget );
+        info->curDragTarget = NULL;
+    }
+    else
+        *info->pdwEffect = DROPEFFECT_NONE;
+}
+
 static HRESULT give_feedback( TrackerWindowInfo *info )
 {
     HRESULT hr;
@@ -2253,7 +2285,6 @@ static HRESULT give_feedback( TrackerWindowInfo *info )
 static void OLEDD_TrackStateChange(TrackerWindowInfo* trackerInfo)
 {
   HWND   hwndNewTarget = 0;
-  HRESULT  hr = S_OK;
   POINT pt;
 
   /*
@@ -2304,56 +2335,8 @@ static void OLEDD_TrackStateChange(TrackerWindowInfo* trackerInfo)
    * All the return valued will stop the operation except the S_OK
    * return value.
    */
-  if (trackerInfo->returnValue!=S_OK)
-  {
-    /*
-     * Make sure the message loop in DoDragDrop stops
-     */
-    trackerInfo->trackingDone = TRUE;
-
-    /*
-     * Release the mouse in case the drop target decides to show a popup
-     * or a menu or something.
-     */
-    ReleaseCapture();
-
-    /*
-     * If we end-up over a target, drop the object in the target or
-     * inform the target that the operation was cancelled.
-     */
-    if (trackerInfo->curDragTarget)
-    {
-      switch (trackerInfo->returnValue)
-      {
-	/*
-	 * If the source wants us to complete the operation, we tell
-	 * the drop target that we just dropped the object in it.
-	 */
-        case DRAGDROP_S_DROP:
-          if (*trackerInfo->pdwEffect != DROPEFFECT_NONE)
-          {
-            hr = IDropTarget_Drop(trackerInfo->curDragTarget, trackerInfo->dataObject,
-                    trackerInfo->dwKeyState, trackerInfo->curMousePos, trackerInfo->pdwEffect);
-            if (FAILED(hr))
-              trackerInfo->returnValue = hr;
-          }
-          else
-            IDropTarget_DragLeave(trackerInfo->curDragTarget);
-          break;
-
-	/*
-	 * If the source told us that we should cancel, fool the drop
-         * target by telling it that the mouse left its window.
-	 * Also set the drop effect to "NONE" in case the application
-	 * ignores the result of DoDragDrop.
-	 */
-        case DRAGDROP_S_CANCEL:
-	  IDropTarget_DragLeave(trackerInfo->curDragTarget);
-	  *trackerInfo->pdwEffect = DROPEFFECT_NONE;
-	  break;
-      }
-    }
-  }
+  if (trackerInfo->returnValue != S_OK)
+    drag_end( trackerInfo );
 }
 
 /***




More information about the wine-cvs mailing list