10 typedef struct W_DNDTargetInfo
{
11 /* data types accepted for drops */
19 static Atom XDNDversion
= XDND_VERSION
;
23 realizedObserver(void *self
, WMNotification
*notif
)
25 WMView
*view
= (WMView
*)WMGetNotificationObject(notif
);
27 XChangeProperty(W_VIEW_SCREEN(view
)->display
, W_VIEW_DRAWABLE(view
),
28 W_VIEW_SCREEN(view
)->xdndAwareAtom
,
29 XA_ATOM
, 32, PropModeReplace
,
30 (unsigned char*)&XDNDversion
, 1);
32 WMRemoveNotificationObserver(self
);
37 W_SetXdndAwareProperty(WMScreen
*scr
, WMView
*view
, Atom
*types
, int typeCount
)
39 Display
*dpy
= scr
->display
;
41 view
= W_TopLevelOfView(view
);
43 if (!view
->flags
.xdndHintSet
) {
44 view
->flags
.xdndHintSet
= 1;
46 if (view
->flags
.realized
) {
47 XChangeProperty(dpy
, W_VIEW_DRAWABLE(view
), scr
->xdndAwareAtom
,
48 XA_ATOM
, 32, PropModeReplace
,
49 (unsigned char*)&XDNDversion
, 1);
51 WMAddNotificationObserver(realizedObserver
,
52 /* just use as an id */
53 &view
->dragDestinationProcs
,
54 WMViewRealizedNotification
,
63 WMRegisterViewForDraggedTypes(WMView
*view
, char *acceptedTypes
[])
70 while (acceptedTypes
[typeCount
++]);
72 types
= wmalloc(sizeof(Atom
)*(typeCount
+1));
74 for (i
= 0; i
< typeCount
; i
++) {
75 types
[i
] = XInternAtom(W_VIEW_SCREEN(view
)->display
,
76 acceptedTypes
[i
], False
);
80 view
->droppableTypes
= types
;
82 W_SetXdndAwareProperty(W_VIEW_SCREEN(view
), view
, types
, typeCount
);
87 WMUnregisterViewDraggedTypes(WMView
*view
)
89 if (view
->droppableTypes
!= NULL
)
90 wfree(view
->droppableTypes
);
91 view
->droppableTypes
= NULL
;
94 /***********************************************************************/
98 defDraggingEntered(WMView
*self
, WMDraggingInfo
*info
)
100 printf("%x drag entered\n", W_VIEW_DRAWABLE(self
));
101 return WDOperationNone
;
105 defDraggingUpdated(WMView
*self
, WMDraggingInfo
*info
)
107 printf("%x drag update\n", W_VIEW_DRAWABLE(self
));
108 return WDOperationNone
;
112 defDraggingExited(WMView
*self
, WMDraggingInfo
*info
)
114 printf("%x drag exit\n", W_VIEW_DRAWABLE(self
));
118 defPrepareForDragOperation(WMView
*self
, WMDraggingInfo
*info
)
120 printf("%x drag prepare\n", W_VIEW_DRAWABLE(self
));
125 defPerformDragOperation(WMView
*self
, WMDraggingInfo
*info
)
127 printf("%x drag perform\n", W_VIEW_DRAWABLE(self
));
132 defConcludeDragOperation(WMView
*self
, WMDraggingInfo
*info
)
134 printf("%x drag conclude\n", W_VIEW_DRAWABLE(self
));
140 WMSetViewDragDestinationProcs(WMView
*view
, WMDragDestinationProcs
*procs
)
142 if (view
->dragDestinationProcs
== NULL
) {
143 view
->dragDestinationProcs
= wmalloc(sizeof(WMDragDestinationProcs
));
145 free(view
->dragDestinationProcs
);
147 *view
->dragDestinationProcs
= *procs
;
149 /*XXX fill in non-implemented stuffs */
150 if (procs
->draggingEntered
== NULL
) {
151 view
->dragDestinationProcs
->draggingEntered
= defDraggingEntered
;
153 if (procs
->draggingUpdated
== NULL
) {
154 view
->dragDestinationProcs
->draggingUpdated
= defDraggingUpdated
;
156 if (procs
->draggingExited
== NULL
) {
157 view
->dragDestinationProcs
->draggingExited
= defDraggingExited
;
159 if (procs
->prepareForDragOperation
== NULL
) {
160 view
->dragDestinationProcs
->prepareForDragOperation
=
161 defPrepareForDragOperation
;
163 if (procs
->performDragOperation
== NULL
) {
164 view
->dragDestinationProcs
->performDragOperation
=
165 defPerformDragOperation
;
167 if (procs
->concludeDragOperation
== NULL
) {
168 view
->dragDestinationProcs
->concludeDragOperation
=
169 defConcludeDragOperation
;
176 WMGetDraggingInfoImageLocation(WMDraggingInfo
*info
)
178 return info
->imageLocation
;
184 receivedData(WMView
*view
, Atom selection
, Atom target
, Time timestamp
,
185 void *cdata
, WMData
*data
)
193 WMRequestDroppedData(WMView
*view
, WMDraggingInfo
*info
, char *type
,
194 WMDropDataCallback
*callback
)
197 WMScreen
*scr
= W_VIEW_SCREEN(view
);
198 if (info
->finished
) {
203 if (!WMRequestSelection(scr
->dragInfo
.destView
,
204 scr
->xdndSelectionAtom
,
205 XInternAtom(scr
->display
, type
, False
),
206 scr
->dragInfo
.timestamp
,
207 receivedData
, &scr
->dragInfo
)) {
208 wwarning("could not request data for dropped data");
210 /* send finished message */
211 sendClientMessage(scr
->display
, source
,
212 scr
->xdndFinishedAtom
,
213 scr
->dragInfo
.destinationWindow
,
217 /* send finished message */
218 sendClientMessage(scr
->display
, source
,
219 scr
->xdndFinishedAtom
,
220 scr
->dragInfo
.destinationWindow
,