From 31dbd7e584529e0b0ca99ccc3a2b127bb3f62eeb Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Tue, 30 Jul 2002 15:20:28 +0000 Subject: [PATCH] Ensure gecko knows the drag left the window and shuts down the drag session (bug 160041) --- camino/CHBrowserView.h | 2 ++ camino/CHBrowserView.mm | 20 ++++++++++++++------ camino/src/embedding/CHBrowserView.h | 2 ++ camino/src/embedding/CHBrowserView.mm | 20 ++++++++++++++------ chimera/CHBrowserView.h | 2 ++ chimera/CHBrowserView.mm | 20 ++++++++++++++------ chimera/src/embedding/CHBrowserView.h | 2 ++ chimera/src/embedding/CHBrowserView.mm | 20 ++++++++++++++------ 8 files changed, 64 insertions(+), 24 deletions(-) diff --git a/camino/CHBrowserView.h b/camino/CHBrowserView.h index d40b341987e0..521a4d9a4be5 100644 --- a/camino/CHBrowserView.h +++ b/camino/CHBrowserView.h @@ -110,6 +110,8 @@ enum { NSWindow* mWindow; nsIDragHelperService* mDragHelper; + NSPoint mLastTrackedLocation; + NSWindow* mLastTrackedWindow; } // NSView overrides diff --git a/camino/CHBrowserView.mm b/camino/CHBrowserView.mm index 5babf2d206e2..ebd37a934747 100644 --- a/camino/CHBrowserView.mm +++ b/camino/CHBrowserView.mm @@ -1330,15 +1330,17 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingEntered:(id )sender { +// NSLog(@"draggingEntered"); nsCOMPtr helper(do_GetService("@mozilla.org/widget/draghelperservice;1")); mDragHelper = helper.get(); NS_IF_ADDREF(mDragHelper); NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" ); if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Enter ( [sender draggingSequenceNumber], sink ); } @@ -1348,10 +1350,14 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (void)draggingExited:(id )sender { +// NSLog(@"draggingExited"); if ( mDragHelper ) { nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + + [self findEventSink:getter_AddRefs(sink) + forPoint:mLastTrackedLocation /* [sender draggingLocation] */ + inWindow:mLastTrackedWindow /* [sender draggingDestinationWindow] */ + ]; if (sink) mDragHelper->Leave( [sender draggingSequenceNumber], sink ); NS_RELEASE(mDragHelper); @@ -1360,11 +1366,13 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingUpdated:(id )sender { +// NSLog(@"draggingUpdated"); PRBool dropAllowed = PR_FALSE; if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Tracking([sender draggingSequenceNumber], sink, &dropAllowed); } diff --git a/camino/src/embedding/CHBrowserView.h b/camino/src/embedding/CHBrowserView.h index d40b341987e0..521a4d9a4be5 100644 --- a/camino/src/embedding/CHBrowserView.h +++ b/camino/src/embedding/CHBrowserView.h @@ -110,6 +110,8 @@ enum { NSWindow* mWindow; nsIDragHelperService* mDragHelper; + NSPoint mLastTrackedLocation; + NSWindow* mLastTrackedWindow; } // NSView overrides diff --git a/camino/src/embedding/CHBrowserView.mm b/camino/src/embedding/CHBrowserView.mm index 5babf2d206e2..ebd37a934747 100644 --- a/camino/src/embedding/CHBrowserView.mm +++ b/camino/src/embedding/CHBrowserView.mm @@ -1330,15 +1330,17 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingEntered:(id )sender { +// NSLog(@"draggingEntered"); nsCOMPtr helper(do_GetService("@mozilla.org/widget/draghelperservice;1")); mDragHelper = helper.get(); NS_IF_ADDREF(mDragHelper); NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" ); if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Enter ( [sender draggingSequenceNumber], sink ); } @@ -1348,10 +1350,14 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (void)draggingExited:(id )sender { +// NSLog(@"draggingExited"); if ( mDragHelper ) { nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + + [self findEventSink:getter_AddRefs(sink) + forPoint:mLastTrackedLocation /* [sender draggingLocation] */ + inWindow:mLastTrackedWindow /* [sender draggingDestinationWindow] */ + ]; if (sink) mDragHelper->Leave( [sender draggingSequenceNumber], sink ); NS_RELEASE(mDragHelper); @@ -1360,11 +1366,13 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingUpdated:(id )sender { +// NSLog(@"draggingUpdated"); PRBool dropAllowed = PR_FALSE; if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Tracking([sender draggingSequenceNumber], sink, &dropAllowed); } diff --git a/chimera/CHBrowserView.h b/chimera/CHBrowserView.h index d40b341987e0..521a4d9a4be5 100644 --- a/chimera/CHBrowserView.h +++ b/chimera/CHBrowserView.h @@ -110,6 +110,8 @@ enum { NSWindow* mWindow; nsIDragHelperService* mDragHelper; + NSPoint mLastTrackedLocation; + NSWindow* mLastTrackedWindow; } // NSView overrides diff --git a/chimera/CHBrowserView.mm b/chimera/CHBrowserView.mm index 5babf2d206e2..ebd37a934747 100644 --- a/chimera/CHBrowserView.mm +++ b/chimera/CHBrowserView.mm @@ -1330,15 +1330,17 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingEntered:(id )sender { +// NSLog(@"draggingEntered"); nsCOMPtr helper(do_GetService("@mozilla.org/widget/draghelperservice;1")); mDragHelper = helper.get(); NS_IF_ADDREF(mDragHelper); NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" ); if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Enter ( [sender draggingSequenceNumber], sink ); } @@ -1348,10 +1350,14 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (void)draggingExited:(id )sender { +// NSLog(@"draggingExited"); if ( mDragHelper ) { nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + + [self findEventSink:getter_AddRefs(sink) + forPoint:mLastTrackedLocation /* [sender draggingLocation] */ + inWindow:mLastTrackedWindow /* [sender draggingDestinationWindow] */ + ]; if (sink) mDragHelper->Leave( [sender draggingSequenceNumber], sink ); NS_RELEASE(mDragHelper); @@ -1360,11 +1366,13 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingUpdated:(id )sender { +// NSLog(@"draggingUpdated"); PRBool dropAllowed = PR_FALSE; if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Tracking([sender draggingSequenceNumber], sink, &dropAllowed); } diff --git a/chimera/src/embedding/CHBrowserView.h b/chimera/src/embedding/CHBrowserView.h index d40b341987e0..521a4d9a4be5 100644 --- a/chimera/src/embedding/CHBrowserView.h +++ b/chimera/src/embedding/CHBrowserView.h @@ -110,6 +110,8 @@ enum { NSWindow* mWindow; nsIDragHelperService* mDragHelper; + NSPoint mLastTrackedLocation; + NSWindow* mLastTrackedWindow; } // NSView overrides diff --git a/chimera/src/embedding/CHBrowserView.mm b/chimera/src/embedding/CHBrowserView.mm index 5babf2d206e2..ebd37a934747 100644 --- a/chimera/src/embedding/CHBrowserView.mm +++ b/chimera/src/embedding/CHBrowserView.mm @@ -1330,15 +1330,17 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingEntered:(id )sender { +// NSLog(@"draggingEntered"); nsCOMPtr helper(do_GetService("@mozilla.org/widget/draghelperservice;1")); mDragHelper = helper.get(); NS_IF_ADDREF(mDragHelper); NS_ASSERTION ( mDragHelper, "Couldn't get a drag service, we're in biiig trouble" ); if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Enter ( [sender draggingSequenceNumber], sink ); } @@ -1348,10 +1350,14 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (void)draggingExited:(id )sender { +// NSLog(@"draggingExited"); if ( mDragHelper ) { nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + + [self findEventSink:getter_AddRefs(sink) + forPoint:mLastTrackedLocation /* [sender draggingLocation] */ + inWindow:mLastTrackedWindow /* [sender draggingDestinationWindow] */ + ]; if (sink) mDragHelper->Leave( [sender draggingSequenceNumber], sink ); NS_RELEASE(mDragHelper); @@ -1360,11 +1366,13 @@ nsCocoaBrowserListener::SetContainer(id aContainer) - (unsigned int)draggingUpdated:(id )sender { +// NSLog(@"draggingUpdated"); PRBool dropAllowed = PR_FALSE; if ( mDragHelper ) { + mLastTrackedLocation = [sender draggingLocation]; + mLastTrackedWindow = [sender draggingDestinationWindow]; nsCOMPtr sink; - [self findEventSink:getter_AddRefs(sink) forPoint:[sender draggingLocation] - inWindow:[sender draggingDestinationWindow]]; + [self findEventSink:getter_AddRefs(sink) forPoint:mLastTrackedLocation inWindow:mLastTrackedWindow]; if (sink) mDragHelper->Tracking([sender draggingSequenceNumber], sink, &dropAllowed); }