b=497498 use a helper method for dispatching destination drag events r=roc
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -3318,16 +3318,33 @@ nsWindow::CheckNeedDragLeave(nsWindow* a
// update our drag status
UpdateDragStatus(aDragContext, aDragService);
// set the last window to the innerMostWidget
sLastDragMotionWindow = aInnerMostWidget;
}
+void
+nsWindow::DispatchDragEvent(PRUint32 aMsg, const nsIntPoint& aRefPoint,
+ guint aTime)
+{
+ nsDragEvent event(true, aMsg, this);
+
+ if (aMsg == NS_DRAGDROP_OVER) {
+ InitDragEvent(event);
+ }
+
+ event.refPoint = aRefPoint;
+ event.time = aTime;
+
+ nsEventStatus status;
+ DispatchEvent(&event, status);
+}
+
gboolean
nsWindow::OnDragMotionEvent(GtkWidget *aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
guint aTime,
gpointer aData)
{
@@ -3380,26 +3397,18 @@ nsWindow::OnDragMotionEvent(GtkWidget *a
// update the drag context
dragServiceGTK->TargetSetLastContext(aWidget, aDragContext, aTime);
dragServiceGTK->SetCanDrop(false);
dragService->FireDragEventAtSource(NS_DRAGDROP_DRAG);
- nsDragEvent event(true, NS_DRAGDROP_OVER, innerMostWidget);
-
- InitDragEvent(event);
-
- event.refPoint.x = retx;
- event.refPoint.y = rety;
- event.time = aTime;
-
- nsEventStatus status;
- innerMostWidget->DispatchEvent(&event, status);
+ innerMostWidget->
+ DispatchDragEvent(NS_DRAGDROP_OVER, nsIntPoint(retx, rety), aTime);
// Reply to tell the source whether we can drop and what action would be
// taken.
dragServiceGTK->TargetEndDragMotion(aWidget, aDragContext, aTime);
// and unset our context
dragServiceGTK->TargetSetLastContext(0, 0, 0);
@@ -3492,42 +3501,30 @@ nsWindow::OnDragDropEvent(GtkWidget *aWi
// contain a position. However, we can't assume the same when the Motif
// protocol is used.
dragServiceGTK->TargetSetLastContext(aWidget, aDragContext, aTime);
dragServiceGTK->SetCanDrop(false);
dragService->FireDragEventAtSource(NS_DRAGDROP_DRAG);
- nsDragEvent event(true, NS_DRAGDROP_OVER, innerMostWidget);
-
- InitDragEvent(event);
-
- event.refPoint.x = retx;
- event.refPoint.y = rety;
- event.time = aTime;
-
- nsEventStatus status;
- innerMostWidget->DispatchEvent(&event, status);
+ innerMostWidget->
+ DispatchDragEvent(NS_DRAGDROP_OVER, nsIntPoint(retx, rety), aTime);
gboolean success = FALSE;
// We need to check innerMostWidget->mIsDestroyed here because the nsRefPtr
// only protects innerMostWidget from being deleted, it does NOT protect
// against nsView::~nsView() calling Destroy() on it, bug 378670.
if (!innerMostWidget->mIsDestroyed) {
bool canDrop;
dragServiceGTK->GetCanDrop(&canDrop);
PRUint32 msg = canDrop ? NS_DRAGDROP_DROP : NS_DRAGDROP_EXIT;
- nsDragEvent event(true, msg, innerMostWidget);
- event.refPoint.x = retx;
- event.refPoint.y = rety;
-
- nsEventStatus status = nsEventStatus_eIgnore;
- innerMostWidget->DispatchEvent(&event, status);
+
+ innerMostWidget->DispatchDragEvent(msg, nsIntPoint(retx, rety), aTime);
success = canDrop;
}
// before we unset the context we need to do a drop_finish
gdk_drop_finish(aDragContext, success, aTime);
@@ -3567,20 +3564,17 @@ nsWindow::OnDragDataReceivedEvent(GtkWid
aSelectionData, aInfo, aTime);
}
void
nsWindow::OnDragLeave(void)
{
LOGDRAG(("nsWindow::OnDragLeave(%p)\n", (void*)this));
- nsDragEvent event(true, NS_DRAGDROP_EXIT, this);
-
- nsEventStatus status;
- DispatchEvent(&event, status);
+ DispatchDragEvent(NS_DRAGDROP_EXIT, nsIntPoint(0, 0), 0);
nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
if (dragService) {
nsCOMPtr<nsIDragSession> currentDragSession;
dragService->GetCurrentSession(getter_AddRefs(currentDragSession));
if (currentDragSession) {
--- a/widget/gtk2/nsWindow.h
+++ b/widget/gtk2/nsWindow.h
@@ -310,16 +310,19 @@ public:
NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical);
NS_IMETHOD BeginMoveDrag(nsMouseEvent* aEvent);
MozContainer* GetMozContainer() { return mContainer; }
GdkWindow* GetGdkWindow() { return mGdkWindow; }
bool IsDestroyed() { return mIsDestroyed; }
+ void DispatchDragEvent(PRUint32 aMsg,
+ const nsIntPoint& aRefPoint,
+ guint aTime);
// If this dispatched the keydown event actually, this returns TRUE,
// otherwise, FALSE.
bool DispatchKeyDownEvent(GdkEventKey *aEvent,
bool *aIsCancelled);
NS_IMETHOD ResetInputState();
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
const InputContextAction& aAction);