fixed misc bugs
[wmaker-crm.git] / WINGs / dragdestination.c
blob06f55eaff73312c76dbf2d0dd7de2f6fc9b3067c
3 #include <X11/Xatom.h>
5 #include "WINGsP.h"
8 /* dropping */
10 typedef struct W_DNDTargetInfo {
11 /* data types accepted for drops */
12 Atom *dropTypes;
13 int dropTypeCount;
16 } DNDTargetInfo;
19 static Atom XDNDversion = XDND_VERSION;
22 static void
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);
36 void
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);
50 } else {
51 WMAddNotificationObserver(realizedObserver, view,
52 WMViewRealizedNotification,
53 /* just use as an id */
54 view->dragDestinationProcs);
62 WMData*
63 WMGetDroppedData(WMView *view, WMDraggingInfo *info)
65 return NULL;
69 void
70 WMRegisterViewForDraggedTypes(WMView *view, char *acceptedTypes[])
72 Atom *types;
73 int typeCount;
74 int i;
76 typeCount = 0;
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);
85 types[i] = 0;
87 view->droppableTypes = types;
89 W_SetXdndAwareProperty(W_VIEW_SCREEN(view), view, types, typeCount);
93 void
94 WMUnregisterViewDraggedTypes(WMView *view)
96 if (view->droppableTypes != NULL)
97 free(view->droppableTypes);
98 view->droppableTypes = NULL;
101 /***********************************************************************/
103 void
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 */