Solaris Common Desktop Environment: Programmer's Guide

API Overview

This section provides an overview of the drag-and-drop application program interface (API).

DtSvc Library and Header File

The drag-and-drop functionality is implemented in the Desktop Services library, DtSvc. To access the drag-and-drop API, include the header file <Dt/Dnd.h> and link with -lDtSvc.

Functions

The API includes four function calls, which are declared in the header file Dnd.h and outlined in the following paragraphs. These functions are described in greater detail in later sections.

The DtDndContext Structure

You handle transfers of data using the DtDndContext data structure. This structure contains fields for the transfer protocol, the number of items being transferred, and an array of the data items being transferred. See the DtDndDragStart(3X) and DtDndDropRegister(3X) man pages for details about the syntax of this structure.

Protocols

Protocols are used to tell the API the type of data being transferred. The predefined protocols are shown in Table 5-6.

Table 5-6 Predefined Protocols

Protocol 

Description 

DtDND_TEXT_TRANSFER

Text transfer. Compound text. (Motif uses a compound text target for text transfers.) 

DtDND_FILENAME_TRANSFER

File name transfer. 

DtDND_BUFFER_TRANSFER

Memory buffer. 

Operations

The drag source and the drop zone can transfer the data in one of three ways, as described in Table 5-7.

Table 5-7 Data Transfer Operations

Operation 

Description 

XmDROP_MOVE

Moves the data (Copy followed by Delete). 

XmDROP_COPY

Copies the data. 

XmDROP_LINK

Contains a link to the data.