зеркало из https://github.com/mozilla/pjs.git
Changes for qnx(photon) platform only. They should not affect building/running other platforms.
Some Dnd related work. It relies on a change in libph and the Photon server, available in the 630 patch. The changes don't break anything if runned on 630 ( no patch ). Mainly it allows to cancel a previously PhInitDrag operation when mozilla decides to invoke a drag and drop session.
This commit is contained in:
Родитель
cc83b8e0e8
Коммит
1032ce95ce
|
@ -52,6 +52,9 @@ NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
|
|||
NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
|
||||
NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession)
|
||||
|
||||
char *nsDragService::mDndEvent = NULL;
|
||||
int nsDragService::mDndEventLen;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DragService constructor
|
||||
|
@ -79,7 +82,11 @@ nsDragService::~nsDragService()
|
|||
|
||||
NS_IMETHODIMP nsDragService::SetNativeDndData( PtWidget_t *widget, PhEvent_t *event ) {
|
||||
mDndWidget = widget;
|
||||
mDndEvent = event;
|
||||
if( !mDndEvent ) {
|
||||
mDndEventLen = sizeof( PhEvent_t ) + event->num_rects * sizeof( PhRect_t ) + event->data_len;
|
||||
mDndEvent = ( char * ) malloc( mDndEventLen );
|
||||
}
|
||||
memcpy( mDndEvent, (char*)event, mDndEventLen );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -97,6 +104,26 @@ NS_IMETHODIMP nsDragService::SetDropData( char *data, PRUint32 tmpDataLen, char
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* remove this function with the one from libph.so, when it becomes available */
|
||||
int CancelDrag( PhRid_t rid, unsigned input_group )
|
||||
{
|
||||
struct dragevent {
|
||||
PhEvent_t hdr;
|
||||
PhDragEvent_t drag;
|
||||
} ev;
|
||||
memset( &ev, 0, sizeof(ev) );
|
||||
ev.hdr.type = Ph_EV_DRAG;
|
||||
ev.hdr.emitter.rid = Ph_DEV_RID;
|
||||
ev.hdr.flags = Ph_EVENT_INCLUSIVE | Ph_EMIT_TOWARD;
|
||||
ev.hdr.data_len = sizeof( ev.drag );
|
||||
ev.hdr.subtype = Ph_EV_DRAG_COMPLETE;
|
||||
ev.hdr.input_group = input_group;
|
||||
ev.drag.rid = rid;
|
||||
return PhEmit( &ev.hdr, NULL, &ev.drag );
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
|
||||
|
@ -118,11 +145,17 @@ nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
|
|||
if ( !numItemsToDrag )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mActionType = aActionType;
|
||||
|
||||
PRUint32 tmpDataLen = 0;
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
char aflavorStr[100];
|
||||
GetRawData( aArrayTransferables, getter_AddRefs( genericDataWrapper ), &tmpDataLen, aflavorStr );
|
||||
|
||||
|
||||
/* cancel a previous drag ( PhInitDrag ) if one is in place */
|
||||
CancelDrag( PtWidgetRid( mDndWidget ), ((PhEvent_t*)mDndEvent)->input_group );
|
||||
|
||||
void *data;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive ( aflavorStr, genericDataWrapper, &data, tmpDataLen );
|
||||
|
||||
|
@ -135,7 +168,8 @@ nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
|
|||
strcpy( dupdata+4, aflavorStr );
|
||||
memcpy( dupdata+4+100, data, tmpDataLen );
|
||||
PtTransportType( mNativeCtrl, "Mozilla", "dnddata", 0, Ph_TRANSPORT_INLINE, "raw", dupdata, tmpDataLen+4+100, 0 );
|
||||
PtInitDnd( mNativeCtrl, mDndWidget, mDndEvent, NULL, 0 );
|
||||
|
||||
PtInitDnd( mNativeCtrl, mDndWidget, (PhEvent_t*)mDndEvent, NULL, 0 );
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -72,9 +72,12 @@ public:
|
|||
NS_IMETHOD SetDropData( char *data, PRUint32 tmpDataLen, char *flavorStr );
|
||||
NS_IMETHOD GetRawData( nsISupportsArray* aArrayTransferables, nsISupports **data, PRUint32 *tmpDataLen, char *aflavorStr );
|
||||
|
||||
PRUint32 mActionType;
|
||||
|
||||
private:
|
||||
PtWidget_t *mDndWidget;
|
||||
PhEvent_t *mDndEvent;
|
||||
static char *mDndEvent;
|
||||
static int mDndEventLen;
|
||||
|
||||
PtTransportCtrl_t *mNativeCtrl;
|
||||
char *mData;
|
||||
|
|
|
@ -1073,15 +1073,6 @@ inline PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbIn
|
|||
case Ph_EV_DRAG_MOTION_EVENT: {
|
||||
PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event );
|
||||
ScreenToWidgetPos( ptrev2->pos );
|
||||
|
||||
#ifdef PHOTON_DND
|
||||
if( sDragService ) {
|
||||
nsDragService *d;
|
||||
nsIDragService *s = sDragService;
|
||||
d = ( nsDragService * )s;
|
||||
d->SetNativeDndData( widget, event );
|
||||
}
|
||||
#endif
|
||||
InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_MOVE );
|
||||
result = DispatchMouseEvent(theMouseEvent);
|
||||
}
|
||||
|
@ -1175,9 +1166,19 @@ void nsWidget::ProcessDrag( PhEvent_t *event, PRUint32 aEventType, PhPoint_t *po
|
|||
sDragService->GetCurrentSession ( getter_AddRefs(currSession) );
|
||||
if( !currSession ) return;
|
||||
|
||||
currSession->SetDragAction( 2 );
|
||||
int action = nsIDragService::DRAGDROP_ACTION_NONE;
|
||||
nsDragService *d = ( nsDragService * ) sDragService;
|
||||
|
||||
if( d->mActionType & nsIDragService::DRAGDROP_ACTION_MOVE )
|
||||
action = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
else if( d->mActionType & nsIDragService::DRAGDROP_ACTION_LINK )
|
||||
action = nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
else if( d->mActionType & nsIDragService::DRAGDROP_ACTION_COPY )
|
||||
action = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
|
||||
DispatchDragDropEvent( aEventType, pos );
|
||||
currSession->SetDragAction( action );
|
||||
|
||||
DispatchDragDropEvent( event, aEventType, pos );
|
||||
|
||||
event->subtype = Ph_EV_DND_ENTER;
|
||||
|
||||
|
@ -1196,7 +1197,7 @@ void nsWidget::ProcessDrag( PhEvent_t *event, PRUint32 aEventType, PhPoint_t *po
|
|||
currSession->SetCanDrop(PR_FALSE);
|
||||
}
|
||||
|
||||
void nsWidget::DispatchDragDropEvent( PRUint32 aEventType, PhPoint_t *pos ) {
|
||||
void nsWidget::DispatchDragDropEvent( PhEvent_t *phevent, PRUint32 aEventType, PhPoint_t *pos ) {
|
||||
nsEventStatus status;
|
||||
nsMouseEvent event;
|
||||
|
||||
|
@ -1205,10 +1206,11 @@ void nsWidget::DispatchDragDropEvent( PRUint32 aEventType, PhPoint_t *pos ) {
|
|||
event.point.x = pos->x;
|
||||
event.point.y = pos->y;
|
||||
|
||||
event.isShift = 0;
|
||||
event.isControl = 0;
|
||||
PhDndEvent_t *dnd = ( PhDndEvent_t * ) PhGetData( phevent );
|
||||
event.isControl = ( dnd->key_mods & Pk_KM_Ctrl ) ? PR_TRUE : PR_FALSE;
|
||||
event.isShift = ( dnd->key_mods & Pk_KM_Shift ) ? PR_TRUE : PR_FALSE;
|
||||
event.isAlt = ( dnd->key_mods & Pk_KM_Alt ) ? PR_TRUE : PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.isAlt = 0;
|
||||
|
||||
event.widget = this;
|
||||
|
||||
|
@ -1220,16 +1222,16 @@ void nsWidget::DispatchDragDropEvent( PRUint32 aEventType, PhPoint_t *pos ) {
|
|||
|
||||
int nsWidget::DndCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) {
|
||||
nsWidget *pWidget = (nsWidget *) data;
|
||||
PtDndCallbackInfo_t *cbdnd = ( PtDndCallbackInfo_t * ) cbinfo->cbdata;
|
||||
PtDndCallbackInfo_t *cbdnd = ( PtDndCallbackInfo_t * ) cbinfo->cbdata;
|
||||
|
||||
static PtDndFetch_t dnd_data_template = { "Mozilla", "dnddata", Ph_TRANSPORT_INLINE, Pt_DND_SELECT_MOTION,
|
||||
NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
///* ATENTIE */ printf( "In nsWidget::DndCallback subtype=%d\n", cbinfo->reason_subtype );
|
||||
|
||||
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( cbinfo->event );
|
||||
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( cbinfo->event );
|
||||
//printf("Enter pos=%d %d\n", ptrev->pos.x, ptrev->pos.y );
|
||||
pWidget->ScreenToWidgetPos( ptrev->pos );
|
||||
pWidget->ScreenToWidgetPos( ptrev->pos );
|
||||
//printf("After trans pos=%d %d pWidget=%p\n", ptrev->pos.x, ptrev->pos.y, pWidget );
|
||||
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ protected:
|
|||
}
|
||||
|
||||
#ifdef PHOTON_DND
|
||||
void DispatchDragDropEvent( PRUint32 aEventType, PhPoint_t *pos );
|
||||
void DispatchDragDropEvent( PhEvent_t *phevent, PRUint32 aEventType, PhPoint_t *pos );
|
||||
void ProcessDrag( PhEvent_t *event, PRUint32 aEventType, PhPoint_t *pos );
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче