mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 466379, add screen coordinates to dragend event, r=josh,sr=roc
This commit is contained in:
parent
c75317fb03
commit
ca355eece3
@ -6228,6 +6228,12 @@ static BOOL keyUpAlreadySentKeyDown = NO;
|
||||
}
|
||||
|
||||
if (mDragService) {
|
||||
// set the dragend point from the current mouse location
|
||||
nsDragService* dragService = static_cast<nsDragService *>(mDragService);
|
||||
NSPoint pnt = [NSEvent mouseLocation];
|
||||
FlipCocoaScreenCoordinate(pnt);
|
||||
dragService->SetDragEndPoint(nsPoint(NSToIntRound(pnt.x), NSToIntRound(pnt.y)));
|
||||
|
||||
mDragService->EndDragSession(PR_TRUE);
|
||||
NS_RELEASE(mDragService);
|
||||
}
|
||||
|
@ -355,7 +355,10 @@ nsDragService::StartInvokingDragSession(IDataObject * aDataObj,
|
||||
|
||||
mUserCancelled = nativeDragSource->UserCancelled();
|
||||
|
||||
// We're done dragging
|
||||
// We're done dragging, get the cursor position and end the drag
|
||||
POINT pos;
|
||||
GetCursorPos(&pos);
|
||||
SetDragEndPoint(nsPoint(pos.x, pos.y));
|
||||
EndDragSession(PR_TRUE);
|
||||
|
||||
// For some drag/drop interactions, IDataObject::SetData doesn't get
|
||||
|
@ -224,6 +224,7 @@ nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
||||
// stash the document of the dom node
|
||||
aDOMNode->GetOwnerDocument(getter_AddRefs(mSourceDocument));
|
||||
mSourceNode = aDOMNode;
|
||||
mEndDragPoint = nsPoint(0, 0);
|
||||
|
||||
// When the mouse goes down, the selection code starts a mouse
|
||||
// capture. However, this gets in the way of determining drag
|
||||
@ -374,7 +375,11 @@ nsBaseDragService::FireDragEventAtSource(PRUint32 aMsg)
|
||||
if (presShell) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsDragEvent event(PR_TRUE, aMsg, nsnull);
|
||||
event.userCancelled = (aMsg == NS_DRAGDROP_END && mUserCancelled);
|
||||
if (aMsg == NS_DRAGDROP_END) {
|
||||
event.refPoint.x = mEndDragPoint.x;
|
||||
event.refPoint.y = mEndDragPoint.y;
|
||||
event.userCancelled = mUserCancelled;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mSourceNode);
|
||||
return presShell->HandleDOMEventWithTarget(content, &event, &status);
|
||||
|
@ -77,6 +77,8 @@ public:
|
||||
NS_DECL_NSIDRAGSERVICE
|
||||
NS_DECL_NSIDRAGSESSION
|
||||
|
||||
void SetDragEndPoint(nsPoint aEndDragPoint) { mEndDragPoint = aEndDragPoint; }
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@ -154,6 +156,9 @@ protected:
|
||||
PRInt32 mScreenX;
|
||||
PRInt32 mScreenY;
|
||||
|
||||
// the screen position where the drag ended
|
||||
nsPoint mEndDragPoint;
|
||||
|
||||
PRUint32 mSuppressLevel;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user