fix the x/y coords of drag drops, just like drag motion events. part of bug #29578 r=pavlov

This commit is contained in:
blizzard%redhat.com 2000-03-04 00:24:49 +00:00
Родитель 94db80804b
Коммит a6af9b1075
2 изменённых файлов: 86 добавлений и 5 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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.