diff --git a/mozilla/widget/public/nsIDragSessionGTK.h b/mozilla/widget/public/nsIDragSessionGTK.h index 7be593974c8..ce4d1f19813 100644 --- a/mozilla/widget/public/nsIDragSessionGTK.h +++ b/mozilla/widget/public/nsIDragSessionGTK.h @@ -39,7 +39,10 @@ class nsIDragSessionGTK : public nsISupports { NS_IMETHOD SetLastContext (GtkWidget *aWidget, GdkDragContext *aContext, guint aTime) = 0; - NS_IMETHOD UpdateDragStatus(GtkWidget *aWidget, + NS_IMETHOD StartDragMotion (GtkWidget *aWidget, + GdkDragContext *aContext, + guint aTime) = 0; + NS_IMETHOD EndDragMotion (GtkWidget *aWidget, GdkDragContext *aContext, guint aTime) = 0; NS_IMETHOD SetDataReceived (GtkWidget *aWidget, diff --git a/mozilla/widget/src/gtk/nsDragService.cpp b/mozilla/widget/src/gtk/nsDragService.cpp index 47f456c8103..9c555d1d906 100644 --- a/mozilla/widget/src/gtk/nsDragService.cpp +++ b/mozilla/widget/src/gtk/nsDragService.cpp @@ -341,12 +341,25 @@ NS_IMETHODIMP nsDragService::SetLastContext (GtkWidget *aWidget, return NS_OK; } -NS_IMETHODIMP nsDragService::UpdateDragStatus(GtkWidget *aWidget, - GdkDragContext *aContext, - guint aTime) +NS_IMETHODIMP nsDragService::StartDragMotion(GtkWidget *aWidget, + GdkDragContext *aContext, + guint aTime) { #ifdef DEBUG_DD - g_print("UpdateDragStatus: %d\n", mCanDrop); + g_print("StartDragMotion\n"); +#endif + // set our drop target to false since we probably won't get + // notification if there's no JS DND listener. + mCanDrop = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP nsDragService::EndDragMotion(GtkWidget *aWidget, + GdkDragContext *aContext, + guint aTime) +{ +#ifdef DEBUG_DD + g_print("EndDragMotion: %d\n", mCanDrop); #endif if (mCanDrop) gdk_drag_status(aContext, GDK_ACTION_COPY, aTime); diff --git a/mozilla/widget/src/gtk/nsDragService.h b/mozilla/widget/src/gtk/nsDragService.h index 79017e87c95..8b34cb4e267 100644 --- a/mozilla/widget/src/gtk/nsDragService.h +++ b/mozilla/widget/src/gtk/nsDragService.h @@ -59,9 +59,12 @@ public: NS_IMETHOD SetLastContext (GtkWidget *aWidget, GdkDragContext *aContext, guint aTime); - NS_IMETHOD UpdateDragStatus(GtkWidget *aWidget, - GdkDragContext *aContext, - guint aTime); + NS_IMETHOD StartDragMotion (GtkWidget *aWidget, + GdkDragContext *aContext, + guint aTime); + NS_IMETHOD EndDragMotion (GtkWidget *aWidget, + GdkDragContext *aContext, + guint aTime); NS_IMETHOD SetDataReceived (GtkWidget *aWidget, GdkDragContext *context, gint x, diff --git a/mozilla/widget/src/gtk/nsWidget.cpp b/mozilla/widget/src/gtk/nsWidget.cpp index ae3efe548bd..0c39516f186 100644 --- a/mozilla/widget/src/gtk/nsWidget.cpp +++ b/mozilla/widget/src/gtk/nsWidget.cpp @@ -2973,7 +2973,7 @@ void nsWidget::UpdateDragContext(GtkWidget *aWidget, GdkDragContext *aGdkDragCon } /* virtual */ -void nsWidget::UpdateDragStatus(GtkWidget *aWidget, GdkDragContext *aGdkDragContext, guint aTime) +void nsWidget::StartDragMotion(GtkWidget *aWidget, GdkDragContext *aGdkDragContext, guint aTime) { // make sure that we tell the drag manager what the hell is going on. nsCOMPtr dragService; @@ -2989,7 +2989,27 @@ void nsWidget::UpdateDragStatus(GtkWidget *aWidget, GdkDragContext *aGdkDragCont if (!dragServiceGTK) { return; } - dragServiceGTK->UpdateDragStatus(aWidget, aGdkDragContext, aTime); + dragServiceGTK->StartDragMotion(aWidget, aGdkDragContext, aTime); +} + +/* virtual */ +void nsWidget::EndDragMotion(GtkWidget *aWidget, GdkDragContext *aGdkDragContext, guint aTime) +{ + // make sure that we tell the drag manager what the hell is going on. + nsCOMPtr dragService; + nsresult rv = nsServiceManager::GetService(kCDragServiceCID, + nsIDragService::GetIID(), + (nsISupports **)&dragService); + if (NS_FAILED(rv)) { + g_print("*** warning: failed to get the drag service. this is a _bad_ thing.\n"); + return; + } + nsCOMPtr dragServiceGTK; + dragServiceGTK = do_QueryInterface(dragService); + if (!dragServiceGTK) { + return; + } + dragServiceGTK->EndDragMotion(aWidget, aGdkDragContext, aTime); } #ifdef NS_DEBUG diff --git a/mozilla/widget/src/gtk/nsWidget.h b/mozilla/widget/src/gtk/nsWidget.h index 15bf7721b96..c43a573f6c9 100644 --- a/mozilla/widget/src/gtk/nsWidget.h +++ b/mozilla/widget/src/gtk/nsWidget.h @@ -202,7 +202,8 @@ public: protected: virtual void UpdateDragContext(GtkWidget *aWidget, GdkDragContext *aGdkDragContext, guint aTime); - virtual void UpdateDragStatus(GtkWidget *aWidget, GdkDragContext *aGdkDragContext, guint aTime); + virtual void StartDragMotion(GtkWidget *aWidget, GdkDragContext *aGdkDragContext, guint aTime); + virtual void EndDragMotion(GtkWidget *aWidget, GdkDragContext *aGdkDragContext, guint aTime); virtual void InitCallbacks(char * aName = nsnull); diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index dee3ba1be74..baeafe9e7b7 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -1357,6 +1357,9 @@ nsWindow::OnToplevelDragMotion (GtkWidget *aWidget, innerMostWidget->OnDragEnterSignal(aDragContext, x, y, aTime); } + // notify the drag service that we are starting a drag motion. + StartDragMotion(aWidget, aDragContext, aTime); + nsMouseEvent event; event.message = NS_DRAGDROP_OVER; @@ -1373,8 +1376,8 @@ nsWindow::OnToplevelDragMotion (GtkWidget *aWidget, innerMostWidget->Release(); - // now that we've dispatched the signal, update the drag context - UpdateDragStatus(aWidget, aDragContext, aTime); + // we're done with the drag motion event. notify the drag service. + EndDragMotion(aWidget, aDragContext, aTime); } void