зеркало из https://github.com/mozilla/pjs.git
b=478816 check that gtk_drag_begin returns a non-NULL GdkDragContext r+sr=roc
This commit is contained in:
Родитель
88ae0aa469
Коммит
6c048809ab
|
@ -176,40 +176,43 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
|||
// length of this call
|
||||
mSourceDataItems = aArrayTransferables;
|
||||
// get the list of items we offer for drags
|
||||
GtkTargetList *sourceList = 0;
|
||||
GtkTargetList *sourceList = GetSourceList();
|
||||
|
||||
sourceList = GetSourceList();
|
||||
if (!sourceList)
|
||||
return NS_OK;
|
||||
|
||||
if (sourceList) {
|
||||
// save our action type
|
||||
GdkDragAction action = GDK_ACTION_DEFAULT;
|
||||
// save our action type
|
||||
GdkDragAction action = GDK_ACTION_DEFAULT;
|
||||
|
||||
if (aActionType & DRAGDROP_ACTION_COPY)
|
||||
action = (GdkDragAction)(action | GDK_ACTION_COPY);
|
||||
if (aActionType & DRAGDROP_ACTION_MOVE)
|
||||
action = (GdkDragAction)(action | GDK_ACTION_MOVE);
|
||||
if (aActionType & DRAGDROP_ACTION_LINK)
|
||||
action = (GdkDragAction)(action | GDK_ACTION_LINK);
|
||||
if (aActionType & DRAGDROP_ACTION_COPY)
|
||||
action = (GdkDragAction)(action | GDK_ACTION_COPY);
|
||||
if (aActionType & DRAGDROP_ACTION_MOVE)
|
||||
action = (GdkDragAction)(action | GDK_ACTION_MOVE);
|
||||
if (aActionType & DRAGDROP_ACTION_LINK)
|
||||
action = (GdkDragAction)(action | GDK_ACTION_LINK);
|
||||
|
||||
// Create a fake event for the drag so we can pass the time
|
||||
// (so to speak.) If we don't do this the drag can end as a
|
||||
// result of a button release that is actually _earlier_ than
|
||||
// CurrentTime. So we use the time on the last button press
|
||||
// event, as that will always be older than the button release
|
||||
// that ends any drag.
|
||||
GdkEvent event;
|
||||
memset(&event, 0, sizeof(GdkEvent));
|
||||
event.type = GDK_BUTTON_PRESS;
|
||||
event.button.window = mHiddenWidget->window;
|
||||
event.button.time = nsWindow::mLastButtonPressTime;
|
||||
// Create a fake event for the drag so we can pass the time
|
||||
// (so to speak.) If we don't do this the drag can end as a
|
||||
// result of a button release that is actually _earlier_ than
|
||||
// CurrentTime. So we use the time on the last button press
|
||||
// event, as that will always be older than the button release
|
||||
// that ends any drag.
|
||||
GdkEvent event;
|
||||
memset(&event, 0, sizeof(GdkEvent));
|
||||
event.type = GDK_BUTTON_PRESS;
|
||||
event.button.window = mHiddenWidget->window;
|
||||
event.button.time = nsWindow::mLastButtonPressTime;
|
||||
|
||||
// start our drag.
|
||||
GdkDragContext *context = gtk_drag_begin(mHiddenWidget,
|
||||
sourceList,
|
||||
action,
|
||||
1,
|
||||
&event);
|
||||
// start our drag.
|
||||
GdkDragContext *context = gtk_drag_begin(mHiddenWidget,
|
||||
sourceList,
|
||||
action,
|
||||
1,
|
||||
&event);
|
||||
|
||||
if (!context) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
} else {
|
||||
PRBool needsFallbackIcon = PR_FALSE;
|
||||
nsIntRect dragRect;
|
||||
nsPresContext* pc;
|
||||
|
@ -239,11 +242,11 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
|||
|
||||
if (needsFallbackIcon)
|
||||
gtk_drag_set_icon_default(context);
|
||||
|
||||
gtk_target_list_unref(sourceList);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
gtk_target_list_unref(sourceList);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
|
Загрузка…
Ссылка в новой задаче