/* Implementation of IDropTarget::Drop
 * This function will not be called if pdwEffect is set to DROPEFFECT_NONE in 
 * the implementation of IDropTarget::DragOver
 */
HRESULT __stdcall GHOST_DropTargetWin32::Drop(IDataObject *pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
{
	void *data = getGhostData(pDataObject);
	if (m_window->canAcceptDragOperation())
	{
		*pdwEffect = allowedDropEffect(*pdwEffect);

	}
	else {
		*pdwEffect = DROPEFFECT_NONE;
	}
	if (data)
		m_system->pushDragDropEvent(GHOST_kEventDraggingDropDone, m_draggedObjectType, m_window, pt.x, pt.y, data);
		
	m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
	return S_OK;
}
bool GHOST_DropTargetX11::GHOST_HandleClientMessage(XEvent *event)
{
    Atom dropType;
    unsigned char *dropBuffer;
    int dropBufferSize, dropX, dropY;

    if (xdnd_get_drop(m_system->getXDisplay(), event, m_dndTypes, m_dndActions,
                      &dropBuffer, &dropBufferSize, &dropType, &dropX, &dropY))
    {
        void *data = getGhostData(dropType, dropBuffer, dropBufferSize);

        if (data)
            m_system->pushDragDropEvent(GHOST_kEventDraggingDropDone, m_draggedObjectType, m_window, dropX, dropY, data);

        free(dropBuffer);

        m_draggedObjectType = GHOST_kDragnDropTypeUnknown;

        return true;
    }

    return false;
}