Bug 488984 - when draging tab to content area aEvent.screenX/Y in _onDragEnd is always 0 (breaks tab tearing). r=vlad
authorJim Mathies <jmathies@mozilla.com>
Mon, 20 Apr 2009 17:54:46 -0700
changeset 27557 f365e3bc979bc1a6011304d4071a1c7b1d462aa7
parent 27556 8ecdcd32c27ab13644b2d91ebd4f178b10923a51
child 27558 a6b1b49f7d7ed93abd30a1e9599033f9ab913070
push id6611
push userjdolske@mozilla.com
push dateTue, 21 Apr 2009 00:55:41 +0000
treeherdermozilla-central@f365e3bc979b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs488984
milestone1.9.2a1pre
Bug 488984 - when draging tab to content area aEvent.screenX/Y in _onDragEnd is always 0 (breaks tab tearing). r=vlad
widget/src/gtk2/nsWindow.cpp
widget/src/windows/nsNativeDragTarget.cpp
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -49,17 +49,17 @@
 #include "nsIDeviceContext.h"
 #include "nsIRenderingContext.h"
 #include "nsIRegion.h"
 #include "nsIRollupListener.h"
 #include "nsIMenuRollup.h"
 #include "nsIDOMNode.h"
 
 #include "nsWidgetsCID.h"
-#include "nsIDragService.h"
+#include "nsDragService.h"
 #include "nsIDragSessionGTK.h"
 
 #include "nsGtkKeyUtils.h"
 #include "nsGtkCursors.h"
 
 #include <gtk/gtk.h>
 #ifdef MOZ_X11
 #include <gdk/gdkx.h>
@@ -3487,16 +3487,23 @@ nsWindow::OnDragDropEvent(GtkWidget *aWi
     // event and and that case is handled in that handler.
     dragSessionGTK->TargetSetLastContext(0, 0, 0);
 
     // clear the mLastDragMotion window
     mLastDragMotionWindow = 0;
 
     // Make sure to end the drag session. If this drag started in a
     // different app, we won't get a drag_end signal to end it from.
+    gint x, y;
+    GdkDisplay* display = gdk_display_get_default();
+    if (display) {
+      // get the current cursor position
+      gdk_display_get_pointer(display, NULL, &x, &y, NULL);
+      ((nsDragService *)dragService.get())->SetDragEndPoint(nsIntPoint(x, y));
+    }
     dragService->EndDragSession(PR_TRUE);
 
     return TRUE;
 }
 
 void
 nsWindow::OnDragDataReceivedEvent(GtkWidget *aWidget,
                                   GdkDragContext *aDragContext,
--- a/widget/src/windows/nsNativeDragTarget.cpp
+++ b/widget/src/windows/nsNativeDragTarget.cpp
@@ -435,16 +435,19 @@ nsNativeDragTarget::Drop(LPDATAOBJECT pD
   ProcessDrag(pData, NS_DRAGDROP_DROP, grfKeyState, aPT, pdwEffect);
 
   // Let the win drag service know whether this session experienced 
   // a drop event within the application. Drop will not oocur if the
   // drop landed outside the app. (used in tab tear off, bug 455884)
   winDragService->SetDroppedLocal();
 
   // tell the drag service we're done with the session
+  POINT pos;
+  GetCursorPos(&pos);
+  winDragService->SetDragEndPoint(nsIntPoint(pos.x, pos.y));
   serv->EndDragSession(PR_TRUE);
 
   // release the ref that was taken in DragEnter
   NS_ASSERTION(mTookOwnRef, "want to release own ref, but not taken!");
   if (mTookOwnRef) {
     this->Release();
     mTookOwnRef = PR_FALSE;
   }