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
, view
,
52 WMViewRealizedNotification
,
53 /* just use as an id */
54 view
->dragDestinationProcs
);
63 WMGetDroppedData(WMView
*view
, WMDraggingInfo
*info
)
70 WMRegisterViewForDraggedTypes(WMView
*view
, char *acceptedTypes
[])
77 while (acceptedTypes
[typeCount
++]);
79 types
= wmalloc(sizeof(Atom
)*(typeCount
+1));
81 for (i
= 0; i
< typeCount
; i
++) {
82 types
[i
] = XInternAtom(W_VIEW_SCREEN(view
)->display
,
83 acceptedTypes
[i
], False
);
87 view
->droppableTypes
= types
;
89 W_SetXdndAwareProperty(W_VIEW_SCREEN(view
), view
, types
, typeCount
);
94 WMUnregisterViewDraggedTypes(WMView
*view
)
96 if (view
->droppableTypes
!= NULL
)
97 free(view
->droppableTypes
);
98 view
->droppableTypes
= NULL
;
101 /***********************************************************************/
104 WMSetViewDragDestinationProcs(WMView
*view
, WMDragDestinationProcs
*procs
)
106 if (view
->dragDestinationProcs
== NULL
) {
107 free(view
->dragDestinationProcs
);
108 view
->dragDestinationProcs
= wmalloc(sizeof(WMDragDestinationProcs
));
110 *view
->dragDestinationProcs
= *procs
;
112 /*XXX fill in non-implemented stuffs */