From a6af9b1075a1675c66eaf43af83beca4862f3ba4 Mon Sep 17 00:00:00 2001 From: "blizzard%redhat.com" Date: Sat, 4 Mar 2000 00:24:49 +0000 Subject: [PATCH] fix the x/y coords of drag drops, just like drag motion events. part of bug #29578 r=pavlov --- widget/src/gtk/nsWindow.cpp | 85 ++++++++++++++++++++++++++++++++++--- widget/src/gtk/nsWindow.h | 6 +++ 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 16ce0597075e..4efa03b7a8e2 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -1354,6 +1354,79 @@ nsWindow::OnToplevelDragMotion (GtkWidget *aWidget, UpdateDragStatus(aWidget, aDragContext, aTime); } +void +nsWindow::OnToplevelDragDrop (GtkWidget *aWidget, + GdkDragContext *aDragContext, + gint x, + gint y, + guint aTime) +{ + + g_print("OnToplevelDragDrop\n"); +#ifdef DEBUG_DND_XLATE + DumpWindowTree(); +#endif + nscoord retx = 0; + nscoord rety = 0; + + Window thisWindow = GDK_WINDOW_XWINDOW(aWidget->window); + Window returnWindow = None; + returnWindow = GetInnerMostWindow(thisWindow, thisWindow, x, y, &retx, &rety, 0); + + nsWindow *innerMostWidget = NULL; + innerMostWidget = GetnsWindowFromXWindow(returnWindow); + + if (!innerMostWidget) + innerMostWidget = this; + +#ifdef DEBUG_DND_XLATE + g_print("innerMostWidget is %p\n", innerMostWidget); +#endif + + // check to see if there was a drag motion window already in place + if (mLastDragMotionWindow) { + // if it wasn't this + if (mLastDragMotionWindow != innerMostWidget) { + // send a drag event to the last window that got a motion event + mLastDragMotionWindow->OnDragLeaveSignal(aDragContext, aTime); + } + } + + // set the last window to this + mLastDragMotionWindow = innerMostWidget; + + if (!innerMostWidget->mIsDragDest) + { + // this will happen on the first motion event, so we will generate an ENTER event + innerMostWidget->OnDragEnterSignal(aDragContext, x, y, aTime); + } + + UpdateDragContext(aWidget, aDragContext, aTime); + + nsMouseEvent event; + + event.message = NS_DRAGDROP_DROP; + event.eventStructType = NS_DRAGDROP_EVENT; + + event.widget = innerMostWidget; + + event.point.x = retx; + event.point.y = rety; + + innerMostWidget->AddRef(); + + innerMostWidget->DispatchMouseEvent(event); + + innerMostWidget->Release(); + + // after a drop takes place we need to make sure that the drag + // service doesn't think that it still has a context. if the other + // way ( besides the drop ) to end a drag event is during the leave + // event and and that case is handled in that handler. + UpdateDragContext(NULL, NULL, 0); + +} + void nsWindow::InstallToplevelDragDropSignal(void) { @@ -1373,11 +1446,13 @@ nsWindow::ToplevelDragDropSignal(GtkWidget * aWidget, guint aTime, void *aData) { - if (mLastLeaveWindow) { - mLastLeaveWindow->OnDragDropSignal(aWidget, aDragContext, x, y, aTime); - mLastLeaveWindow = NULL; - } - return PR_FALSE; + nsWindow *widget = (nsWindow *)aData; + + NS_ASSERTION(nsnull != widget, "instance pointer is null"); + + widget->OnToplevelDragDrop(aWidget, aDragContext, x, y, aTime); + + return PR_TRUE; } void diff --git a/widget/src/gtk/nsWindow.h b/widget/src/gtk/nsWindow.h index 9b4c6dc016da..58f1e97827f4 100644 --- a/widget/src/gtk/nsWindow.h +++ b/widget/src/gtk/nsWindow.h @@ -145,6 +145,12 @@ public: gint y, guint aTime); + void OnToplevelDragDrop (GtkWidget *aWidget, + GdkDragContext *aDragContext, + gint x, + gint y, + guint aTime); + gint ConvertBorderStyles(nsBorderStyle bs); // Add an XATOM property to this window.