2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: DndDrop.c /main/6 1996/09/27 19:00:45 drk $ */
24 /*********************************************************************
28 * Description: Implementation of DND Drop Registration
30 *********************************************************************
34 * RESTRICTED CONFIDENTIAL INFORMATION:
36 * The information in this document is subject to special
37 * restrictions in a confidential disclosure agreement between
38 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
39 * document outside HP, IBM, Sun, USL, SCO, or Univel without
40 * Sun's specific written approval. This documment and all copies
41 * and derivative works thereof must be returned or destroyed at
44 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
46 * (c) Copyright 1993, 1994 Hewlett-Packard Company
47 * (c) Copyright 1993, 1994 International Business Machines Corp.
48 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
49 * (c) Copyright 1993, 1994 Novell, Inc.
56 #include <X11/Intrinsic.h>
57 #include <Xm/AtomMgr.h>
58 #include <Xm/DragDrop.h>
59 #include <Xm/DropSMgr.h>
60 #include <Xm/DropTrans.h>
63 #include "DtSvcLock.h"
66 * Drop Receiver Callbacks
69 static void dndDropProc(Widget, XtPointer, XtPointer);
70 static void dndTransferStart(Widget, XmDropProcCallbackStruct*,
71 DtDropInfo*, DtDndTransfer*, Atom*, Cardinal);
72 static void dndTransferProc(Widget, XtPointer, Atom*, Atom*,
73 XtPointer, unsigned long*, int*);
74 static void dndAppTransfer(Widget, DtDropInfo*);
75 static void dndDropAnimateCallback(Widget, XtPointer, XtPointer);
78 * Drop Support Functions
81 static void dndDropSiteDestroy(Widget, XtPointer, XtPointer);
82 static XID dndGetContextXID(Display*);
83 static Boolean dndSaveDropInfo(Display*, Widget, DtDropInfo*);
84 static DtDropInfo * dndFindDropInfo(Display*, Widget);
85 static void dndTransferStartFailed(Widget);
86 static void dndTransferFail(DtDropInfo*, Widget);
89 * Drop Register Resources
93 XtCallbackList dropAnimateCallback;
94 Boolean preserveRegistration;
95 Boolean registerChildren;
99 #define Offset(field) XtOffsetOf(DropSettings, field)
101 static XtResource dropResources[] = {
102 { DtNdropAnimateCallback, DtCDropAnimateCallback,
103 XtRCallback, sizeof(XtCallbackList), Offset(dropAnimateCallback),
104 XtRImmediate, (XtPointer)NULL },
105 { DtNpreserveRegistration, DtCPreserveRegistration,
106 XtRBoolean, sizeof(Boolean), Offset(preserveRegistration),
107 XtRImmediate, (XtPointer)True },
108 { DtNregisterChildren, DtCRegisterChildren,
109 XtRBoolean, sizeof(Boolean), Offset(registerChildren),
110 XtRImmediate, (XtPointer)False },
111 { DtNtextIsBuffer, DtCTextIsBuffer,
112 XtRBoolean, sizeof(Boolean), Offset(textIsBuffer),
113 XtRImmediate, (XtPointer)False },
119 * DtDndVaDropRegister
121 * Drop Site Registration - varargs version
127 DtDndProtocol protocols,
128 unsigned char operations,
129 XtCallbackList transferCallback,
135 _DtSvcWidgetToAppContext(dropReceiver);
138 va_start(vaList, transferCallback);
139 argCount = _DtDndCountVarArgs(vaList);
142 va_start(vaList, transferCallback);
143 _DtDndArgListFromVarArgs(vaList, argCount, &argList, &argCount);
146 DtDndDropRegister(dropReceiver, protocols, operations,
147 transferCallback, argList, argCount);
149 XtFree((char *)argList);
150 _DtSvcAppUnlock(app);
156 * Drop Site Registration - arglist version
162 DtDndProtocol protocols,
163 unsigned char operations,
164 XtCallbackList dropTransferCallback,
168 Display * display = XtDisplayOfObject(dropReceiver);
169 DropSettings settings;
170 DtDropInfo * dtDropInfo;
171 DtDropSiteInfo* dsInfo = NULL;
172 DtDndTransfer * transfers;
173 Cardinal numTransfers;
175 Cardinal numImportTargets;
176 unsigned char mergedOperations;
179 _DtSvcWidgetToAppContext(dropReceiver);
184 * Reject a noop registration
186 if (protocols == DtDND_NOOP_TRANSFER) {
187 _DtSvcAppUnlock(app);
192 * Parse resources into dropResources
194 XtGetSubresources(dropReceiver, &settings,
195 (String)NULL, (String)NULL,
196 dropResources, XtNumber(dropResources),
199 * Initialize DropInfo
202 dtDropInfo = (DtDropInfo *) XtMalloc(sizeof(DtDropInfo));
204 dtDropInfo->dropReceiver = dropReceiver;
205 dtDropInfo->protocols = protocols;
206 dtDropInfo->operations = operations;
207 dtDropInfo->textIsBuffer = settings.textIsBuffer;
208 dtDropInfo->dropSiteInfo = NULL;
209 dtDropInfo->transferInfo = NULL;
210 dtDropInfo->status = DtDND_SUCCESS;
212 dtDropInfo->dropTransferCallback
213 = _DtDndCopyCallbackList(dropTransferCallback);
214 dtDropInfo->dropAnimateCallback
215 = _DtDndCopyCallbackList(settings.dropAnimateCallback);
218 * Initialize Transfer Methods
221 transfers = _DtDndCreateImportTransfers(dtDropInfo, &numTransfers);
223 dtDropInfo->transfers = transfers;
224 dtDropInfo->numTransfers = numTransfers;
227 printf("DtDndDropRegister: registering widget 0x%p\n", dropReceiver);
228 _DtDndPrintTransfers(display,transfers,numTransfers);
232 * Preserve existing drop registration info if requested
235 if (settings.preserveRegistration) {
238 dsInfo = (DtDropSiteInfo *)XtMalloc(sizeof(DtDropSiteInfo));
240 dsInfo->dropProc = (XtCallbackProc)NULL;
241 dsInfo->operations = XmDROP_NOOP;
242 dsInfo->importTargets = NULL;
243 dsInfo->numImportTargets = 0;
247 XtSetArg(pArgs[nn], XmNimportTargets,
248 &(dsInfo->importTargets)); nn++;
249 XtSetArg(pArgs[nn], XmNdropSiteOperations,
250 &(dsInfo->operations)); nn++;
251 XtSetArg(pArgs[nn], XmNnumImportTargets,
252 &(dsInfo->numImportTargets)); nn++;
253 XtSetArg(pArgs[nn], XmNdropProc,
254 &(dsInfo->dropProc)); nn++;
256 XmDropSiteRetrieve(dropReceiver, pArgs, nn);
258 if ( (dsInfo->dropProc != NULL) &&
259 (dsInfo->numImportTargets > 0) &&
260 (dsInfo->operations != XmDROP_NOOP) ){
262 dtDropInfo->dropSiteInfo = dsInfo;
264 XtFree((char *)dsInfo);
270 * Create list of import targets based on the requested transfer
271 * protocols and any preserved drop site registration.
274 numImportTargets = 0;
276 for (ii = 0; ii < numTransfers; ii++) {
277 numImportTargets += transfers[ii].numTargets;
280 if (dsInfo != NULL) {
281 numImportTargets += dsInfo->numImportTargets;
284 importTargets = (Atom *) XtMalloc(numImportTargets * sizeof(Atom));
287 for (ii = 0; ii < numTransfers; ii++) {
288 for (jj = 0; jj < transfers[ii].numTargets; jj++) {
289 importTargets[kk++] = transfers[ii].targets[jj];
293 if (dsInfo != NULL) {
294 for (jj = 0; jj < dsInfo->numImportTargets; jj++) {
295 importTargets[kk++] = dsInfo->importTargets[jj];
303 if (dsInfo != NULL) {
304 mergedOperations = dsInfo->operations | operations;
306 mergedOperations = operations;
310 * Create an argument list
313 #define NUM_DROP_ARGS 5
314 args = (Arg *) XtMalloc(sizeof(Arg) * (NUM_DROP_ARGS + argCount));
318 * Copy in passed arguments
323 for (ii = 0; ii < argCount; ii++) {
324 XtSetArg(args[nn], argList[ii].name, argList[ii].value); nn++;
328 * Set argument list for drop site registration
331 XtSetArg(args[nn], XmNimportTargets, importTargets); nn++;
332 XtSetArg(args[nn], XmNnumImportTargets, numImportTargets); nn++;
333 XtSetArg(args[nn], XmNdropSiteOperations, mergedOperations); nn++;
334 XtSetArg(args[nn], XmNdropProc, dndDropProc); nn++;
336 if (settings.registerChildren) {
337 XtSetArg(args[nn], XmNdropSiteType, XmDROP_SITE_COMPOSITE); nn++;
341 * Register the drop site
344 if (dsInfo != NULL) {
345 XmDropSiteUnregister(dropReceiver);
346 XmDropSiteRegister(dropReceiver, args, nn);
348 XmDropSiteRegister(dropReceiver, args, nn);
352 * Add a destroy callback to unregister the drop site
353 * Store the dropInfo using the dropReceiver as the context
354 * Free locally allocated memory
357 XtAddCallback(dropReceiver, XtNdestroyCallback,
358 dndDropSiteDestroy, NULL);
360 (void)dndSaveDropInfo(display, dropReceiver, dtDropInfo);
362 XtFree((char *)importTargets);
363 XtFree((char *)args);
364 _DtSvcAppUnlock(app);
368 * DtDndDropUnregister
370 * Unregister the drop site
376 Display *display = XtDisplayOfObject(dropReceiver);
377 DtDropInfo *dtDropInfo;
378 DtDropSiteInfo *dsInfo;
379 _DtSvcWidgetToAppContext(dropReceiver);
384 * Retrieve dropInfo. If there isn't one then the drop site
385 * was not registered by DtDndDropRegister() so return.
388 if ((dtDropInfo = dndFindDropInfo(display, dropReceiver)) == NULL) {
389 _DtSvcAppUnlock(app);
392 dsInfo = dtDropInfo->dropSiteInfo;
395 * Unregister the drop site
398 XmDropSiteUnregister(dropReceiver);
401 * If we have preserved drop site registration
402 * then restore the drop site to it's original state.
405 if (dsInfo != NULL) {
409 XtSetArg(args[nn], XmNimportTargets,
410 dsInfo->importTargets); nn++;
411 XtSetArg(args[nn], XmNnumImportTargets,
412 dsInfo->numImportTargets); nn++;
413 XtSetArg(args[nn], XmNdropProc,
414 dsInfo->dropProc); nn++;
415 XtSetArg(args[nn], XmNdropSiteOperations,
416 dsInfo->operations); nn++;
418 XmDropSiteRegister(dropReceiver, args, nn);
420 XtFree((char *)dsInfo);
424 * Free callback, context and memory associated with DtDndDropRegister
427 XtRemoveCallback(dropReceiver, XtNdestroyCallback,
428 dndDropSiteDestroy, NULL);
430 XDeleteContext(display, dndGetContextXID(display),
431 (XContext)dropReceiver);
433 _DtDndDestroyTransfers(dtDropInfo->transfers, dtDropInfo->numTransfers);
435 XtFree((char *)dtDropInfo->dropTransferCallback);
436 XtFree((char *)dtDropInfo->dropAnimateCallback);
437 XtFree((char *)dtDropInfo);
438 _DtSvcAppUnlock(app);
442 /*********************************************************************
444 * Drop Receiver Callbacks
446 *********************************************************************/
452 * Determine transfer target and operation and initiate transfer.
457 XtPointer clientData,
460 XmDropProcCallbackStruct *xmDropInfo =
461 (XmDropProcCallbackStruct *) callData;
462 Display * display = XtDisplayOfObject(dropReceiver);
464 Atom * exportTargets = NULL;
465 Cardinal numExportTargets = 0;
466 DtDropInfo * dtDropInfo;
467 DtDropSiteInfo* dsInfo;
468 DtDndTransfer * transfer;
471 * Reject invalid drops
474 if ( (xmDropInfo->dropSiteStatus != XmDROP_SITE_VALID) ||
475 (xmDropInfo->operation == XmDROP_NOOP) ||
476 (xmDropInfo->dropAction != XmDROP) ) {
479 printf("dndDropProc: failed drop status or operation\n");
481 dndTransferStartFailed(xmDropInfo->dragContext);
486 * Get the cached DropInfo
489 if ((dtDropInfo = dndFindDropInfo(display, dropReceiver)) == NULL) {
490 dndTransferStartFailed(xmDropInfo->dragContext);
495 * Get the export targets from the dragContext
498 XtVaGetValues(xmDropInfo->dragContext,
499 XmNexportTargets, &exportTargets,
500 XmNnumExportTargets, &numExportTargets,
503 if (exportTargets == NULL) {
504 dndTransferStartFailed(xmDropInfo->dragContext);
505 dtDropInfo->status = DtDND_FAILURE;
510 printf("dndDropProc: Export Targets: ");
511 _DtDndPrintTargets(display,exportTargets,numExportTargets);
515 * Search the DnD protocol import targets list to see
516 * if it's a target we handle. If it is then start our transfer.
519 transfer = _DtDndTransferFromTargets(
520 dtDropInfo->transfers, dtDropInfo->numTransfers,
521 exportTargets, numExportTargets);
523 if (transfer != NULL) {
525 dndTransferStart(dropReceiver, xmDropInfo, dtDropInfo,
526 transfer, exportTargets, numExportTargets);
531 * If there isn't any alternate drop registration
532 * then fail the transfer
535 dsInfo = dtDropInfo->dropSiteInfo;
537 if (dsInfo == NULL) {
538 dndTransferStartFailed(xmDropInfo->dragContext);
539 dtDropInfo->status = DtDND_FAILURE;
544 * Determine if the exportTargets are compatible with
545 * the alternate drop registration targets
546 * If they are not compatible then fail the transfer
547 * Otherwise call the original dropProc.
550 compatible = XmTargetsAreCompatible(display,
551 dsInfo->importTargets, dsInfo->numImportTargets,
552 exportTargets, numExportTargets);
555 dndTransferStartFailed(xmDropInfo->dragContext);
556 dtDropInfo->status = DtDND_FAILURE;
560 if (dsInfo->dropProc != NULL) {
561 (*(dsInfo->dropProc))(dropReceiver, clientData, callData);
568 * Start the transfer using protocol specific transfer entries
574 XmDropProcCallbackStruct *xmDropInfo,
575 DtDropInfo * dtDropInfo,
576 DtDndTransfer * transfer,
577 Atom * exportTargets,
578 Cardinal numExportTargets)
580 XtCallbackRec dropAnimateCbRec[] = { {dndDropAnimateCallback,
581 NULL}, {NULL, NULL} };
582 Display * display = XtDisplayOfObject(dropReceiver);
583 DtDndContext * dropData;
584 DtTransferInfo *transferInfo;
585 Atom * transferTargets;
586 Cardinal numTransferTargets;
588 XmDropTransferEntryRec * transferEntries;
589 Cardinal numTransferEntries;
590 int posOffsetX, posOffsetY;
596 printf("dndTransferStart: transfer method = %s\n",
597 transfer->methods->name);
600 * If the operation is a move but not registered for a move
601 * then force it to a copy drop.
604 if ((xmDropInfo->operation == XmDROP_MOVE) &&
605 !(dtDropInfo->operations & XmDROP_MOVE)) {
606 xmDropInfo->operation = XmDROP_COPY;
610 * Determine icon adjustment to drop position
613 _DtDndGetIconOffset(xmDropInfo->dragContext,
614 transfer->methods->sourceType,
615 &posOffsetX, &posOffsetY);
618 * Initialize drop transfer info
621 transferInfo = (DtTransferInfo *)XtMalloc(sizeof(DtTransferInfo));
623 transferInfo->dragContext = xmDropInfo->dragContext;
624 transferInfo->protocol = transfer->methods->protocol;
625 transferInfo->operation = xmDropInfo->operation;
626 transferInfo->methods = transfer->methods;
627 transferInfo->transferTargets = NULL;
628 transferInfo->numTransferTargets = 0;
629 transferInfo->currentTransfer = 0;
630 transferInfo->appTransferCalled = False;
631 transferInfo->event = xmDropInfo->event;
632 transferInfo->x = xmDropInfo->x + posOffsetX;
633 transferInfo->y = xmDropInfo->y + posOffsetY;
634 transferInfo->clientData = NULL;
637 * Initialize drop data
640 dropData = (DtDndContext *)XtCalloc(1,sizeof(DtDndContext));
642 dropData->protocol = transferInfo->protocol;
645 * Initialize drop transfer fields of DtDropInfo
648 dtDropInfo->transferInfo = transferInfo;
649 dtDropInfo->dropData = dropData;
650 dtDropInfo->status = DtDND_SUCCESS;
653 * Get protocol specific transfer targets
656 (*transferInfo->methods->transferTargets)(dtDropInfo,
657 exportTargets, numExportTargets,
658 &transferTargets, &numTransferTargets);
660 if (transferTargets == NULL) {
662 XtFree((char *)dtDropInfo->transferInfo);
663 XtFree((char *)dtDropInfo->dropData);
665 dtDropInfo->transferInfo = NULL;
666 dtDropInfo->dropData = NULL;
667 dtDropInfo->status = DtDND_FAILURE;
669 dndTransferStartFailed(xmDropInfo->dragContext);
674 * Convert _SUN_ENUMERATION_COUNT if available
675 * Insert into transfer targets list
677 owCompat = XmTargetsAreCompatible(display,
678 exportTargets, numExportTargets,
679 &XA_SUN_ENUM_COUNT, 1);
682 Cardinal jj, numTargets;
685 numTargets = numTransferTargets + 1;
686 targets = (Atom *)XtMalloc(numTargets * sizeof(Atom));
689 targets[jj++] = XA_SUN_ENUM_COUNT;
691 for (ii = 0; ii < numTransferTargets; ii++, jj++) {
692 targets[jj] = transferTargets[ii];
695 XtFree((char *)transferTargets);
697 transferTargets = targets;
698 numTransferTargets = numTargets;
702 * Create a transfer entries list from the transfer targets
705 numTransferEntries = numTransferTargets;
706 transferEntries = (XmDropTransferEntryRec *)
707 XtMalloc(numTransferEntries * sizeof(XmDropTransferEntryRec));
709 for (ii = 0; ii < numTransferEntries; ii++) {
710 transferEntries[ii].target = transferTargets[ii];
711 transferEntries[ii].client_data = (XtPointer)dtDropInfo;
714 transferInfo->transferTargets = transferTargets;
715 transferInfo->numTransferTargets = numTransferTargets;
718 printf("Requesting transfers: ");
719 _DtDndPrintTargets(display,transferTargets,numTransferTargets);
723 * Start the drop transfer
726 dropAnimateCbRec[0].closure = (XtPointer) dtDropInfo;
727 transferInfo->dropAnimateCallback
728 = _DtDndCopyCallbackList(dropAnimateCbRec);
730 XtSetArg(args[nn], XmNdropTransfers, transferEntries); nn++;
731 XtSetArg(args[nn], XmNnumDropTransfers, numTransferEntries);nn++;
732 XtSetArg(args[nn], XmNtransferProc, dndTransferProc); nn++;
733 XtSetArg(args[nn], XmNdestroyCallback, transferInfo->dropAnimateCallback); nn++;
735 (void)XmDropTransferStart(xmDropInfo->dragContext, args, nn);
737 XtFree((char *)transferEntries);
743 * Process the transfers
748 XtPointer clientData,
752 unsigned long * length,
755 DtDropInfo * dtDropInfo = (DtDropInfo *)clientData;
756 DtTransferInfo *transferInfo = dtDropInfo->transferInfo;
761 * Ignore if no dtDropInfo or failed transfer
762 * Ignore null transfer (which are responses to DELETE)
765 if (value == NULL || dtDropInfo == NULL ||
766 dtDropInfo->status == DtDND_FAILURE) {
767 dndTransferFail(dtDropInfo, dropTransfer);
770 } else if (*type == XA_NULL) {
776 * Determine current transfer target
779 index = transferInfo->currentTransfer;
781 if (index < transferInfo->numTransferTargets) {
782 target = transferInfo->transferTargets[index];
786 transferInfo->currentTransfer++;
790 Display *display = XtDisplayOfObject(dropTransfer);
791 char *targetname = XGetAtomName(display,target);
792 char *typename = XGetAtomName(display,*type);
793 printf("dndTransferProc: target = %s type = %s fmt = %d len = %ld\n",
794 (targetname ? targetname : "Null"),
795 (typename ? typename : "Null"),
797 if (targetname) XFree(targetname);
798 if (typename) XFree(typename);
803 * Handle _SUN_ENUMERATION_COUNT request; reject multiple items
805 if (target == XA_SUN_ENUM_COUNT) {
806 int * enumCount = (int *)value;
807 if (enumCount[0] > 1) {
808 dndTransferFail(dtDropInfo, dropTransfer);
815 * Invoke protocol specific transfer proc
818 (*transferInfo->methods->transfer)( dropTransfer, dtDropInfo,
819 selection, &target, type, value, length, format);
822 * If the transfer failed, set up to terminate unsuccessfully
825 if (dtDropInfo->status == DtDND_FAILURE) {
826 dndTransferFail(dtDropInfo, dropTransfer);
831 * If the transfers are complete;
832 * If the dropData isn't ready then fail the transfer
833 * Otherwise call the application transfer callback
836 if (transferInfo->currentTransfer == transferInfo->numTransferTargets) {
838 if (dtDropInfo->dropData->numItems == 0) {
839 dndTransferFail(dtDropInfo, dropTransfer);
841 } else if (!transferInfo->appTransferCalled) {
842 dndAppTransfer(dropTransfer, dtDropInfo);
843 transferInfo->appTransferCalled = True;
851 * Call the application transfer callback
856 DtDropInfo * dtDropInfo)
858 DtTransferInfo *transferInfo = dtDropInfo->transferInfo;
859 DtDndTransferCallbackStruct transferCallData;
862 * If the transfer failed or there isn't a callback simply return
865 if (dtDropInfo->status == DtDND_FAILURE ||
866 dtDropInfo->dropTransferCallback == NULL) {
871 * Fill in the callback structure and call the
872 * application-defined dropTransferCallback.
875 transferCallData.reason = DtCR_DND_TRANSFER_DATA;
876 transferCallData.event = transferInfo->event;
877 transferCallData.x = transferInfo->x;
878 transferCallData.y = transferInfo->y;
879 transferCallData.operation = transferInfo->operation;
880 transferCallData.dropData = dtDropInfo->dropData;
881 transferCallData.dragContext = transferInfo->dragContext;
882 transferCallData.status = DtDND_SUCCESS;
884 if (transferInfo->operation == XmDROP_MOVE) {
885 transferCallData.completeMove = True;
887 transferCallData.completeMove = False;
890 _DtDndCallCallbackList(dtDropInfo->dropReceiver,
891 dtDropInfo->dropTransferCallback,
892 (XtPointer)&transferCallData);
894 dtDropInfo->status = transferCallData.status;
897 * If the app requests it then fail the transfer
899 if (transferCallData.status == DtDND_FAILURE) {
900 dndTransferFail(dtDropInfo, dropTransfer);
905 * If the transfer succeeded and this is a move operation
906 * then transfer DELETE to delete the original.
909 if (transferCallData.status == DtDND_SUCCESS &&
910 transferCallData.completeMove &&
911 transferInfo->operation == XmDROP_MOVE) {
913 XmDropTransferEntryRec transferEntries[1];
915 transferEntries[0].target = XA_DELETE;
916 transferEntries[0].client_data = (XtPointer)dtDropInfo;
918 XmDropTransferAdd(dropTransfer, transferEntries, 1);
923 * dndDropAnimateCallback
925 * Call the application dropAnimateCallback
928 dndDropAnimateCallback(
930 XtPointer clientData,
933 DtDropInfo * dtDropInfo = (DtDropInfo *)clientData;
934 DtTransferInfo *transferInfo = dtDropInfo->transferInfo;
935 DtDndDropAnimateCallbackStruct dropAnimateCallData;
938 * Fill in the callback structure and call the
939 * application-defined dropAnimateCallback.
942 if (dtDropInfo->status == DtDND_SUCCESS &&
943 dtDropInfo->dropAnimateCallback != NULL) {
945 dropAnimateCallData.reason = DtCR_DND_DROP_ANIMATE;
946 dropAnimateCallData.event = transferInfo->event;
947 dropAnimateCallData.x = transferInfo->x;
948 dropAnimateCallData.y = transferInfo->y;
949 dropAnimateCallData.operation = transferInfo->operation;
950 dropAnimateCallData.dropData = dtDropInfo->dropData;
952 _DtDndCallCallbackList(dtDropInfo->dropReceiver,
953 dtDropInfo->dropAnimateCallback,
954 (XtPointer)&dropAnimateCallData);
958 * Invoke the protocol specific transfer finish proc
961 (*transferInfo->methods->transferFinish)(dtDropInfo);
964 * Free transfer created memory
966 XtFree((char *)dtDropInfo->transferInfo->transferTargets);
967 XtFree((char *)dtDropInfo->transferInfo->dropAnimateCallback);
968 XtFree((char *)dtDropInfo->transferInfo);
969 XtFree((char *)dtDropInfo->dropData);
971 dtDropInfo->transferInfo = NULL;
972 dtDropInfo->dropData = NULL;
978 * Destroy callback unregisters the widget being destroyed as a drop site
983 XtPointer clientData,
986 DtDndDropUnregister(widget);
992 * Returns a pixmap to use as the XID for Save/Find Context
998 static XID contextXID;
1000 _DtSvcProcessLock();
1001 if (contextXID == NULL) {
1002 contextXID = XCreatePixmap(display,
1003 DefaultRootWindow(display), 1, 1, 1);
1005 _DtSvcProcessUnlock();
1012 * Saves the DtDropInfo relative to the dropReceiver
1017 Widget dropReceiver,
1018 DtDropInfo * dtDropInfo)
1022 status = XSaveContext(display, dndGetContextXID(display),
1023 (XContext)dropReceiver, (XPointer)dtDropInfo);
1025 return (status == 0);
1031 * Finds the DtDropInfo saved relative to the dropReceiver
1036 Widget dropReceiver)
1039 DtDropInfo * dtDropInfo;
1041 status = XFindContext(display, dndGetContextXID(display),
1042 (XContext)dropReceiver, (XPointer *)&dtDropInfo);
1045 dtDropInfo = (DtDropInfo *)NULL;
1051 * dndTransferStartFailed
1053 * Fail the transfer by starting a 'failure' transfer
1054 * Calls XmDropTransferStart()
1057 dndTransferStartFailed(
1063 XtSetArg(args[nn], XmNtransferStatus, XmTRANSFER_FAILURE); nn++;
1064 XtSetArg(args[nn], XmNnumDropTransfers, 0); nn++;
1066 XmDropTransferStart(dragContext, args, nn);
1072 * Fail the transfer by setting the dropTransfer widget to failure
1073 * Assumes XmDropTransferStart() already called.
1077 DtDropInfo * dtDropInfo,
1078 Widget dropTransfer)
1081 dtDropInfo->status = DtDND_FAILURE;
1083 XtVaSetValues(dropTransfer,
1084 XmNtransferStatus, XmTRANSFER_FAILURE,
1085 XmNnumDropTransfers, 0,