Esempio n. 1
0
//-----------------------------------------------------
void
nsNativeDragTarget::ProcessDrag(LPDATAOBJECT pData,
                                PRUint32     aEventType,
                                DWORD        grfKeyState,
                                POINTL       ptl,
                                DWORD*       pdwEffect)
{
  // Before dispatching the event make sure we have the correct drop action set
  PRUint32 geckoAction;
  GetGeckoDragAction(pData, grfKeyState, pdwEffect, &geckoAction);

  // Set the current action into the Gecko specific type
  nsCOMPtr<nsIDragSession> currSession;
  mDragService->GetCurrentSession(getter_AddRefs(currSession));
  if (!currSession) {
    return;
  }

  currSession->SetDragAction(geckoAction);

  // Dispatch the event into Gecko
  DispatchDragDropEvent(aEventType, ptl);

  // Now get the cached Drag effect from the drag service
  // the data memeber should have been set by who ever handled the
  // nsGUIEvent or nsIDOMEvent
  PRBool canDrop;
  currSession->GetCanDrop(&canDrop);
  if (!canDrop)
    *pdwEffect = DROPEFFECT_NONE;

  // Clear the cached value
  currSession->SetCanDrop(PR_FALSE);
}
Esempio n. 2
0
//-----------------------------------------------------
STDMETHODIMP
nsNativeDragTarget::DragLeave()
{
  if (DRAG_DEBUG) printf("DragLeave\n");

	if (!mDragService) {
		return ResultFromScode(E_FAIL);
  }

  // Drag and drop image helper
  if (mDropTargetHelper) {
    mDropTargetHelper->DragLeave();
  }

  // dispatch the event into Gecko
  DispatchDragDropEvent(NS_DRAGDROP_EXIT, gDragLastPoint);

  nsCOMPtr<nsIDragSession> currentDragSession;
  mDragService->GetCurrentSession(getter_AddRefs(currentDragSession));

  if (currentDragSession) {
    nsCOMPtr<nsIDOMNode> sourceNode;
    currentDragSession->GetSourceNode(getter_AddRefs(sourceNode));

    if (!sourceNode) {
      // We're leaving a window while doing a drag that was
      // initiated in a different app. End the drag session, since
      // we're done with it for now (until the user drags back into
      // mozilla).
      mDragService->EndDragSession(PR_FALSE);
    }
  }

  // release the ref that was taken in DragEnter
  NS_ASSERTION(mTookOwnRef, "want to release own ref, but not taken!");
  if (mTookOwnRef) {
    this->Release();
    mTookOwnRef = PR_FALSE;
  }

  return S_OK;
}
Esempio n. 3
0
void nsWidget::ProcessDrag( PhEvent_t *event, PRUint32 aEventType, PhPoint_t *pos ) {
    nsCOMPtr<nsIDragSession> currSession;
    sDragService->GetCurrentSession ( getter_AddRefs(currSession) );
    if( !currSession ) return;

    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;

    currSession->SetDragAction( action );

    DispatchDragDropEvent( event, aEventType, pos );

    int old_subtype = event->subtype;
    event->subtype = Ph_EV_DND_ENTER;

    PRBool canDrop;
    currSession->GetCanDrop(&canDrop);
    if(!canDrop) {
        static PhCharacterCursorDescription_t nodrop_cursor = {  { Ph_CURSOR_NOINPUT, sizeof(PhCharacterCursorDescription_t) }, PgRGB( 255, 255, 224 ) };
        PhAckDnd( event, Ph_EV_DND_MOTION, ( PhCursorDescription_t * ) &nodrop_cursor );
    }
    else {
        static PhCharacterCursorDescription_t drop_cursor = { { Ph_CURSOR_PASTE, sizeof(PhCharacterCursorDescription_t) }, PgRGB( 255, 255, 224 ) };
        PhAckDnd( event, Ph_EV_DND_MOTION, ( PhCursorDescription_t * ) &drop_cursor );
    }

    event->subtype = old_subtype;

    // Clear the cached value
    currSession->SetCanDrop(PR_FALSE);
}