b=495184 current drag operation (dropEffect) is not updated while dragging outside the application. r=enndeakin sr=roc

This commit is contained in:
Karl Tomlinson 2009-06-15 12:48:52 +12:00
parent a3b518d9d3
commit e4a22d9f5b
5 changed files with 56 additions and 15 deletions

View File

@ -52,6 +52,7 @@
PRLogModuleInfo *gWidgetLog = nsnull;
PRLogModuleInfo *gWidgetFocusLog = nsnull;
PRLogModuleInfo *gWidgetIMLog = nsnull;
PRLogModuleInfo *gWidgetDragLog = nsnull;
PRLogModuleInfo *gWidgetDrawLog = nsnull;
#endif
@ -90,6 +91,8 @@ nsAppShell::Init()
gWidgetFocusLog = PR_NewLogModule("WidgetFocus");
if (!gWidgetIMLog)
gWidgetIMLog = PR_NewLogModule("WidgetIM");
if (!gWidgetDragLog)
gWidgetDragLog = PR_NewLogModule("WidgetDrag");
if (!gWidgetDrawLog)
gWidgetDrawLog = PR_NewLogModule("WidgetDraw");
#endif

View File

@ -246,6 +246,8 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
gtk_target_list_unref(sourceList);
StartDragSession();
return rv;
}
@ -309,7 +311,8 @@ nsDragService::StartDragSession()
NS_IMETHODIMP
nsDragService::EndDragSession(PRBool aDoneDrag)
{
PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::EndDragSession"));
PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::EndDragSession %d",
aDoneDrag));
// unset our drag action
SetDragAction(DRAGDROP_ACTION_NONE);
return nsBaseDragService::EndDragSession(aDoneDrag);
@ -1152,10 +1155,43 @@ nsDragService::GetSourceList(void)
}
void
nsDragService::SourceEndDrag(void)
nsDragService::SourceEndDrag(GdkDragContext *aContext)
{
// this just releases the list of data items that we provide
mSourceDataItems = 0;
mSourceDataItems = nsnull;
if (!mDoingDrag)
return; // EndDragSession() was called on drop
// Either the drag was aborted or the drop occurred outside the app.
// The dropEffect of mDataTransfer is not updated for motion outside the
// app, but is needed for the dragend event, so set it now.
// aContext->dest_window will be non-NULL only if the drop succeeded .
GdkDragAction action =
aContext->dest_window ? aContext->action : (GdkDragAction)0;
// Only one bit of action should be set, but, just in case someone does
// something funny, erring away from MOVE, and not recording unusual
// action combinations as NONE.
PRUint32 dropEffect;
if (!action)
dropEffect = DRAGDROP_ACTION_NONE;
else if (action & GDK_ACTION_COPY)
dropEffect = DRAGDROP_ACTION_COPY;
else if (action & GDK_ACTION_LINK)
dropEffect = DRAGDROP_ACTION_LINK;
else if (action & GDK_ACTION_MOVE)
dropEffect = DRAGDROP_ACTION_MOVE;
else
dropEffect = DRAGDROP_ACTION_COPY;
nsCOMPtr<nsIDOMNSDataTransfer> dataTransfer =
do_QueryInterface(mDataTransfer);
if (dataTransfer) {
dataTransfer->SetDropEffectInt(dropEffect);
}
// Inform the drag session that we're ending the drag.
EndDragSession(PR_TRUE);
@ -1344,7 +1380,7 @@ invisibleSourceDragDataGet(GtkWidget *aWidget,
guint32 aTime,
gpointer aData)
{
PR_LOG(sDragLm, PR_LOG_DEBUG, ("invisibleDragDataGet"));
PR_LOG(sDragLm, PR_LOG_DEBUG, ("invisibleSourceDragDataGet"));
nsDragService *dragService = (nsDragService *)aData;
dragService->SourceDataGet(aWidget, aContext,
aSelectionData, aInfo, aTime);
@ -1356,7 +1392,7 @@ invisibleSourceDragEnd(GtkWidget *aWidget,
GdkDragContext *aContext,
gpointer aData)
{
PR_LOG(sDragLm, PR_LOG_DEBUG, ("invisibleDragEnd"));
PR_LOG(sDragLm, PR_LOG_DEBUG, ("invisibleSourceDragEnd"));
nsDragService *dragService = (nsDragService *)aData;
gint x, y;
@ -1367,6 +1403,6 @@ invisibleSourceDragEnd(GtkWidget *aWidget,
}
// The drag has ended. Release the hostages!
dragService->SourceEndDrag();
dragService->SourceEndDrag(aContext);
}

View File

@ -101,7 +101,7 @@ public:
// This is called when the drag started with the invisible widget
// finishes. It's called from within the drag service code but from
// a callback - it needs to be public.
void SourceEndDrag(void);
void SourceEndDrag(GdkDragContext *aContext);
void SourceDataGet(GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,

View File

@ -3390,7 +3390,7 @@ nsWindow::OnDragMotionEvent(GtkWidget *aWidget,
guint aTime,
gpointer aData)
{
LOG(("nsWindow::OnDragMotionSignal\n"));
LOGDRAG(("nsWindow::OnDragMotionSignal\n"));
if (mLastButtonReleaseTime) {
// The drag ended before it was even setup to handle the end of the drag
@ -3490,7 +3490,7 @@ nsWindow::OnDragLeaveEvent(GtkWidget *aWidget,
{
// XXX Do we want to pass this on only if the event's subwindow is null?
LOG(("nsWindow::OnDragLeaveSignal(%p)\n", (void*)this));
LOGDRAG(("nsWindow::OnDragLeaveSignal(%p)\n", (void*)this));
sIsDraggingOutOf = PR_TRUE;
@ -3521,7 +3521,7 @@ nsWindow::OnDragDropEvent(GtkWidget *aWidget,
gpointer *aData)
{
LOG(("nsWindow::OnDragDropSignal\n"));
LOGDRAG(("nsWindow::OnDragDropSignal\n"));
// get our drag context
nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
@ -3634,7 +3634,7 @@ nsWindow::OnDragDataReceivedEvent(GtkWidget *aWidget,
guint aTime,
gpointer aData)
{
LOG(("nsWindow::OnDragDataReceived(%p)\n", (void*)this));
LOGDRAG(("nsWindow::OnDragDataReceived(%p)\n", (void*)this));
// get our drag context
nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
@ -3647,7 +3647,7 @@ nsWindow::OnDragDataReceivedEvent(GtkWidget *aWidget,
void
nsWindow::OnDragLeave(void)
{
LOG(("nsWindow::OnDragLeave(%p)\n", (void*)this));
LOGDRAG(("nsWindow::OnDragLeave(%p)\n", (void*)this));
nsDragEvent event(PR_TRUE, NS_DRAGDROP_EXIT, this);
@ -3680,7 +3680,7 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY)
{
// XXX Do we want to pass this on only if the event's subwindow is null?
LOG(("nsWindow::OnDragEnter(%p)\n", (void*)this));
LOGDRAG(("nsWindow::OnDragEnter(%p)\n", (void*)this));
nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
@ -5894,7 +5894,7 @@ nsWindow::ResetDragMotionTimer(GtkWidget *aWidget,
void
nsWindow::FireDragMotionTimer(void)
{
LOG(("nsWindow::FireDragMotionTimer(%p)\n", (void*)this));
LOGDRAG(("nsWindow::FireDragMotionTimer(%p)\n", (void*)this));
OnDragMotionEvent(mDragMotionWidget, mDragMotionContext,
mDragMotionX, mDragMotionY, mDragMotionTime,
@ -5904,7 +5904,7 @@ nsWindow::FireDragMotionTimer(void)
void
nsWindow::FireDragLeaveTimer(void)
{
LOG(("nsWindow::FireDragLeaveTimer(%p)\n", (void*)this));
LOGDRAG(("nsWindow::FireDragLeaveTimer(%p)\n", (void*)this));
mDragLeaveTimer = nsnull;

View File

@ -85,11 +85,13 @@
extern PRLogModuleInfo *gWidgetLog;
extern PRLogModuleInfo *gWidgetFocusLog;
extern PRLogModuleInfo *gWidgetIMLog;
extern PRLogModuleInfo *gWidgetDragLog;
extern PRLogModuleInfo *gWidgetDrawLog;
#define LOG(args) PR_LOG(gWidgetLog, 4, args)
#define LOGFOCUS(args) PR_LOG(gWidgetFocusLog, 4, args)
#define LOGIM(args) PR_LOG(gWidgetIMLog, 4, args)
#define LOGDRAG(args) PR_LOG(gWidgetDragLog, 4, args)
#define LOGDRAW(args) PR_LOG(gWidgetDrawLog, 4, args)
#else